Adding Attachement

  • Thread starter Thread starter Flannel
  • Start date Start date
F

Flannel

I'm trying to create a macro that I can assign to a button
that would attach a certain file to the e-mail. Here's
what I have:

Dim oApp As Outlook.Application
Dim oItem As Outlook.MailItem

Set oApp = CreateObject("Outlook.Application")
Set oItem = oApp.CreateItem(Outlook.OlItemType.olMailItem)
oItem.Attachments.Add "c:\easy.xls"

After picking the button I get a hourglass for a couple of
seconds, but no attachment (no errors either). Any help
would be apprectiated. Thank you.
 
Try saving the message before you add the attachment and since
Attachments.Add is a function try it like this:

Dim oAttach As Outlook.Attachment

Set oAttach = oItem.Attachments.Add "c:\easy.xls"

Also, in Outlook VBA code you have an intrinsic Application object so you
don't need to create an Outlook.Application object.
 
Back
Top