用MailMessage发送邮件,html格式会有乱码?
代码如下,组合好的html也没有问题,但是收下来的邮件隔一段就会有个空格或者有一小段乱码,哪位大虾帮忙看看什么原因?谢谢
public static bool SendMail(string p_strSubject,string p_strMsg,string p_strReceiver,string p_strSender,string p_strType)
{
try
{
if(Server==null||Server=="")
InitMailSender();
MailMessage msg=new MailMessage();
msg.Subject=p_strSubject;
msg.From=p_strSender;
msg.To=p_strReceiver;
if(p_strType=="html")
msg.BodyFormat=MailFormat.Html;
else
msg.BodyFormat=MailFormat.Text;
msg.Body=p_strMsg;
msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusing", "2");
msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserver", Server);
msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", ServerPort);
msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", Account);
msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", Password);
SmtpMail.Send(msg);
return true;
}
catch
{
return false;
}
}