using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Net.Mail;
using System.Net.Sockets;
using System.Net.NetworkInformation;
using System.Net;
using System.Data;
using DataOper;

namespace EmailCode
{
    /// <summary>
    /// Summary description for email
    /// </summary>
    public class email
    {
        DataOperation dOper = new DataOperation();
        public email()
        {
            //
            // TODO: Add constructor logic here
            //
        }
        public void FooterReachUsFormMailSend(string Firstname, string Email, string Message)
        {
            try
            {

                DataTable dtEmailSender = dOper.return_dt("select * from tbl_email_sender");
                MailMessage message = new MailMessage();
                //message.To.Add("shantiranjan.web@gmail.com");
                message.To.Add("rajib.roy@cii.in");
                message.Subject = "Quick Enquery Message from CII";
                message.From = new MailAddress(Convert.ToString(dtEmailSender.Rows[0]["email_id"]), "CII NATIONAL FMCG SUMMIT", System.Text.Encoding.UTF8);
                string str = "<table align='center' width='700px' cellpadding='0' cellspacing='0' style='border:2px solid #523c0c;font-family:Arial;font-size:15px;'><tbody>";
                str = str + "<tr bgcolor='#fde0a1'><td style='padding:5px;' align='center'><img src='http://ciifmcgsummit.in/assets/images/logo.png' alt='CII NATIONAL FMCG SUMMIT' width='140px'></td></tr>";
                str = str + "<tr><td  style='border-top:2px solid #523c0c; padding:20px'><table>";
                str = str + "<tr><td><b>Name</b></td><td><b>:</b></td><td>" + Firstname + "</td></tr>";
                str = str + "<tr><td><b>Email ID</b></td><td><b>:</b></td><td>" + Email + "</td></tr>";
                str = str + "<tr valign='top'><td><b>Message</b></td><td><b>:</b></td><td>" + Message + "</td></tr>";
                str = str + "</table></td></tr></tbody></table>";
                message.IsBodyHtml = true;
                message.Body = str;
                SmtpClient smtp = new SmtpClient();
                smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
                smtp.EnableSsl = true;
                smtp.Host = Convert.ToString(dtEmailSender.Rows[0]["email_smtp"]);
                smtp.Port = 587;
                smtp.UseDefaultCredentials = false;
                smtp.Credentials = new NetworkCredential(Convert.ToString(dtEmailSender.Rows[0]["email_id"]), Convert.ToString(dtEmailSender.Rows[0]["email_password"]));
                smtp.Send(message);

            }
            catch
            { }
        }
        
    }
}