//====================================================================
//      Copyright(C) 2008-2009 ruimingde
//      All rights reserved
//      
//      filename :Email
//      description:
//
//      created by 郑瑞明 at 10/12/2008 18:33:53
//=====================================================================
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.Text;

using BookShopOnline.Utility;

/// <summary>
/// Email 的摘要说明
/// </summary>
public class Email
{
    private string toEmail;
    private string subject;
    private string body;

    public Email(string toEmail,string subject,string body)
    {
        this.toEmail = toEmail;
        this.subject = subject;
        this.body = body;
    }

    public void Send()
    {
        SmtpServer smtpServer = EmailHelper.GetDefaultSmtpServer();

        EmailHelper emailHelper = new EmailHelper(smtpServer);

        EmailMsg emailMsg = new EmailMsg();
        emailMsg.FromEmail = smtpServer.FromEmail;
        emailMsg.FromName = smtpServer.FromName;
        emailMsg.ToEmail = toEmail;
        emailMsg.ToName = "";
        emailMsg.Subject = subject;
        emailMsg.Body = body;
        emailMsg.IsBodyHtml = true;
        emailMsg.BodyEncoding = Encoding.UTF8;

        emailHelper.SendEmail(emailMsg);
    }
}
