I wrote one macro in excel I m send mail via Gmail. I m sending message but I cannot send picture because I cannot paste picture in gmail message body . I put my code. Also I m getting picture from activesheet(Sheet4 according to my excel ). How can I add this picture in my mail message body ?
Sub SendGmail(frommail As String, password As String, tomail As String, subject As String, mesaj As String)
Dim pic As String
pic = CheckImageName
If pic <> "" Then
Sheet4.Shapes(pic).Copy
End If
If frommail <> "" And password <> "" And tomail <> "" And subject <> "" And mesaj <> "" Then
On Error Resume Next
'creating a CDO object
Dim Mail As CDO.message
Set Mail = New CDO.message
'Enable SSL Authentication
Mail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
'Make SMTP authentication Enabled=true (1)
Mail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
'Set the SMTP server and port Details
'Get these details from the Settings Page of your Gmail Account
Mail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = _
"smtp.gmail.com"
Mail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
Mail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'Set your credentials of your Gmail Account
Mail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusername") = _
frommail
Mail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendpassword") = _
password
'Update the configuration fields
Mail.Configuration.Fields.Update
'Set All Email Properties
With Mail
.subject = subject
.From = frommail
.To = tomail
.CC = ""
.BCC = ""
.HTMLBody = mesaj
End With
'to send the mail
Mail.Send
If Err <> 0 Then
'MsgBox "Mail gönderme basarisiz.Eposta Ayarlari sayfasindan mail adresinizi ve sifrenizi kontrol ediniz!!!"
Call MessageBoxTimer("HATA", "Mail gönderme basarisiz.Eposta Ayarlari sayfasindan mail adresinizi ve sifrenizi kontrol ediniz!!!")
Exit Sub
End If
End If
End Sub