floggingmolly
Board Regular
- Joined
- Sep 14, 2019
- Messages
- 167
- Office Version
- 365
- Platform
- 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"))