Hi. I've been trying to set up a simple table to use to send mass emails and must be doing something wrong. The code is not mine but believe it works; I have done something to cause it to not work. I've tired several solutions and think Ron De Bruin's is probably the most straight-forward so was hoping to use that. In short, I have several fields, but the key fields are in columns E (email address) and F (Yes/No). The Yes/No option is to select which email addresses I send to.
Following is the code I tried.
>>> use code - tags <<<
Thank you for your consideration and assistance.
Following is the code I tried.
>>> use code - tags <<<
Code:
Sub Test1()
'For Tips see: rondebruin.nl....
'Working in Office 2000-2016
Dim outApp As Object
Dim outMail As Object
Dim cell As Range
Application.ScreenUpdating = False
Set outApp = CreateObject("Outlook.Application")
On Error GoTo cleanup
For Each cell In Columns("E").Cells.SpecialCells(xlCellTypeConstants)
If cell.Value Like "?*@?*.?*" And _
LCase(Cells(cell.Row, "F").Value) = "Y" Then
Set outMail = outApp.CreateItem(0)
On Error Resume Next
With outMail
.To = cell.Value
.Subject = "Reminder"
.Body = "Dear " & Cells(cell.Row, "A").Value _
& vbNewLine & vbNewLine & _
"Please contact us to discuss bringing " & _
"your account up to date"
.Send 'Or use Display
End With
On Error GoTo 0
Set outMail = Nothing
End If
Next cell
cleanup:
Set outApp = Nothing
Application.ScreenUpdating = True
End Sub
Thank you for your consideration and assistance.
Last edited by a moderator: