Run-time error -2147467259 (80004005) Method 'MailEnvelope" of object _Worksheet failed

Qazxswe

New Member
Joined
May 28, 2012
Messages
36
I have some VBA which emails a range of cells, and attaches itself the email and sends.

This first time I run the macro it works fine. If I try to run it again I get the above error. Saving the work book (without closing) "resets" the issue and I can use the macro again; opening/closing has the same positive effect. I cannot see any open processes is process manager.

Any suggestions?

VBA Code:
Option Explicit

Sub Mail()
Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("Mail Form")

sh.Range("B11:J22").Select

With Selection.Parent.MailEnvelope.Item
    .to = "email@gmail.com"
     .Subject = "Subject Line: " & Range("D5").Value
    .Attachments.Add (ThisWorkbook.FullName)
    .send
End With

MsgBox "Your request has been submitted"

End Sub
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.

Forum statistics

Threads
1,214,971
Messages
6,122,517
Members
449,088
Latest member
RandomExceller01

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