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:
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.
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.