返回列表 回复 发帖

通过一个web.Mail发送到一个web.Mail

  usingSystem;

  usingSystem.Web;

  usingSystem.Web.Mail;

  usingDottext.Framework;

  usingDottext.Framework.Configuration;

  namespaceYourNamespace.Email

  {

  ///

  ///DefaultimplementationoftheIMailProvider

  ///

  publicclassSystemMail:IMailProvider

  {

  publicSystemMail(){}

  #region

  privatestring_to;

  publicstringTo

  {

  get{return_to;}

  set{_to=value;}

  }

  privatestring_from;

  publicstringFrom

  {

  get{return_from;}

  set{_from=value;}

  }

  privatestring_subject;

  publicstringSubject

  {

  get{return_subject;}

  set{_subject=value;}

  }

  privatestring_body;

  publicstringBody

  {

  get{return_body;}

  set{_body=value;}

  }

  #endregion

  privatestring_adminEmail;

  publicstringAdminEmail

  {

  get{return_adminEmail;}

  set{_adminEmail=value;}

  }

  privatestring_smtpServer='localhost';

  publicstringSmtpServer

  {

  get{return_smtpServer;}

  set{_smtpServer=value;}

  }

  privatestring_password;

  publicstringPassword

  {

  get{return_password;}

  set{_password=value;}

  }

  privatestring_userName;

  publicstringUserName

  {

  get{return_userName;}

  set{_userName=value;}

  }

  publicboolSend(stringto,stringfrom,stringsubject,stringmessage)

  {

  try

  {

  MailMessageem=newMailMessage();

  em.To=to;

  em.From=from;

  em.Subject=subject;

  em.Body=message;

  //FoundouthowtosendauthenticatedemailviaSystem.Web.Mailatem.Fields.Add('em.Fields.Add('

  }

  SmtpMail.SmtpServer=this.SmtpServer;

  SmtpMail.Send(em);

  returntrue;

  }

  catch

  {

  returnfalse;

  }

  }

  }

  }
返回列表