troubleshooting Question

Mail attachment an Excel file in VBA

Avatar of AFGPHXExcel
AFGPHXExcel asked on
OutlookMicrosoft Excel
4 Comments1 Solution326 ViewsLast Modified:
I am trying to attach a file I have saved to the desktop to an Outlook Object. Outlook seems to ignore the file though. Any help would be much appreciated.

v_WksFldrDest = CreateObject("WScript.Shell").SpecialFolders("Desktop") & Application.PathSeparator

EmailAttachDest= v_WksFldrDest & v_TempFileName

            Dim OutApp As Object
            Dim OutMail As Object
            Dim strbody As String
            Set OutApp = CreateObject("Outlook.Application")
            Set OutMail = OutApp.CreateItem(0)
                strbody = Range(ReviewerName & "ReqBy_EmailTxt").Value & vbNewLine & vbNewLine & _
                        "Please reply to: " & Range(ReviewerName & "ReplyTo_Name").Value & _
                            " at " & Range(ReviewerName & "ReplyTo_Email").Value & " and CC to " & Range(ReviewerName & "ReplyCC_Email").Value

            On Error Resume Next
            With OutMail
                .To = Range(GKName & "_GatekeeperEmail").Value
                .CC = Range(ReviewerName & "ReqCC_Email").Value
                .BCC = ""
                .Subject = v_TempFileName
                .Body = strbody
                'You can add a file like this
                .Attachments.Add (EmailAttachDest)
                '.Send or use
            End With
            On Error GoTo 0
            Set OutMail = Nothing
            Set OutApp = Nothing
Arno Koster

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros