Home Excel Powerpoint Word Outlook Error Codes

VBA Useful Codes

Welcome to the World of VBA
Home > VBAUsefulCodes

Send Mail in Outlook with Attachments from Excel VBA

If you ever wanted to automate the task of sending emails with attachments, then this is the code for you. This code will automatically add attachments to the emails along with the body content.

Sub add_Attachment_to_email()
Dim strLocation As String

Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)

strLocation = "C:\Users\welcome\Desktop\ap.txt" ' Specify your own file name with path

With OutMail
.To = ""
.CC = ""
.BCC = ""
.Subject = "Mail with Attachments" ' Specify your Subject line
.Body = "Check More Codes in VBA Useful Codes Android App!" ' Specify your body text
.Attachments.Add (strLocation)
End With

On Error GoTo 0

Set OutMail = Nothing
Set OutApp = Nothing

With Application
.ScreenUpdating = True
.EnableEvents = True
End With

End Sub


Enter your e-mail below and get notified on the latest blog posts.


VBA Outlook KPI Excel Alt+F11 Dashboards Macros Recording Graphs Automation Developer WaterFall Powerpoint Charts Pivot Tables Forecast Charts

Follow Us