Insertion d'images dans un mail
Le forum bonjour
J'ai un code, qui fonctionne très bien, pour insérer une image dans le coprs d'un mail. Malheureusement, lorsque j'essaye d'en mettre une deuxième, cela ne fonctionne pas. J'ai doublé les instructions pour la deuxième, mais il n'y a que la première image qui apparaisse.
Voici le code
Code:
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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
| Set objApp = CreateObject("Outlook.Application")
Set objApp2 = CreateObject("Outlook.Application")
Set l_Msg = objApp.CreateItem(olMailItem)
Set l_Msg2 = objApp2.CreateItem(olMailItem)
Set colAttach = l_Msg.Attachments
Set colAttach2 = l_Msg2.Attachments
If Image_OK = "Oui" Then
Set l_Attach = colAttach.Add("d:\Temp\Fichier.gif")
End If
If Image_OK <> "Oui" Then
Set l_Attach = colAttach.Add(" ")
End If
l_Attach2 = colAttach2.Add("V:\DPDI\GFL\SCG-CHQ\PEXTRAIT\BASES EXCEL\BASE INCIDENTS\icone SG.jpg")
l_Msg.Close olSave
l_Msg2.Close olSave
strEntryID = l_Msg.EntryID
strEntryID2 = l_Msg2.EntryID
Set l_Msg = Nothing
Set l_Msg2 = Nothing
Set colAttach = Nothing
Set colAttach2 = Nothing
Set l_Attach = Nothing
Set l_Attach2 = Nothing
On Error Resume Next
Set oSession = CreateObject("MAPI.Session")
Set oSession2 = CreateObject("MAPI.Session")
oSession.Logon "", "", False, False
oSession2.Logon "", "", False, False
Set oMsg = oSession.GetMessage(strEntryID)
Set oMsg2 = oSession2.GetMessage(strEntryID2)
Set oAttachs = oMsg.Attachments
Set oAttachs2 = oMsg2.Attachments
Set oAttach = oAttachs.Item(1)
Set oAttach2 = oAttachs.Item(1)
Set colFields = oAttach.Fields
Set colFields2 = oAttach2.Fields
Set oField = colFields.Add(CdoPR_ATTACH_MIME_TAG, "image/jpeg")
Set oField2 = colFields2.Add(CdoPR_ATTACH_MIME_TAG, "image/jpeg")
Set oField = colFields.Add(&H3712001E, "myident")
Set oField2 = colFields2.Add(&H3712001E, "myident2")
oMsg.Fields.Add "{0820060000000000C000000000000046}0x8514", 11, True
oMsg2.Fields2.Add "{0820060000000000C000000000000046}0x8514", 11, True
oMsg.Update
oMsg2.Update
Set l_Msg = objApp.GetNamespace("MAPI").GetItemFromID(strEntryID)
Set l_Msg2 = objApp.GetNamespace("MAPI").GetItemFromID(strEntryID2)
strHtml = strHtml & "<IMG align=baseline border=0 hspace=0 src=cid:myident>"
strHtml = strHtml & "<IMG align=baseline border=0 hspace=0 src=cid:myident2>"
etc...
l_Msg.HtmlBody = strHtml
l_Msg.Close (olSave)
l_Msg.display |
Quelqu'un saurait-il d'où peut provenir le problème ?
Merci d'avance.