Bonjour
Dans mon organisation, j'utilise couramment l'envoi de mail via Outlook avec une macro qui copie une plage de cellule, enregistre un fichier en format .jpg, puis l'inclus dans le corps du mail Outlook.
Jusqu'à présent tout fonctionnait, pour l'ensemble des réceptionnaire.
J'ai un problème depuis peu avec certains destinataires or de mon entreprise qui reçoivent le mail mais sans l'image dans le corps ni en PJ.
J'ai chercher par tou dans les paramètre Outlook ,chez moi et chez mes destinataires, sans trouver pourquoi l'image n'est pas dedans le message.
Si dès fois vous avez une idée, je veux envoyer une image dans le message mais pas en pj.
un extrait de mon code :
....
Dim Img As String, Plage As Range, PathTmp As String
'PathTmp = Environ$("temp") & ""
PathTmp = Environ$("temp") & "\"
Img = "Image.jpg"
If Dir(PathTmp & Img) <> "" Then Kill PathTmp & Img
Set Plage = Range("E2:Y104")
'Création d'un fichier image dans le répertoire temporaire
Plage.CopyPicture
With ActiveSheet.ChartObjects.Add(0, 0, Plage.Width, Plage.Height)
.Activate
.Chart.Paste
.Chart.Export PathTmp & Img, "JPG"
End With
ActiveSheet.ChartObjects(ActiveSheet.ChartObjects.Count).Delete
Set OutApp = CreateObject("outlook.application")
Set OutMail = OutApp.CreateItem(olMailItem)
With OutMail
.SentOnBehalfOfName = "papamaman@moi.fr"
.To = Worksheets("Mail").Range("B3")
.CC = Worksheets("Mail").Range("B4")
.Subject = Worksheets("Mail").Range("B6")
.Attachments.Add PathTmp & Img, olByValue, 0
.HTMLBody = "<span LANG=FR><p class=style2>" _
& "<font FACE=Calibri SIZE=3>Bonjour,<br><br>" _
& "<img src='cid:" & Img & "'</font></span>"
'===================================================================
.Send
'.Display
'===================================================================
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
Dans mon organisation, j'utilise couramment l'envoi de mail via Outlook avec une macro qui copie une plage de cellule, enregistre un fichier en format .jpg, puis l'inclus dans le corps du mail Outlook.
Jusqu'à présent tout fonctionnait, pour l'ensemble des réceptionnaire.
J'ai un problème depuis peu avec certains destinataires or de mon entreprise qui reçoivent le mail mais sans l'image dans le corps ni en PJ.
J'ai chercher par tou dans les paramètre Outlook ,chez moi et chez mes destinataires, sans trouver pourquoi l'image n'est pas dedans le message.
Si dès fois vous avez une idée, je veux envoyer une image dans le message mais pas en pj.
un extrait de mon code :
....
Dim Img As String, Plage As Range, PathTmp As String
'PathTmp = Environ$("temp") & ""
PathTmp = Environ$("temp") & "\"
Img = "Image.jpg"
If Dir(PathTmp & Img) <> "" Then Kill PathTmp & Img
Set Plage = Range("E2:Y104")
'Création d'un fichier image dans le répertoire temporaire
Plage.CopyPicture
With ActiveSheet.ChartObjects.Add(0, 0, Plage.Width, Plage.Height)
.Activate
.Chart.Paste
.Chart.Export PathTmp & Img, "JPG"
End With
ActiveSheet.ChartObjects(ActiveSheet.ChartObjects.Count).Delete
Set OutApp = CreateObject("outlook.application")
Set OutMail = OutApp.CreateItem(olMailItem)
With OutMail
.SentOnBehalfOfName = "papamaman@moi.fr"
.To = Worksheets("Mail").Range("B3")
.CC = Worksheets("Mail").Range("B4")
.Subject = Worksheets("Mail").Range("B6")
.Attachments.Add PathTmp & Img, olByValue, 0
.HTMLBody = "<span LANG=FR><p class=style2>" _
& "<font FACE=Calibri SIZE=3>Bonjour,<br><br>" _
& "<img src='cid:" & Img & "'</font></span>"
'===================================================================
.Send
'.Display
'===================================================================
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing