Mail.cs
资源名称:SHOPASP.rar [点击查看]
上传用户:xiecaij
上传日期:2015-02-08
资源大小:2016k
文件大小:1k
源码类别:
百货/超市行业
开发平台:
ASP/ASPX
- 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;
- }
- }
- }