邮件到Hotmail上的嵌入式图像 [英] Embedded Images on Mails to Hotmail

查看:77
本文介绍了邮件到Hotmail上的嵌入式图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在发送给Hotmail用户的邮件中嵌入图像?
我尝试过此操作(如下),它对Yahoo用户非常有效.
如何为Hotmail用户使用它?

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 ?

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);



谢谢,

Guilherme



Thanks,

Guilherme

推荐答案

我不确定这是否正确,但是您可以将图像嵌入到IMG标签的SRC属性中(即您将实际SRC属性中的图片数据,而不是图片数据的网址).参见此处:数据URI图像提取器.
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.


此是你的问题:

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

您需要告诉hotmail您要嵌入的类型.

这行得通,但是您需要添加一些错误捕获功能:

使用Microsoft.Win32;
RegistryKey键= Registry.ClassesRoot.OpenSubKey(extension);
字符串contentType = key.GetValue("Content Type").ToString();
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();


这篇关于邮件到Hotmail上的嵌入式图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆