Click here to Skip to main content
15,888,113 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
How can I embed Images on messages to Hotmail users ?
I tried this one (below) and it works well for Yahoo users.
How can I do it works for Hotmail users ?
C#
MailMessage MsgTorp = new MailMessage(pOrigem, pDestino, pTitulo, pTexto);
ContentType mimeType = new System.Net.Mime.ContentType("text/html");
AlternateView alternate = AlternateView.CreateAlternateViewFromString(MsgTexto, mimeType);

LinkedResource FotoUser = new LinkedResource(pFoto);
FotoUser.ContentId = "FotoUserTorpedo";
FotoUser.TransferEncoding = TransferEncoding.Base64;
alternate.LinkedResources.Add( FotoUser );

Attachment attach = new Attachment(pFoto);
MsgTorp.Attachments.Add(attach);

MsgTorp.IsBodyHtml = true;
MsgTorp.AlternateViews.Add(alternate);

SmtpClient SmtpCliente = new SmtpClient(); //pServer);
SmtpCliente.Send(MsgTorp);


Thanks,

Guilherme
Posted
Updated 13-Sep-11 7:36am
v2

I am not sure if this is the correct way, but you can embed images in the IMG tag's SRC attribute (i.e., you put the actual image data in the SRC attribute, rather than the URL to the image data). See here: Data URI Image Extractor.
 
Share this answer
 
v2
this is your problem:

ContentType mimeType = new System.Net.Mime.ContentType("text/html");

you need to tell hotmail what type you are embedding.

this works, but you'll need to add some error catching:

using Microsoft.Win32;
RegistryKey key = Registry.ClassesRoot.OpenSubKey(extension);
string contentType = key.GetValue("Content Type").ToString();
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900