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

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
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,223,920
Messages
6,175,377
Members
452,638
Latest member
Oluwabukunmi

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