Created
February 9, 2022 12:32
-
-
Save adrielAd/7e13b968c69170101d1799ba0dc1426e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub EmailAll() | |
Dim oApp As Object | |
Dim oMail As Object | |
Dim SendToName As String | |
Dim theSubject As String | |
Dim theBody As String | |
For Each c In Selection 'loop through (manually) selected records | |
'''For each row in selection, collect the key parts of | |
'''the email message from the Table | |
SendToName = Range("C" & c.Row) | |
theSubject = Range("H" & c.Row) | |
theBody = Range("I" & c.Row) | |
'''Compose emails for each selected record | |
'''Set object variables. | |
Set oApp = CreateObject("Outlook.Application") | |
Set oMail = oApp.CreateItem(0) | |
'''Compose the customized message | |
With oMail | |
.To = SendToName | |
.Subject = theSubject | |
.Body = theBody | |
''' If you want to send emails automatically, use the Send option. | |
''' If you want to generate draft emails and review before sending, use the Display option. | |
''' Do not use both! | |
'''To activate your chosen option: Remove the single quote from the beginning of the code line, then | |
'''add the single quote back to the option you didn't choose | |
.Display | |
'.Send | |
End With | |
Next c | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment