using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Net.Mail;
using System.Net;
using System.Text;
/// <summary>
/// ChangeHopeEmail 的摘要说明
/// </summary>
namespace ChangeHopeEmail
{
  public class ChangeHopemail
    {
      public void sendmail(string server, string username,string password ,string toaddr, string titel, string body)//,string path)
        {
            System.Net.Mail.SmtpClient client = new SmtpClient();
            client.Host = server;
            client.UseDefaultCredentials = false;
            client.Credentials = new System.Net.NetworkCredential(username, password);
            //星号改成自己邮箱的密码
            client.DeliveryMethod = SmtpDeliveryMethod.Network;

            System.Net.Mail.MailMessage message = new MailMessage(username, toaddr,titel,body);
            message.BodyEncoding = System.Text.Encoding.Default;
            message.IsBodyHtml = true;
           
            //添加附件
            //if (path != "" || path != null)
            //{
            //    Attachment data = new Attachment(path, System.Net.Mime.MediaTypeNames.Application.Octet);
            //    message.Attachments.Add(data);
            //}
            client.Send(message);
        }
    }
}