예제 #1
0
    protected void MailSend(string from, string to, string subject, string body)
    {
        //Test Email Data
        string strdir       = "D:\\TEMP\\";
        string AttFileName  = Label2.Text.ToString();
        string filelocation = strdir + AttFileName;

        //client = new SmtpClient();
        //client.Host = "localhost";
        //client.Port = 25;
        try
        {
            bool            T1;
            GoofyMailSender mail = new GoofyMailSender("localhost");
            T1 = mail.SendMailWithAttachment(to, from, subject, body, "");
            if (T1 == false)
            {
                Response.Write("<script>alert('Email address Error, Your Mail do not send,Please check recipient mail '); </script>");
            }
            else
            {
                if (PDFCheckBox.Checked == true)
                {
                    mail.AttachFile(filelocation);
                }
                mail.MailSend();
                updateEmailhistory(to, subject, body, from);
                //File.Delete(filelocation);
            }
        }
        catch
        {
            //File.Delete(filelocation);
            Response.Write("<script>alert('Email address Error, Your Mail do not send '); indow.close();</script>");
        }
        finally
        {
            Response.Write("Your E-mail has been sent sucessfully");
            Response.Write("<script>window.close();</script>");
        }
    }