1

在我的邮箱中显示我的电子邮件时,我遇到了一个有趣的问题。当我通过主机发送电子邮件时,它成功发送给我的用户,但在我的电子邮件文本的某些部分中,我想转到下一行,我使用
标签来做到这一点。奇怪的是,在某些邮箱中它会转到下一行,而在其他一些邮箱中则不会!例如正确的形式是:

Dear Dr smith:
nice....

thank you very much

但它显示如下:

Dear Dr smith: nice.... thank you very much

这是我的代码:

MailMessage msg = new MailMessage();
StringBuilder bodyMsg = new StringBuilder();
msg.Subject = "Submission Confirmation";

bodyMsg.Append("<html><head><img src=" + "http://javahery21.ir/images/header.jpg" + ">" + "<title>CONFIRMATION EMAIL:</title></head><body>");
bodyMsg.Append("<br/>");
string link = string.Format("http://javahery21.ir/Activate.aspx?userID={0}", userID.ToString());
bodyMsg.Append("Dear " + RadioButtonList_Prefix.SelectedItem.Text + " " + name.Text + " " + middle.Text + " " + lastname.Text + ":<br/> Thank you for registering with Publishing manuscript submission system.");
bodyMsg.Append("To confirm and complete your registration<p>" + " <a href=" + link + ">" + "fallow this link" + "</a></p>.");
//bodyMsg.Append("<br/><br/>");

bodyMsg.Append("<br/>This link is active for 48 hours. If the link is not visited within this time frame, your registration will be discarded and you will need to register again.<br/><br/></br>Best regards,</br>Publishing<br/>http://***.com");

msg.IsBodyHtml = true;
msg.Body = bodyMsg.ToString();

msg.BodyEncoding = System.Text.Encoding.GetEncoding("utf-8");
msg.Priority = MailPriority.High;

//  msg.ReplyTo = new MailAddress(TextBox2.Text);
msg.From = new MailAddress("***@***.**");
msg.To.Add(new MailAddress(TextBox_email.Text));
SmtpClient mailsender = new SmtpClient();

mailsender.Host = "SmtpClient.***.**";

mailsender.Port = 587;
mailsender.EnableSsl = true;
mailsender.Credentials = new System.Net.NetworkCredential("****@***.**", "classaspnet");

SmtpClient smtp = new SmtpClient();
//Literal1.Text = "<script>alert(' ')</script>";
smtp.Send(msg);

我在哪里做错了?有谁能够帮助我?

4

2 回答 2

0

尝试使用<p>标签。

例如。

<p>Dear Dr smith:</p>
<p>nice....</p>
<br/>
<p>thank you very much</p>
于 2013-01-03T07:08:59.993 回答
0

你错过了这个

String msgText = getHtmlMessageText(...);
msg.setContent(msgText, "text/html");

您没有设置消息的内容类型

于 2013-01-03T07:16:38.673 回答