#1
|
|||
|
|||
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 |
#2
|
||||
|
||||
Hi AnneN,
Do you get an error message? If so, what does it say and what code line, if any, gets highlighted? Your macro uses early binding. Have you set a reference in Word's vbe to the Microsoft Outlook Object Library?
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Macro to export email to text file on send depending on category | Joe Patrick | Outlook | 0 | 10-19-2012 06:20 PM |
Send e-mail by macro | plamenbv | Excel Programming | 1 | 04-16-2012 05:25 AM |
How to send an email to all contacts I ever send an email to? | JSYdeJong | Outlook | 1 | 11-02-2011 07:22 PM |
Send document as email | pat-ty | Word | 0 | 09-09-2010 10:23 AM |
Can't send email | helpplease | Outlook | 6 | 12-21-2008 06:00 AM |