Forum Discussion

Logaraj Sekar's avatar
Logaraj Sekar
Iron Contributor
Oct 31, 2021
Solved

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?
  • HansVogelaar's avatar
    HansVogelaar
    Oct 31, 2021

    Logaraj Sekar 

    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

Resources