Image en PJ d'un mail (Non Outlook)
K
Bonjour,
Avant tout, je ne souhaite pas utiliser Outlook pour la génération des mails.
Voici mon code :
Sub EnvoiMail()
Dim mMessage As Object
Dim mConfig As Object
Dim mChps
Dim NOM_AFFRETEUR_MAIL As String
Dim ADRESSE_MAIL As String
Dim DF As Long
Dim DL_MAIL As Long
Dim DL_GENERAL As Long
'**********************************************************Pramétrage de gmail**********************************************************************************************
Set mConfig = CreateObject("CDO.Configuration")
mConfig.Load -1
Set mChps = mConfig.Fields
With mChps
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = "1"
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "xxxxxxx@gmail.com"
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "xxxxxx"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = "true"
.Update
End With
DL_GENERAL = Sheets(2).Cells(Application.Rows.Count, 10).End(xlUp).Row
For k = 3 To DL_GENERAL
ADRESSE_MAIL = Sheets(2).Range("J" & k)
Set mMessage = CreateObject("CDO.Message")
With mMessage
Set .Configuration = mConfig
.To = ADRESSE_MAIL
.From = "xxxxxxx"
.Subject = "INDEXATIONS GASOIL"
.TextBody = "Vous trouverez en PJ les indexations gasoil pour tous les clients."
.AddAttachment "K:\DEVELOPPEMENTS\TEMP\INDEXATIONS GASOIL GENERALES.pdf"
.send
End With
Set mMessage = Nothing
Next k
Set mConfig = Nothing
Set mChps = Nothing
End SubJe souhaiterais ajouter une image à la fin du mail (une sorte de signature) mais je ne vois pas comment faire avec cette méthode. J'ai trouvé de nombreux renseignements à ce propos sur les divers forum mais par la méthode Outlook.
Merci d'avance pour votre aide.
Cordialement.
Invité
Bonjour Kuartz
Peut-être en créant tout simplement un message HTML et non en texte brut
avec un truc du style (pas testé)
With mMessage
Set .Configuration = mConfig
.To = ADRESSE_MAIL
.From = "xxxxxxx"
.Subject = "INDEXATIONS GASOIL"
'.TextBody = "Vous trouverez en PJ les indexations gasoil pour tous les clients."
.HTMLBody = "Vous trouverez en PJ les indexations gasoil pour tous les clients.<BR>" & _
"<img src="C:\Temp\MonImage.jpg">"
.AddAttachment "K:\DEVELOPPEMENTS\TEMP\INDEXATIONS GASOIL GENERALES.pdf"
.send
End WithA+
K
