// clsEmailListener.cs
// Copyright (C) 2008 Karel Jordaan http://zanzi.ops4it.com
// 
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
// 
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
using System;
using System.Diagnostics;
using System.Web.Mail;
using System.Windows.Forms;

namespace ResControlLogic
{
    /// <summary>
    /// clsEmailListener is a trace listener that sends email.
    /// </summary>
    public class clsEmailListener : TraceListener
    {
        #region Variable declaration

        //private const string MAIL_FROM = "error@cvviewer.com";
        //private const string MAIL_MESSAGE = "Error information: ";
        //private const string MAIL_SUBJECT = " ERROR";
        //private const string MAIL_TO = "somewhere@yahoo.com";
        //private readonly Exception ex;
        //private readonly MailMessage msg = new MailMessage();

        #endregion

        #region Functions

        public clsEmailListener(Exception ex)
        {
            //
            // TODO: Add constructor logic here
            // Init all the mail classes
            //ex = exx;
        }

        public override void Write(string str)
        {
            //base.Write (str);
            ComposeEmail();
        }

        public override void WriteLine(string str)

        {
            //base.Write (str);
            ComposeEmail();
        }

        private void ComposeEmail()
        {
            try
            {
                //DateTime dt = new DateTime();
                //msg.From = MAIL_FROM;
                //msg.To = MAIL_TO;
                //msg.Subject = MAIL_SUBJECT;
                //msg.Body = MAIL_SUBJECT + " " + dt.Date + Keys.Tab + dt.TimeOfDay + Keys.Tab + ex.Message + Keys.Tab +
                //           ex.Source + Keys.Tab + ex.StackTrace + Keys.Tab + ex.TargetSite;
                //msg.BodyFormat = MailFormat.Text;

                //SmtpMail.Send(msg);
            }
            catch (Exception)
            {
                // new clsExeption(ex);
                //ErrByte = 1;
            }
        }

        private void SendEmail()
        {
        }

        #endregion
    }

//	internal struct structVersion
//	{
//		string	assemblyname;
//		string	assemblyversion;
//		string	culture;
//	}

    /// <summary>
    /// Structure to hold error information
    /// </summary>
//	internal struct stuctErrorInfo
//	{	
//		structVersion AsseblyInfo;
//		int  ErrNumber;
//		string  ErrDescription;
//		string  ErrStackTrace;
//	}
}

//Dim email As New System.Web.Mail.MailMessage()
//email.To = "RecipientAddress"
//email.From = "SenderAddress"
//email.Body = "MessageText"
//email.Subject = "SubjectText"
//email.BodyFormat = Web.Mail.MailFormat.Text
//System.Web.Mail.SmtpMail.SmtpServer = "SmtpServerName"
//System.Web.Mail.SmtpMail.Send(email)