I
Ilja Zwolsman
Hi,
I am trying to automate sending an e-mail message and an
attachment from vba in excel.
Using the following code the message is put into the
outbox. When I then use the sending option under the tools
menu the message is send but the attachment is not.
I am using windows 98se and officeXp.
set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olMailItem)
Set myRecipient = myItem.Recipients.Add
("(e-mail address removed)")
With myItem
.Display
.Save
Set myAttachments = .Attachments
myAttachments.Add "H:\Expeditie\Xml_Verzonden\" &
SaveName & ".xml", _
olByValue, 1, "Xml bestand voor Maersk"
.Subject = "Shipping Instructions ( " & SaveName
& " ) "
.body = " Dear Sir/Madam, " & vbCrLf & _
" " & vbCrLf & _
" Attached you will find new shipping
instructions." & vbCrLf & _
" " & vbCrLf & _
" Kind regards," & vbCrLf & _
" " & vbCrLf & _
"TCCModexpress B.V. "
.Send
end with
Set myOlApp = Nothing
I am trying to automate sending an e-mail message and an
attachment from vba in excel.
Using the following code the message is put into the
outbox. When I then use the sending option under the tools
menu the message is send but the attachment is not.
I am using windows 98se and officeXp.
set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olMailItem)
Set myRecipient = myItem.Recipients.Add
("(e-mail address removed)")
With myItem
.Display
.Save
Set myAttachments = .Attachments
myAttachments.Add "H:\Expeditie\Xml_Verzonden\" &
SaveName & ".xml", _
olByValue, 1, "Xml bestand voor Maersk"
.Subject = "Shipping Instructions ( " & SaveName
& " ) "
.body = " Dear Sir/Madam, " & vbCrLf & _
" " & vbCrLf & _
" Attached you will find new shipping
instructions." & vbCrLf & _
" " & vbCrLf & _
" Kind regards," & vbCrLf & _
" " & vbCrLf & _
"TCCModexpress B.V. "
.Send
end with
Set myOlApp = Nothing