sends_mail.cs

来自「Help Desk Pro has three different interf」· CS 代码 · 共 85 行

CS
85 行
字号
using System;
using System.Web.Mail;

namespace Final_Project_Alpha
{
	/// <summary>
	/// Summary description for sends_mail.
	/// </summary>
	public class sends_mail
	{
		public sends_mail()
		{
			//
			// TODO: Add constructor logic here
			//
		}

		public void send_mail(String to,String from,String subject,String body)
		{
			MailMessage MM=new MailMessage();
			
			MM.To=to;
			MM.From=from;
			MM.Subject=subject;
			MM.Body=body;
			//MM.Attachments=attach.Text;
			
			try
			{
				SmtpMail.SmtpServer="202.83.173.53";
				SmtpMail.Send(MM);
			}
			catch(Exception ex)
			{
				Console.Write( ex.Message ) ;
			}

		}

		
		public void send_mail_att(String to,String from,String subject,String body,String att)
		{
			MailMessage MM=new MailMessage();
			if(att == "")

			{
				MM.To=to;
				MM.From=from;
				MM.Subject=subject;
				MM.Body=body;
			}
		
			else
			{

				MM.To=to;
				MM.From=from;
				MM.Subject=subject;
				MM.Body=body;

				MailAttachment MyAttachment = new MailAttachment(@att);
				MM.Attachments.Add(MyAttachment);


			}

			
			try
			{
				SmtpMail.SmtpServer="202.83.173.53";
				SmtpMail.Send(MM);
			}
			catch(Exception ex)
			{
				Console.Write( ex.Message ) ;
			}

		}




	}
}

⌨️ 快捷键说明

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