VBA to send emails

floggingmolly

Board Regular
Joined
Sep 14, 2019
Messages
167
Office Version
  1. 365
Platform
  1. Windows
I have an Excel sheet with data, and need to send an email to each row in the sheet. I have part of a VBA code for email that I used in another project, but not sure how to make it work to cycle through each row and send an email. Below is a snippet of the code I have so far. Any help would be appreciated.

Code:
Set OutApp = CreateObject("Outlook.Application") 'Create Outlook Application
                                                  Set OutMail = OutApp.CreateItem(0) 'Create Email
                                                  With OutMail
                                                      .bcc = Sheet1.Range("R" & CustRow).Value & ";" & Sheet1.Range("S" & CustRow).Value & ";" & Sheet1.Range("T" & CustRow).Value
                                                      .Subject = "This is the subject line" & Sheet1.Range("F" & CustRow).Value
                                                      .Body = "This is the first line of body." & vbCrLf & _
                                                      "This is the second line of the body." _
                                                      & vbCrLf & "This is the 3rd line of the body" _
                                                      & vbCrLf & vbCrLf & "This is the 4th line of the body" _
                                                      & vbCrLf & "This is the 5th line of the body" _
                                                      & vbCrLf & "This is the 6th line of the body" _
                                                      & vbCrLf & vbCrLf & "Thank you," _
                                                      & vbCrLf & vbCrLf & "John Smith" _
                                                      & vbCrLf & "John Doe"
                                                      
                                                      
                                                     
                                                      .Send 'To send without Displaying change .Display to .Send
                                                      Application.Wait (Now + TimeValue("0:00:5"))
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
I have an Excel sheet with data, and need to send an email to each row in the sheet. I have part of a VBA code for email that I used in another project, but not sure how to make it work to cycle through each row and send an email. Below is a snippet of the code I have so far. Any help would be appreciated.

Code:
Set OutApp = CreateObject("Outlook.Application") 'Create Outlook Application
                                                  Set OutMail = OutApp.CreateItem(0) 'Create Email
                                                  With OutMail
                                                      .bcc = Sheet1.Range("R" & CustRow).Value & ";" & Sheet1.Range("S" & CustRow).Value & ";" & Sheet1.Range("T" & CustRow).Value
                                                      .Subject = "This is the subject line" & Sheet1.Range("F" & CustRow).Value
                                                      .Body = "This is the first line of body." & vbCrLf & _
                                                      "This is the second line of the body." _
                                                      & vbCrLf & "This is the 3rd line of the body" _
                                                      & vbCrLf & vbCrLf & "This is the 4th line of the body" _
                                                      & vbCrLf & "This is the 5th line of the body" _
                                                      & vbCrLf & "This is the 6th line of the body" _
                                                      & vbCrLf & vbCrLf & "Thank you," _
                                                      & vbCrLf & vbCrLf & "John Smith" _
                                                      & vbCrLf & "John Doe"
                                                     
                                                     
                                                    
                                                      .Send 'To send without Displaying change .Display to .Send
                                                      Application.Wait (Now + TimeValue("0:00:5"))
This is resolved. No need to reply. Thank you
 
Upvote 0

Forum statistics

Threads
1,224,828
Messages
6,181,201
Members
453,022
Latest member
RobertV1609

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top