mail.cs
来自「网上购物系统源代码加毕业设计论文」· CS 代码 · 共 45 行
CS
45 行
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 + =
减小字号Ctrl + -
显示快捷键?