public void MailMessage()
{
string str=DateTime.Now.ToString()+":Error! when "+" copying,errorMessage: ";
MailMessage mailMsg = new MailMessage(); //创建MailMessage对象
mailMsg.Body = str; //所要发送的文本
mailMsg.From = "[email protected]"; //发送者的邮箱地址
mailMsg.To = "[email protected]"; //接收者的邮箱地址
mailMsg.BodyFormat = MailFormat.Text; //邮件的格式是文本文件
mailMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate","1"); //设置支持服务器验证
mailMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername",".....");//设置用户名
mailMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword","....."); //设置用户密码
SmtpMail.SmtpServer = "smtp.263xmail.com"; //发送邮件服务器
SmtpMail.Send(mailMsg); //发送邮件
}不知道这个是不是适合你.我以前就是这么用的
{
string str=DateTime.Now.ToString()+":Error! when "+" copying,errorMessage: ";
MailMessage mailMsg = new MailMessage(); //创建MailMessage对象
mailMsg.Body = str; //所要发送的文本
mailMsg.From = "[email protected]"; //发送者的邮箱地址
mailMsg.To = "[email protected]"; //接收者的邮箱地址
mailMsg.BodyFormat = MailFormat.Text; //邮件的格式是文本文件
mailMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate","1"); //设置支持服务器验证
mailMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername",".....");//设置用户名
mailMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword","....."); //设置用户密码
SmtpMail.SmtpServer = "smtp.263xmail.com"; //发送邮件服务器
SmtpMail.Send(mailMsg); //发送邮件
}不知道这个是不是适合你.我以前就是这么用的
我要创造csdn第一自顶贴
我要创造csdn第一自顶贴
我要创造csdn第一自顶贴
http://www.systemnetmail.com/
using System.Data;
using System.Configuration;
using System.Web;
using System.Net;
using System.Net.Mail;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.OracleClient;/// <summary>
/// Email 的摘要说明
/// </summary>
public class Myemail
{
public static int SendSMTPEMail(string strSmtpServer, string strFrom, string strFromPass, string strto, string strSubject, string strBody)
{
try
{ System.Net.Mail.SmtpClient client = new SmtpClient(strSmtpServer);
client.UseDefaultCredentials = false;
client.Credentials = new System.Net.NetworkCredential(strFrom, strFromPass);
client.DeliveryMethod = SmtpDeliveryMethod.Network; System.Net.Mail.MailMessage message = new MailMessage(strFrom, strto, strSubject, strBody); message.BodyEncoding = System.Text.Encoding.UTF7;
message.IsBodyHtml = true; client.Send(message);
return 1;
}
catch (ArgumentOutOfRangeException err) //error code please check the msdn doc.
{
common.ErrorLog(err);
return 2;
}
catch (SmtpFailedRecipientException err)
{
common.ErrorLog(err);
return 3;
}
catch (SmtpException err)
{
common.ErrorLog(err);
return 4;
}
catch (Exception err)
{
common.ErrorLog(err);
return 5;
}
} public static void SendPassword(string strEmail, string userpwd, string strUsername)
{ //测试使用
string strFrom = common.EmailFrom();
string strSmtpServer = common.EmailSmtpServer();
string strFromPass = common.EmailFromPassWod();
string strto = strEmail; string strSubject = "Dear User " + strUsername + ",";
string strBody = "Dear User " + strUsername + "," + "<br />" + " Thanks for using 168EC Self-help Password Service." + "<br />"
+ " Your Registered Member ID:" + strUsername + "<br />" + " Your Random Password:" + userpwd + "<br />"
+ " For enhanced security,we advise you to set your password with numbers and characters together.<br />"+
" Now click http://www.168ec.com/login/login.aspx to log in and reset your password.<br />" +
" Hope you make the most out of your time with 168EC.<br />"+
" Best Regards<br />"
+ " 168EC Help Center";
SendSMTPEMail(strSmtpServer, strFrom, strFromPass, strto, strSubject, strBody);
}
/// <summary>
/// Send Email
/// </summary>
/// <param name="strEmail">To address</param>
/// <param name="strTitle">email title</param>
/// <param name="strContent">content</param>
/// <returns>send status</returns>
public static int SendMail(string strEmail, string strTitle, string strContent)
{ //测试使用
string strFrom = common.EmailFrom();//[email protected]
string strSmtpServer = common.EmailSmtpServer();//smtp.163.com
string strFromPass = common.EmailFromPassWod();//密码
string strto = strEmail; string strSubject = strTitle;
string strBody = strContent;
return SendSMTPEMail(strSmtpServer, strFrom, strFromPass, strto, strSubject, strBody);
}
}