Sub SendEmail(what_address As String, Subject_line As String, mail_body As String)
Dim olApp As Outlook.Application
Set olApp = CreateObject("Outlook.Application")
Dim olMail As Outlook.MailItem
Set olMail = olApp.CreateItem(olMailItem)
olMail.To = what_address
olMail.Subject = Subject_line
olMail.Body = mail_body
olMail.Save
___________________________________________
End Sub
Sub Massemail()
row_number = 1
Do
DoEvents
row_number = row_number + 1
Dim mail_body_message As String
Dim con_number As String
Dim d_libres As String
mail_body_message = Sheet1.Range("F2")
con_number = Sheet1.Range("A" & row_number)
d_libres = Sheet1.Range("B" & row_number)
mail_body_message = Replace(mail_body_message, "cont_num", con_number)
mail_body_message = Replace(mail_body_message, "d_l", d_libres)
Call SendEmail(Sheet1.Range("D" & row_number), "LongStanding Test", mail_body_message)
Loop Until row_number = 13
End Sub
In the line that says "Loop Until row_number = 13" I just put 13 to stop the generation of emails. Please advise anything that can resolve this or stop when it reaches an empty cell. Please see attachment for the screenshot of the excel file.
Test Email1.jpg
Thanks in advance
Bookmarks