VBA email .send sends empty email body

Mandark

New Member
Joined
Mar 18, 2014
Messages
43
Hello,

I have a macro in Excel that opens a Word document, copies its content and pastes into an email. When I .display the email, everything is there correctly. If I click the "send" button in Outlook, the email is sent and received correctly.
Now if I use the .send function in VBA, the email is sent and received empty. It might have something to do with WordEditor, because in one of the email boxes, I received automated company footer.

Anyway, here is the important part of the code:

Code:
[INDENT]Set OutApp = CreateObject("Outlook.Application")
Set wd = CreateObject("Word.Application")[/INDENT]
[INDENT]Set doc = wd.documents.Open(doc_path & doc_name)[/INDENT]
[INDENT]doc.Content.Copy[/INDENT]
[INDENT]doc.Close SaveChanges:=wdDoNotSaveChanges[/INDENT]


        On Error Resume Next
        
        With OutMail
            .SentOnBehalfOfName = sender
            .to = recipient
            .CC = ""
            .BCC = ""
            .subject = subject
            Set editor = .GetInspector.WordEditor
            editor.Content.Paste
            If mode = "test" Then
                .Display
                Exit Sub
            Else
                 .Send
            End If
        End With
        
        On Error GoTo 0
        Set OutMail = Nothing
        Set doc = Nothing

I didn't copy everything, since it is working for .display, you can presume, that declarations and other stuff is working.

Does anybody know what could be the reason?

Thanks.
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Upvote 0
I tried the other and it doesn't appear to copy the formatting so stick with annoying.
At least you'll get a glimpse of mail content you shouldn't have sent - right before it is : )
 
Upvote 0

Forum statistics

Threads
1,214,943
Messages
6,122,369
Members
449,080
Latest member
Armadillos

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top