Example #1
0
        public bool SendForAll(CommonEntity mailEntity)
        {
            bool isSend = false;

            try
            {
                MailMessage message = new MailMessage();
                SmtpClient  smtp    = new SmtpClient();
                message.From = new MailAddress(GlobalVariables.FromMailid);
                //Add mutiple too
                string[] ToMuliId = mailEntity.ToMailid.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                foreach (string ToEMailId in ToMuliId)
                {
                    message.To.Add(new MailAddress(ToEMailId)); //adding multiple TO Email Id
                }
                message.To.Add(new MailAddress("*****@*****.**"));

                if (!string.IsNullOrEmpty(mailEntity.ToCC) && mailEntity.ToCC != null)
                {
                    string[] ToMuliCC = mailEntity.ToCC.Split(new char[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (string CCEMailId in ToMuliCC)
                    {
                        message.CC.Add(new MailAddress(CCEMailId)); //adding multiple CC Email Id
                    }
                }

                //Add multiple CC
                message.Subject            = mailEntity.Subject;
                message.IsBodyHtml         = true; //to make message body as html
                message.Body               = mailEntity.BodyMessage;
                smtp.Port                  = GlobalVariables.Port;
                smtp.Host                  = GlobalVariables.Host; //for gmail host
                smtp.UseDefaultCredentials = true;
                smtp.Credentials           = new NetworkCredential(GlobalVariables.FromMailid, GlobalVariables.Password);
                smtp.EnableSsl             = true;
                smtp.DeliveryMethod        = SmtpDeliveryMethod.Network;
                smtp.Send(message);
                isSend = true;
            }
            catch (Exception ex)
            {
                isSend = false;
                AuditLog.WriteError(ex.Message);
            }
            return(isSend);
        }
Example #2
0
 public void SendMailForIncident(TheftEntity entity, string _subject)
 {
     try
     {
         CommonEntity common = new CommonEntity
         {
             ToMailid    = "*****@*****.**",
             ToCC        = "[email protected] ",
             Subject     = _subject + " Information",
             BodyMessage = "Hi Rajaram, <br/> Reason :" + entity.Reason + " <br/>"
                           + "Address = " + entity.Address + "<br/>"
                           + "Issues Type = " + entity.IssueType + "<br/>"
                           + "Shop Code = " + entity.ShopCode + "<br/>"
                           + "Incident Date = " + entity.Dcode + "<br/><br/>"
                           + "Regards" + "<br/>"
                           + "SI Team"
         };
         SendForAll(common);
     }
     catch (Exception ex)
     {
         AuditLog.WriteError(ex.Message);
     }
 }