邮件发不出去,急,大家帮忙呀。
public static void StartSendMail(string mailto,string mailFrom,string subject,string mailBody)
{
MailMessage objMessage=new MailMessage();
//objMessage.To=mailto+ " < "+mailtoAddress+ "> ";
objMessage.To=mailto;
objMessage.From=mailFrom+ " <hr@sohu.com> ";
objMessage.Subject=subject;
objMessage.BodyFormat=MailFormat.Html;
objMessage.BodyEncoding=Encoding.GetEncoding( "GB2312 ");
objMessage.Body=mailBody;
objMessage.Fields.Add( "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate ", 1);
objMessage.Fields.Add( " http://schemas.microsoft.com/cdo/configuration/sendusername ", "hr ");
objMessage.Fields.Add( "http://schemas.microsoft.com/cdo/configuration/sendpassword ", "hr ");
SmtpMail.SmtpServer = "mail.sohu.com ";
SmtpMail.Send(objMessage);
}
------解决方案--------------------服务器。。端口