关于asp.net中的邮件 [英] Regarding mail in asp.net

查看:51
本文介绍了关于asp.net中的邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家下午好,





i在asp.net中发送aspx页面作为电子邮件正文有问题,

i已经发送了一封来自asp.net的邮件但是我遇到了一个问题,图片没有显示在结果邮件中

所以请给我任何想法得到一个确切的aspx页面作为邮件内容。















提前感谢,

关于

shobana.K

{
MailMessage newMail = new MailMessage();
newMail.To.Add(new MailAddress(you@your.address));
newMail.Subject =测试主题;
newMail.IsBodyHtml = true;

var inlineLogo = new LinkedResource(Server.MapPath(〜/ Path / To / YourImage.png));
inlineLogo.ContentId = Guid.NewGuid()。ToString();

string body = string.Format(@
< p > Lorum Ipsum Blah Blah < / p >
< img src = cid:{0} / >
< p > Lorum Ipsum Blah Blah < / p >
,inlineLogo.ContentId);

var view = AlternateView.CreateAlternateViewFromString(body,null,text / html);
view.LinkedResources.Add(inlineLogo);
newMail.AlternateViews.Add(view);

client.Send(newMail);
}


你好,



你必须传递图像的动态路径物理路径,因为电子邮件在不同的服务器上,你的图像在你的服务器上,所以它没有得到它。



你必须传递完整的图像路径,如http:/ /www.xyz.com/images/home.jpg



试试这个。


good afternoon to all,


i have a problem on sending an aspx page as a e-mail body in asp.net ,
i have sent a mail from asp.net but i got a problem that image are not shown in the resulted mail
so please suggess me with any to idea to get a exact aspx page as a mail content.







thanks in advance,
with regards
shobana.K

解决方案

using (var client = new SmtpClient())
{
    MailMessage newMail = new MailMessage();
    newMail.To.Add(new MailAddress("you@your.address"));
    newMail.Subject = "Test Subject";
    newMail.IsBodyHtml = true;

    var inlineLogo = new LinkedResource(Server.MapPath("~/Path/To/YourImage.png"));
    inlineLogo.ContentId = Guid.NewGuid().ToString();

    string body = string.Format(@"
            <p>Lorum Ipsum Blah Blah</p>
            <img src=""cid:{0}"" />
            <p>Lorum Ipsum Blah Blah</p>
        ", inlineLogo.ContentId);

    var view = AlternateView.CreateAlternateViewFromString(body, null, "text/html");
    view.LinkedResources.Add(inlineLogo);
    newMail.AlternateViews.Add(view);

    client.Send(newMail);
}


Hello,

You have to pass Dynamic path of images not physical path because email is on different server and you images are on your server so it did not get that.

you have to pass full path of images like http://www.xyz.com/images/home.jpg

Try this.


这篇关于关于asp.net中的邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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