This macro will allow the user to send e-mails via MS Outlook. This is especially helpful when you need to send email in bulk (this is an alternative to mail merge (MM), if you wish to learn how to mail merge there are several Youtube videos for it. MM does not require any VBA coding so it might be nice to learn about it too)
SAMPLE FILE:
If you are unable to download the sample file, these are the columns you will need:
FILE PREVIEW:
CODE:
Sub SendEmail()
'Learnwithglezy.com
Line = 2
Dim objOutlook As Object
Dim emlBody, sendTo As String
Dim wkbook As String
Application.ScreenUpdating = False
Do Until Worksheets("Sheet1").Cells(Line, 5).Value = ""
Set objOutlook = CreateObject("Outlook.Application")
Set objMailMessage = objOutlook.CreateItem(0)
' Cells(Line, x) X represents column number
With objMailMessage
.To = Worksheets("Sheet1").Cells(Line, 2).Value
.cc = Worksheets("Sheet1").Cells(Line, 3).Value
' .bcc = Worksheets("Sheet1").Cells(Line, 4).Value 'if you want to add this then you will need to modify the column(s) on attached excel macro sample
.Subject = Worksheets("Sheet1").Cells(Line, 4).Value
.Body = Worksheets("Sheet1").Cells(Line, 5).Value
.Display ' or use .Send to send e-mail directly, otherwise it will prompt as a display before getting sent out
' .Close olPromtForsend
End With
Line = Line + 1
Loop
End Sub
E-MAIL PREVIEW:
Comments