File Is Not Attaching to Email

cklausen

New Member
Joined
May 21, 2015
Messages
8
I am using Excel & Outlook 2013 and am having difficulty getting a file to attach to an email using a macro in excel. The code I am using is below. The macro creates the email fine, but does not include the attachment in the file. I have checked to make sure the file path is correct and it is.

Any help you can provide is appreciated.


Sub Mail_File_AC()
Dim OutApp As Object
Dim OutMail As Object


Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)


On Error Resume Next
With OutMail
.To = "email@email.com"
.CC = ""
.BCC = ""
.Subject = "Subject Line"
.Body = "Body Message"
.Attachments.Add ("C:\Users\hrc.csv")
.Display
'.Send
End With
On Error GoTo 0


Set OutMail = Nothing
Set OutApp = Nothing
End Sub
 
Try moving the file to an actual users folder instead of the Users root.

I note I cannot create a file by right-clicking in this folder on Win7 and require Administrator privileges to drop docs into it so that's likely your problem.

Comment out the On error line and it might give you an indication of the problem.
 
Last edited:
Upvote 0
Thanks for the reply davenrunt.

I actually have the file stored in a folder on my desktop. I just changed the file name when I posted it since it has some proprietary information in it.
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top