No Attachment send

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
 
M

Michael Bauer

Hi Ilja,

do you get an error? If you use an "On Error Resume Next" statement,
then you won´t get one, of course. Please comment out this line for
testing. I suppose the attachment doesn´t exist for the given path.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top