View Single Post
 
Old 02-05-2013, 09:31 AM
AnneN AnneN is offline Windows 7 32bit Office 2010 32bit
Novice
 
Join Date: Feb 2013
Posts: 1
AnneN is on a distinguished road
Default Macro to send document in email

I'm trying to write a Macro that takes a Word 2010 document and sends it in the body of an email to a set email distribution list by clicking a button on the document. I had everything working but only when I run the Macro on my computer and this will be a report that several people will fill out and will need to email. Then I upgraded to Office 2010 and now it won't even work on my PC.

Any help is appreciated!

Here is my current code:

Code:
 
Sub SendDocumentInMail()
Dim bStarted As Boolean
Dim oOutlookApp As Outlook.Application
Dim oItem As Outlook.MailItem
On Error Resume Next
'Get Outlook if it's running
 Set oOutlookApp = GetObject(, "Outlook.Application")
If Err <> 0 Then
    'Outlook wasn't running, start it from code
    Set oOutlookApp = CreateObject("Outlook.Application")
     bStarted = True
 End If
'Create a new mailitem
 Set oItem = oOutlookApp.CreateItem(olMailItem)
With oItem
     'Set the recipient for the new email
   .To = "IDS-Omaha-LeadNurseReport@xxxxx.com"
     'Set the recipient for a copy
    .Subject = "Lead Nurse Report"
     'The content of the document is used as the body for the email
    .Body = ActiveDocument.Content
     .Send
 End With
If bStarted Then
     'If we started Outlook from code, then close it
    oOutlookApp.Quit
End If
'Clean up
 Set oItem = Nothing
Set oOutlookApp = Nothing
End Sub
Reply With Quote