Option Compare Database
Sub send_christmas_greet1()
Dim rs As Recordset
' tbl_clientnames is table name
Set rs = CurrentDb.OpenRecordset("tbl_clientnames", dbOpenDynaset)
Do While Not rs.EOF
Call sending_bday_greetings_method1(rs.Fields![Client Name].Value, rs.Fields![Client Email].Value)
rs.MoveNext
Loop
rs.Close
End Sub
Sub sending_bday_greetings_method1(nm As String, emid As String)
'To know how to set colors to text or align image in center in html Visit below links
' Send image stored in the desktop in the body of email
Dim olApp As Outlook.Application
Dim olMail As MailItem
Dim bdayimage As String
' set objects
Set olApp = New Outlook.Application
Set olMail = olApp.CreateItem(olMailItem)
' path of image
bdayimage = "C:\Documents and Settings\user\Desktop\christmas greetings\christmas2.jpg"
'************************ add image and text
s = "<p> <p align='left'><font size='2' face='arial' color='blue'><i> Dear " & nm & ", </p>" & vbNewLine
s = s & "<p> <p align='CENTER'><font size='3' face='arial' color='red'><i> May joy and happiness snow on you May the bells jingle for you May Santa be extra good to you! Merry Christmas! </p>" & vbNewLine
s = s & "<left><p align='CENTER'><img src=""cid:" & Mid(bdayimage, InStrRev(bdayimage, "\") + 1) & """>" & vbNewLine
s = s & vbNewLine & "<left><p><p align='Left'><font size='3' face='arial' color='blue'><i>Regards<br>" & "Ashish Koul</p>"
' send email
With olMail
.To = emid
.Subject = "Merry Christmas"
.Attachments.Add bdayimage
.HTMLBody = s
.Send 'or use .display
End With
' Release objects
Set olApp = Nothing
Set olMail = Nothing
End Sub