bonjour à toutes et à tous,
malgré les exemples, je ne parviens pas à envoyer du html
contenant des images, par mail.
pouvez-vous m'aider ?
initialisation :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
 
private void Form1_Load( object sender, EventArgs e )	{	
	webBrowser1.DocumentText=
		"<html>"+
		"	<body>"+
		"		texte début<br />"+
		"		<img src='D:/Mes documents/...' />"+	// exemple
		"		<img src='D:/Mes documents/...' />"+	 
		"		<br />texte fin"+
		"	</body>"+
		"</html>";
}
lancement :
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
 
private void button1_Click( object sender, EventArgs e )	{
	button1.BackColor=Color.Coral;
	MailMessage mail=new MailMessage();
	mail.BodyEncoding=Encoding.GetEncoding("UTF-8");
	mail.HeadersEncoding=Encoding.GetEncoding("UTF-8");
	mail.SubjectEncoding=Encoding.GetEncoding("UTF-8");
	mail.From=new MailAddress( "a.b@free.fr" );		// mal bidon
	mail.To.Add( "a.b@free.fr" );
	mail.Subject="Sujet";
	mail.IsBodyHtml=true;
	SmtpClient smtp=new SmtpClient( "smtp.free.fr" );
	smtp.Port=int.Parse( "25" );
	HtmlDocument wTmp=webBrowser1.Document;
	int max=wTmp.GetElementsByTagName("IMG").Count;
	String nomImg;
	for ( int numImg=0; numImg<max; numImg ++ )
	{	AlternateView htmlView=
			AlternateView.CreateAlternateViewFromString
				(	"<img src='cid:img"+numImg.ToString()+"'>", 
					null,
					"text/html"
				);
		nomImg=wTmp.GetElementsByTagName("IMG")[numImg].
				GetAttribute("SRC").Replace("file:///","");
		nomImg=nomImg.Replace("%20"," ");	// sinon plante
		wTmp.GetElementsByTagName("IMG")[numImg].SetAttribute
				( "SRC", "cid:img"+numImg.ToString() );
		LinkedResource lrimage = new LinkedResource(nomImg);
		lrimage.ContentId = "img"+numImg.ToString();
		htmlView.LinkedResources.Add(lrimage);
		mail.AlternateViews.Add(htmlView);
	}
	AlternateView plainView =
			AlternateView.CreateAlternateViewFromString	
				(wTmp.Body.InnerHtml, Encoding.UTF8, "text/plain");
	mail.AlternateViews.Add(plainView);
	mail.Body=wTmp.Body.InnerHtml;
	smtp.Send( mail );
	button1.BackColor=Color.Aqua;
}
les images ne s'affichent pas, et le mail est "en texte"
je me plante où ?

merci d'avance.