![]() |
#1
|
|||
|
|||
![]()
Hello everyone. I am wondering if I can get some help with this code I am using below.
While it currently sends the complete document text to Outlook as a Doc attachement, I would like it to actually send the document contents to the body of the email. Thanks. Sub eMailActiveDocument() Dim OL As Object Dim EmailItem As Object Dim Doc As Document Application.ScreenUpdating = False Set OL = CreateObject("Outlook.Application") Set EmailItem = OL.CreateItem(olMailItem) Set Doc = ActiveDocument Doc.Save Doc.Content.Copy With EmailItem .Subject = "Insert Subject Here" .Body = "Insert message here" & vbCrLf & _ "Line 2" & vbCrLf & _ "Line 3" .To = "User@Domain.Com" .Importance = olImportanceNormal 'Or olImprotanceHigh Or olImprotanceLow .Attachments.Add Doc.FullName .Send End With Application.ScreenUpdating = True Set Doc = Nothing Set OL = Nothing Set EmailItem = Nothing End Sub |
#2
|
|||
|
|||
![]() Code:
Sub eMailActiveDocument() Dim OL As Object Dim EmailItem As Object Dim oEditor As Object Dim Doc As Document Application.ScreenUpdating = False Set OL = CreateObject("Outlook.Application") Set EmailItem = OL.CreateItem(olMailItem) Set Doc = ActiveDocument Doc.Save Doc.Content.Copy With EmailItem .Subject = "Insert Subject Here" .BodyFormat = olFormatRichText Set oEditor = .GetInspector.WordEditor oEditor.Content.Paste .To = "gmaxey@gregmaxey.com" .Importance = olImportanceNormal 'Or olImprotanceHigh Or olImprotanceLow .Display 'Send End With Application.ScreenUpdating = True Set Doc = Nothing Set OL = Nothing Set EmailItem = Nothing End Sub If you want to use "Send" instead "Display" you are probably going to have to insert a delay before killing the Outlook instance. |
#3
|
|||
|
|||
![]()
Hello Greg
Thank you for posting this, it worked perfectly! |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Creating a VBA Code to print then send as an email attachment | bcfd_110 | Word VBA | 1 | 09-04-2022 01:53 PM |
Help to get a word document to send specific content via email using submit button | ActualJax | Word VBA | 2 | 07-06-2020 04:18 PM |
Outlook macro to check a value of a cell in an attachment and send an email based on that value | ketangarg86 | Outlook | 13 | 03-25-2015 07:11 AM |
![]() |
bigbird69 | Word VBA | 13 | 11-18-2012 10:06 PM |
![]() |
gauntlett | Word | 1 | 04-27-2012 09:06 AM |