1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| Sub SendEmail(What_adress As String, subject_line As String, mail_body As String)
Dim olApp As Outlook.Application
Set olApp = CreateObject("Outlook.Application")
Dim Mon_pdf As String
Dim olMail As Outlook.MailItem
Set olMail = olApp.CreateItem(olMailItem)
Set ColAttach = Obj.Mail.Attachments
Set oAttach = ColAttach.Add("C:\Image1.jpg")
Set ObjOutlook = New Outlook.Application
olMail.To = What_adress
olMail.Subject = subject_line
olMail.BodyFormat = olFormatHTML
olMail.HTMLBody = mail_body
olMail.HTMLBody = IMG = cid: Image1.jpg
olMail.Attachments.Add ("C:\Doc.PJ.pdf")
olMail.Send
End Sub
__________________________________________________________________________________
Sub SendMassEmail()
row_number = 1
Do
DoEvents
row_number = row_number + 1
Dim mail_body_message As String
Dim full_name As String
Dim promo_code As String
mail_body_message = Feuil1.Range("J2")
full_name = Feuil1.Range("B" & row_number) & " " & Feuil1.Range("C" & row_number)
promo_code = Feuil1.Range("D" & row_number)
mail_body_message = Replace(mail_body_message, "replace_name_here", full_name)
mail_body_message = Replace(mail_body_message, "promo_code_replace", promo_code)
Call SendEmail(Feuil1.Range("A" & row_number), "Doc.PJ", mail_body_message)
Loop Until row_number = "4"
MsgBox "Congratulations, eMailing Completed"
End Sub |
Partager