?? mail.cs
字號:
using System;
namespace eshop.BLL
{
/// <summary>
/// Mail 的摘要說明。
/// </summary>
public class Mail
{
public Mail()
{
}
public static void CDOsendmail(string from, string to, string subject,
string body, string userName, string password, string smtpServer)
{
//聲明新的郵件實例
CDO.Message Msg = new CDO.Message();
//分別設置發送人、收信人、主題、內容
Msg.From = from;
Msg.To = to;
Msg.Subject = subject;
Msg.HTMLBody = "<html><body>"+body
+"</body></html>";
//設置發送參數,包括smtpServer,用戶名,密碼
CDO.IConfiguration Config = Msg.Configuration;
ADODB.Fields oFields = Config.Fields;
oFields["http://schemas.microsoft.com/cdo/configuration/sendusing"].Value = 2;
oFields["http://schemas.microsoft.com/cdo/configuration/sendusername"].Value=userName;
oFields["http://schemas.microsoft.com/cdo/configuration/sendpassword"].Value=password;
oFields["http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"].Value=1;
oFields["http://schemas.microsoft.com/cdo/configuration/languagecode"].Value=0x0804;
oFields["http://schemas.microsoft.com/cdo/configuration/smtpserver"].Value=smtpServer;
oFields.Update();
//字符格式
Msg.BodyPart.Charset = "gb2312";
Msg.HTMLBodyPart.Charset = "gb2312";
//發送
Msg.Send();
Msg = null;
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -