Adding an attachment to existing email

J

jason

I have a code that generates an email and fills in the subject/body. But
when I try and have it add an attachment, it generates 2 emails. Here is
what I have, how and where do I put the code to add a file as an attachment

Sub Macro1()



Dim olApp As Outlook.Application

Dim olMsg As Outlook.MailItem



Set olApp = Outlook.Application

Set olMsg = olApp.CreateItem(olMailItem)



With olMsg



.Subject = "Hello world"

.Display

.Body = "Hello, here is my email!" & .Body

End With



Set olMsg = Nothing

Set olApp = Nothing

End Sub
 
K

Ken Slovak - [MVP - Outlook]

With olMsg



.Subject = "Hello world"

.Display

.Body = "Hello, here is my email!" & .Body

.Attachments.Add filePath 'filePath is the path and file name of the
attachment

End With
 
J

jason

Thanks so much worked great

Ken Slovak - said:
With olMsg



.Subject = "Hello world"

.Display

.Body = "Hello, here is my email!" & .Body

.Attachments.Add filePath 'filePath is the path and file name of the
attachment

End With
 

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

Similar Threads


Top