1.1的pop方式
System.Web.Mail.MailMessage msg=new MailMessage();
msg.BodyEncoding=System.Text.Encoding.GetEncoding("gb2312");
msg.BodyFormat=MailFormat.Text;
msg.From="cbw123_1984@163.com";
msg.Subject="测试程序";
msg.To="cbw123_1984@163.com";
msg.Body="hello,world!";
msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //basic authentication
msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "cbw123_1984"); //set your username here
msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "test"); //set your password here
SmtpMail.SmtpServer = "smtp.163.com";
System.Web.Mail.SmtpMail.Send(msg);
2.0的pop方式
public static void SendSMTPEMail(string strSmtpServer, string strFrom,
string strFromPass, string strto, string strSubject, string strBody)
{
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.UTF8;
message.IsBodyHtml = true;
client.Send(message);
}
接收邮件的列表可参照:
http://www.csharphelp.com/archives2/archive450.html