Image dans un mail en VBA sans utiliser Outlook

Résolu/Fermé
Kuartz Messages postés 850 Date d'inscription vendredi 13 février 2015 Statut Membre Dernière intervention 15 février 2019 - 26 juil. 2016 à 17:14
 LEGONZ77 - 1 août 2017 à 13:04
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 Sub



Je 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.

Je précise que j'ai posté ce message sur le forum excel-pratique mais le post est malheureusement resté sans réponse. Peut-être est-ce tout simplement impossible?

Merci d'avance pour votre aide.

Cordialement.
A voir également:

21 réponses

cs_Le Pivert Messages postés 7903 Date d'inscription jeudi 13 septembre 2007 Statut Contributeur Dernière intervention 11 mars 2024 728
21 avril 2017 à 18:13
Chez moi en mettant Img = "Image.jpg" cela fonctionne très bien. Je ne comprends pas que cela ne marche pas chez toi!

Dans le post 3, j'ai cité ce site qui met effectivement derrière la variable Img le chemin entre parenthèse. Il faudrait peut-être approfondir la question

  & "<img src='cid:" & Trim(strFile) & "'" & "width='500' height='200'><br>" _


https://excel-macro.tutorialhorizon.com/excel-vba-send-unique-images-embedded-to-mail-body-with-every-mail-from-ms-outlook-using-excel/
0