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

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
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,223,886
Messages
6,175,193
Members
452,616
Latest member
intern444

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