⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mail.cs

📁 网上购物系统源代码加毕业设计论文
💻 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 + -