Adding attachment to email - Runtime error 438

Jbone697

New Member
Joined
Jun 7, 2018
Messages
15
I have this macro that email's a specific range from an actvive sheet that works perfectly until I try to add an attachment from a file path on my computer and this is where I get the 438 error. What am I doing wrong? Any help is greatly appreciated.

Code:
Sub Email_Test()

MsgBox "Email will be sent to "Blah and Blah Blah"
rspn = MsgBox("Are you sure you want to send the E-mail?", vbYesNo)
If rspn = vbNo Then Exit Sub

Sheets("TestSheet1").Unprotect Password:="123456"
' Range Selection to send
   ActiveSheet.Range("E1:G9").Select
   
' Show the envelope on the ActiveWorkbook.
   ActiveWorkbook.EnvelopeVisible = True
   
'Email Details
   With ActiveSheet.MailEnvelope
      .Introduction = ""
      '.Item.To = "Blah"
      '.Item.CC = "Blah Blah"
      .Item.Subject = "Test1" & Date
      .Attachments.Add ("where my file path goes") '<<<<438 error
      .Item.Send
   End With
   Sheets("TestSheet1").Protect Password:="123456"
End Sub
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Check if the file exists before attaching. e.g.
Code:
Dim fn$
fn="c:\temp\ken.txt"
If Dir(fn)<> "" Then .Attachments.Add(fn)
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,175
Members
453,021
Latest member
Justyna P

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