Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2006

    Unanswered: Send email with attachment


    I have a report titled “Monthly ABC Report”

    I use the following code to send out the email.
    How do I attached the “Monthly ABC Report” to my code below so that it will attach when I send out this email and change it to a PDF?

    Option Compare Database
    Sub Mail_Outlook_With_Signature_Html_1()
    ' Working in Office 2000-2013
        Dim OutApp As Object
        Dim OutMail As Object
        Dim strbody As String
        Set OutApp = CreateObject("Outlook.Application")
        Set OutMail = OutApp.CreateItem(0)
        strbody = "Please find attached last month's Regions Monthly Report along with #ACCNTS and #GUARS.<br>" & _
                  "<br><br>" & _
                  "Regions Monthly Presumptive #ACCNTS Export.<br>" & _
                  "Regions Monthly Presumptive #GUARS Export.<br>" & _
                  "<br><br>" & _
                  "Thank you<br>"
    On Error Resume Next
        With OutMail
            .To = "
            .CC = "
            .BCC = ""
            .Subject = "Regions Monthly Report"
            .HTMLBody = strbody & "<br>" & .HTMLBody
        End With
        On Error GoTo 0
        Set OutMail = Nothing
        Set OutApp = Nothing
    End Sub

  2. #2
    Join Date
    Jan 2009
    United Kingdom
    Have you considered sending the email via Powershell . It would require that you trigger the Powershell from within the VBA code - for example :
    runSendEmail = Shell("Powershell.exe -executionpolicy bypass C:\Progra~1\powerhsell\MyEmailScript.ps1")

    It will give you loads of flexibility as other applications could also send email using the same script. You'd need to pass parameters into the script . This post has a sample script on sending email through powershell with an attachment :

    In your case you'd need to adjust for input parameters

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts