Forum Discussion
Logaraj Sekar
Oct 31, 2021Iron Contributor
Is that possible to add attachment in hyperlink formula?
=HYPERLINK("mailto:"&G2&"?subject=Test Mail"&"&body=This is Test Mail","Send Emails") I want add attachment. Is that possible?
- Oct 31, 2021
You can send any open workbook as attachment using the SendMail method of the Workbook object, for example:
Sub SendActiveWorkbook() ActiveWorkbook.SendMail Recipients:="emailaddress", Subject:="Monthly Report" End Sub
If you want to add other files, you can use Automation to send a message using Outlook. For example:
Sub SendWithAttachment() Dim objOL As Object Dim objMail As Object Set objOL = CreateObject("Outlook.Application") objOL.Session.Logon Set objMail = objOL.CreateItem(0) With objMail .To = "Someone" .CC = "Another" .Subject = "Monthly Report" .Body = "Please see the attached report" .Attachments.Add "PathAndFilename" ' Use only ONE of the following two lines .Display ' to inspect the message bedore sending it .Send ' to send the message immediately End With End Sub
HansVogelaar
Oct 31, 2021MVP
No, the mailto: protocol does not support adding an attachment.
- Logaraj SekarOct 31, 2021Iron Contributor
Is there any other way to add attachment? (Or) Suggest me any other way to send email with attach.
Using Excel 2016. VBA is Preferred.
- HansVogelaarOct 31, 2021MVP
You can send any open workbook as attachment using the SendMail method of the Workbook object, for example:
Sub SendActiveWorkbook() ActiveWorkbook.SendMail Recipients:="emailaddress", Subject:="Monthly Report" End Sub
If you want to add other files, you can use Automation to send a message using Outlook. For example:
Sub SendWithAttachment() Dim objOL As Object Dim objMail As Object Set objOL = CreateObject("Outlook.Application") objOL.Session.Logon Set objMail = objOL.CreateItem(0) With objMail .To = "Someone" .CC = "Another" .Subject = "Monthly Report" .Body = "Please see the attached report" .Attachments.Add "PathAndFilename" ' Use only ONE of the following two lines .Display ' to inspect the message bedore sending it .Send ' to send the message immediately End With End Sub