loop through list of email addresses

pikepro92

New Member
Joined
Feb 14, 2019
Messages
10
hi folks,

Ive got which loops through a table of emial addresses and creates individual emails to each person in the list. What i want to do is take each email address and use it to lookup rows in another table/sheet and include those rows in the email body or as an attachment.

This is the code I have atm.

Sub SendEm()
Dim i As Integer, Mail_Object, Email_Subject, o As Variant, lr As Long
lr = Cells(Rows.Count, "F").End(xlUp).Row
Set Mail_Object = CreateObject("Outlook.Application")
For i = 38 To lr
With Mail_Object.CreateItem(o)
.Subject = Range("J1").Value
.To = Range("C" & i).Value
.CC = Range("F" & i).Value
.Body = Range("D" & i).Value & "," & vbNewLine & vbNewLine & Range("I1").Value

.display

End With
Next i
MsgBox "E-mail successfully sent", 64
Application.DisplayAlerts = False
Set Mail_Object = Nothing
End Sub
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.

daverunt

Well-known Member
Joined
Jul 9, 2009
Messages
1,893
Office Version
  1. 2013
Platform
  1. Windows
You haven't specified how you determine which rows on the other sheet are applicable.

I've just done something similar here for a list of names that also appear in the table on the other sheet, that you may be able to adapt. It sends the rows in the mail body.
You can download the file to take a look.

 

Watch MrExcel Video

Forum statistics

Threads
1,130,174
Messages
5,640,590
Members
417,152
Latest member
DayTimeSeby

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
Top