我正在尝试发送一封Outlook电子邮件,如下所示,我没有看到任何错误或异常,但是当电子邮件发出时仍然是HTML代码,如下所示?我错过了什么?
public object SendBuildAnnouncementEmail(string softwareProductBuildID)
{
try
{
MailMessage mail = new MailMessage("fromname@yourmail.com", "toname@yourmail.com");
SmtpClient client = new SmtpClient();
client.Port = 25;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = false;
client.Host = "smtphost.company.com";
mail.Subject = "this is a test email.";
//mail.Body = "this is my test email body";
mail.Body = "";
var output = GetBuildAnnounceDetails(softwareProductBuildID);
foreach (var item in output)
{
mail.Body += "<html>";
mail.Body += "<p>" + item.SP + "</p>";
mail.Body += "<p>" + item.CreatedDate + "</p>";
mail.Body += "<p>" + item.AnnouncedDate + "</p>";
mail.Body += "<p>" + item.AnnouncedBy + "</p>";
mail.Body += "</html>";
}
//client.Send(mail);
client.Send(mail);
}
catch
{
throw;
}
return null;
}
HTML代码: -
<html><p>spname</p><p>4/8/2017 5:24:37 PM</p><p>4/8/2017 5:43:34 PM</p><p>name</p></html>
答案 0 :(得分:1)
要发送HTML格式的电子邮件,请添加
// you can do this like this
<?php while ( have_posts() ) : the_post(); ?>
<div class="col-sm-12">
<h1><?php the_title() ?><h1>
</div>
<div class="col-sm-8">
<?php the_content() ?>
</div>
<?php endwhile; ?>
代码。 (在mail.IsBodyHtml = true;
之前)