Bonjour,
Cela fait plusieur Jour que j'essaye de trouver la solution mais en vain.
Je veux envoyer un mail HTML avec des image (inline) (cid:...)
Avec des fichiers joint aussi.
Tout se déroule bien, sauf si j'ajoute les fichier joint.
à la récéption de l'email, ils sont invisible et le content-type de l'email est 'multipart/related;...' au lieu de 'multipart/mixed'
Pour tester mon code, il faut que vous le liser sur un webmail comme voila.fr
Car outlook semble resoudre le probleme
Voici mon code
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 var part :TidMessagePart; idText :TidText; att :TidAttachment; begin idMsgSend.Clear; idMsgSend.ContentType := 'multipart/mixed'; idText := TIdText.Create(IdMsgSend.MessageParts); idText.Body.Text := 'Ceci est le Texte simple'; idText.ContentType := 'text/plain'; idText := TIdText.Create(IdMsgSend.MessageParts); idText.Body.Text := '<B><h1>Salut ça va?</h1></b><br><br><img src="cid:a.gif" >' + '<br><h2>Hello</h2><br><img src="cid:b.gif" >'; idText.ContentType := 'text/html'; // image a inline att := TIdAttachment.Create(IdMsgSend.MessageParts, 'a.gif'); att.ContentDisposition :='inline'; att.ContentType := 'image/gif'; att.ContentTransfer := 'base64'; att.ExtraHeaders.Values['content-id'] := 'a.gif'; //image b inline att := TIdAttachment.Create(IdMsgSend.MessageParts, 'b.gif'); att.ContentDisposition :='inline'; att.ContentType := 'image/gif'; att.ContentTransfer := 'base64'; att.ExtraHeaders.Values['content-id'] := 'b.gif'; // un fichier zip joint att := TIdAttachment.Create(IdMsgSend.MessageParts, 'Mail.zip'); att.ContentDisposition :='outline'; idMsgSend.ContentType := 'multipart/mixed;'; // l'envois idMsgSend.From.Text := UserEmail; idMsgSend.Recipients.EMailAddresses := edtTo.Text; { To: header } idMsgSend.Subject := edtSubject.Text; { Subject: header } idMsgSend.Priority := TIdMessagePriority(cboPriority.ItemIndex); { Message Priority } SMTP.Username := SmtpServerUser; SMTP.Password := SmtpServerPassword; SMTP.Host := SmtpServerName; SMTP.Port := SmtpServerPort; SMTP.Connect; try SMTP.Send(IdMsgSend); MessageBoxA(Handle, PChar('ok'), PChar(idMsgSend.ContentType), MB_OK); finally SMTP.Disconnect; end; end;
Partager