请教一个利用OpenSmtp发邮件的问题
最近我用OpenSmtp做了一个发邮件程序,该邮件的客户端都是用outlook2003,但是很奇怪,一部分用户会显示正常,一部分用户会显示乱码,这是什么原因?下面是乱码:
To: <PCITYDS@gnpjvc.com.cn>;
CC: <PCITYDS@gnpjvc.com.cn>;
Subject: =?gb2312?Q?=a1=be=ce=c4=bc=fe=b4=ab=cb=cd=a1=bf=a3=ba(=b3=cc=d0=f2)=b9=ab=cb=be=ce=e5=c4=ea=b7=a2=d5=b9=bc=c6=bb=ae WD-0420-101-I?=
Date: Fri, 27 Mar 2009 03:04:34 GMT
X-Mailer: OpenSmtp.net
MIME-Version: 1.0
Content-Type: text/html;
charset="gb2312"
Content-Transfer-Encoding: quoted-printable
Return-Path: pcismsg@gnpjvc.com.cn
Message-ID: <DNMC-MAIL04oOWGMhLP00000928@DNMC-MAIL34.gnpjvc.cgnpc.com.cn>
X-OriginalArrivalTime: 27 Mar 2009 03:04:34.0667 (UTC) FILETIME=[C1C813B0:01C9AE88]
test
下面是我的发邮件代码:
public Boolean SendLocalEmail1(string sTo,string sTitle,string sHtmlBody,string sCC,bool isbCC)
{
bool IsOk=true;
//邮件服务参数
string mailServer=System.Configuration.ConfigurationSettings.AppSettings["MailServer"];
string mailUser=System.Configuration .ConfigurationSettings.AppSettings["WebMasterEMailUID"];
string mailPassword=System.Configuration.ConfigurationSettings.AppSettings["WebMasterEMailPWD"];
string SendFrom=(string)System.Configuration.ConfigurationSettings .AppSettings["WebMasterEMail"];
string smtpHost =mailServer;
string suffix ="@gnpjvc.com.cn";
int smtpPort =25;
string mailFrom =mailUser+suffix;
string mailAcct =mailUser;
string mailPwd =mailPassword;
// //得到收件人、抄送人
string[] arrTo = sTo.Trim(';').Split(';');
string[] arrCC = sCC.Trim(';').Split(';');
//构造并发送邮件
try
{
//初始化邮件服务的一个实例
Smtp smtp = new Smtp(smtpHost,mailAcct,mailPwd,smtpPort);
//构造邮件
MailMessage mail = new MailMessage();
mail.Charset = "gb2312";
mail.Subject = sTitle.Trim();
mail.HtmlBody = sHtmlBody.Trim();
//mail.From = new EmailAddress(mailFrom,"");
mail.From=new EmailAddress(SendFrom,"");
for(int i=0;i<arrTo.Length;i++)
{
if(arrTo[i] != "")
// 发送
if (isbCC)
mail.AddRecipient(arrTo[i] + suffix,AddressType.Bcc);
else
mail.AddRecipient(arrTo[i] + suffix,AddressType.To);
}
for(int i=0;i<arrCC.Length;i++)
{
if(arrCC[i] != "")
mail.AddRecipient(arrCC[i] + suffix,AddressType.Cc);
}
//发送邮件
smtp.SendMail(mail);
IsOk=true;
}
catch(System.Exception e)
{
IsOk=false;
throw e;
}
return IsOk;
}
}
补充:.NET技术 , ASP.NET