如何在asp.net中发送包含图像的电子邮件?

时间:2013-07-22 04:02:43

标签: asp.net html-email

我正在尝试使用图片发送简报,我能够发送电子邮件但没有获取图像,我试图搜索大量解决方案,但它不起作用。请检查此链接Simple Newsletter

当我尝试通过电子邮件发送此简报时,我收到的是没有图片的简报。我把硬编码的图像放在html文件中,比如<img src=http://www.abc.com/images/xyz.jpg /> 这是我发送电子邮件的简单代码:

MailMessage myMail;

    using (StreamReader reader = File.OpenText(Server.MapPath("Newsletter.html"))) // Path to your 
    {                                                         // HTML file
        myMail = new MailMessage();
        myMail.From = new MailAddress("email@domain.com.au");
        myMail.Subject = "Test News Letter";
        myMail.To.Add("se@yahoo.com.au");
        myMail.IsBodyHtml = true;

        myMail.Body = reader.ReadToEnd();  // Load the content from your file...

    }
    SmtpClient smtp = new SmtpClient("xx.xx.xx.y", 25);
    smtp.UseDefaultCredentials = true;

    NetworkCredential cred = new NetworkCredential("email@domain.com.au", "hakoo");
    smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
    smtp.Credentials = cred;
    smtp.Send(myMail);

有人可以帮我解决这个问题吗?

谢谢,

Hakoo Desai。

0 个答案:

没有答案