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

📄 sendmail.cs

📁 一个办公管理系统完整版
💻 CS
字号:
using System;
using System.Data;
using System.Data.SqlClient;
using System.Web.Mail;

namespace OfficeSys.Class
{
	/// <summary>
	/// SendMail 的摘要说明。
	/// </summary>
	public class SendMail
	{   
		string user=null;
		string password=null;
		public SendMail()
		{
			//
			// TODO: 在此处添加构造函数逻辑
			//
			string  strSql="select * from 系邮箱 ";
			DataProcess  dataProcess=new DataProcess( );
			SqlDataReader reader=dataProcess.ExecuteReader(strSql);
			while(reader.Read( ))
			{
				user=reader.GetString(0).Trim( );				
				password=reader.GetString(1).Trim( );
			    
			}
			
		}

		public void  sendMail(string MailAddress,string Title,string Textarea)
		{
			//产生发送邮件类的对象
			MailMessage mail = new MailMessage(); 
			//设置邮件显示类型
			mail.BodyFormat=MailFormat.Html;
			//发送对象的邮箱地址
			mail.To=MailAddress;
			mail.From =user;	
			mail.Subject =Title;
			mail.Body =Textarea;
			mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //basic authentication 
			mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", user); //你的邮箱用户名
			mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", password); //你的邮箱密码
			SmtpMail.SmtpServer ="smtp.163.com"; //设置邮件发送服务器
			SmtpMail.Send(mail);
			

		}
		public void  sendMailP(string MailAddress,string Title,string Textarea,string path)
		{
			//产生发送邮件类的对象
			MailMessage mail = new MailMessage(); 
			//设置邮件显示类型
			mail.BodyFormat=MailFormat.Html;
			//发送对象的邮箱地址
			mail.To=MailAddress;
			mail.From =user;		
			mail.Subject =Title;
			mail.Body =Textarea;			
			mail.Attachments.Add(new MailAttachment(path));			
		
			mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //basic authentication 
			mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", user); //你的邮箱用户名
			mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", password); //你的邮箱密码
			SmtpMail.SmtpServer ="smtp.163.com"; //设置邮件发送服务器
			SmtpMail.Send(mail);
			

		}
		public void  sendMailPP(string MailAddress,string Title,string Textarea,string path1,string path2)
		{
			//产生发送邮件类的对象
			MailMessage mail = new MailMessage(); 
			//设置邮件显示类型
			mail.BodyFormat=MailFormat.Html;
			//发送对象的邮箱地址
			mail.To=MailAddress;
			mail.From =user;		
			mail.Subject =Title;
			mail.Body =Textarea;
			mail.Attachments.Add(new MailAttachment(path1));
			mail.Attachments.Add(new MailAttachment(path2));
			mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //basic authentication 
			mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", user); //你的邮箱用户名
			mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", password); //你的邮箱密码
			SmtpMail.SmtpServer ="smtp.163.com"; //设置邮件发送服务器
			SmtpMail.Send(mail);		

		}
		
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -