发送邮件程序,大家来帮忙。
private int SendMail(string Tomail)
{
MailMessage myMail = new MailMessage();
myMail.From = "fmtvlive@126.com ";
myMail.To = Tomail;
myMail.Subject = "1111111 ";
myMail.Priority = MailPriority.High;
myMail.BodyFormat = MailFormat.Text;
myMail.Body = "测试!!! ";
myMail.Fields.Add( "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate ", "1 ");
myMail.Fields.Add( "http://schemas.microsoft.com/cdo/configuration/sendusername ", "fmtvlive ");
myMail.Fields.Add( "http://schemas.microsoft.com/cdo/configuration/sendpassword ", "fmtv2007 ");
SmtpMail.SmtpServer = "smtp.126.com ";
try
{
SmtpMail.Send(myMail);
}
catch
{
return 0;
}
return 1;
}
------解决方案--------------------SmtpMail.SmtpServer = "smtp.126.com ";
改成:
SmtpMail.SmtpServer= "IP地址 ";
不敢确定,试试吧
------解决方案--------------------public bool SendMail(string Accept_Mail_Add,string Send_Mail_Add, string mail_title, string mail_doby)
{
MailMessage myMail = new MailMessage(Send_Mail_Add ,Accept_Mail_Add );
myMail.Subject = mail_title;
myMail.Body = mail_doby;
myMail.IsBodyHtml = true;
//设置SMTP
SmtpClient client = new SmtpClient();
client.Host = "smtp.126.com ";
client.Port = 25;
client.Credentials = new System.Net.NetworkCredential( "郵件地址 ", "密碼 ");
client.Send(myMail);
return true;
}
------解决方案--------------------MailMessage mail = new MailMessage();
SmtpClient smtp = new SmtpClient();
MailAddress address1 = new MailAddress( "你的邮箱地址 ");
mail.To.Add( "别人的邮箱地 ");
mail.From = address1