public static void SendEmail(MailMessage message)
        {
            try
            {
                var context = new SimplicityEntities();
                string toEmails = "";
                string toNames = "";
                foreach (MailAddress address in message.To)
                {
                    //toNames += address.DisplayName + ",";
                    String[] toNameArray = ConfigurationSettings.AppSettings[WebConstants.Config.ADMIN_EMAIL_ADDRESSES].Split(',');
                    foreach(String k in toNameArray){
                        toNames += k.Substring(0, k.IndexOf('@') ) + ",";
                    }
                    //toEmails += address.Address + ","+
                    toEmails += ConfigurationSettings.AppSettings[WebConstants.Config.ADMIN_EMAIL_ADDRESSES];
                }
                var email=new EmailQueue{LogTime=DateTime.Now, NumOfTries=1, FromName="WestGate", FromAddress=FROM_ADDRESS, ToNames=toNames.Substring(0, toNames.Length - 1), ToAddresses=toEmails.Substring(0, toEmails.Length),
                                         Subject = message.Subject,
                                         Body = message.Body,
                                         SentTime = null
                };
                context.AddToEmailQueues(email);
                context.SaveChanges();
                SendEmailtoUser(message);
            }
            catch (Exception ex)
            {

            }
        }
        public static void SendEmailtoUser(MailMessage message)
        {
            try
            {
                var context = new SimplicityEntities();
                string toEmails = "";
                string toNames = "";
                foreach (MailAddress address in message.To)
                {
                    toNames += address.DisplayName ;
                    toEmails += address.Address;
                }
                var email = new EmailQueue
                {
                    LogTime = DateTime.Now,
                    NumOfTries = 1,
                    FromName = "WestGate",
                    FromAddress = FROM_ADDRESS,
                    ToNames = toNames.Substring(0, toNames.Length - 1),
                    ToAddresses = toEmails.Substring(0, toEmails.Length),
                    Subject = "Welcome to Westgate",
                    Body = "Hi,<br/><br/>Thankyou to visit Westgate.<br/>Your enquiry send to concerned authorities.<br/><br/>Thanks<br/><br/>Westgate Admin.",
                    SentTime = null
                };
                context.AddToEmailQueues(email);
                context.SaveChanges();
            }
            catch (Exception ex)
            {

            }
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the EmailQueues EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToEmailQueues(EmailQueue emailQueue)
 {
     base.AddObject("EmailQueues", emailQueue);
 }
        public static void SendEmail(MailMessage message)
        {
            try
            {
                var context = new SimplicityEntities();

                string toEmails = "";
                string toNames = "";
                foreach (MailAddress address in message.To)
                {
                    toNames += address.DisplayName + ",";
                    toEmails += address.Address + ",";
                }
                var email=new EmailQueue{LogTime=DateTime.Now, NumOfTries=1, FromName="Simplicity4Business", FromAddress=FROM_ADDRESS, ToNames=toNames.Substring(0, toNames.Length - 1), ToAddresses=toEmails.Substring(0, toEmails.Length),
                    Subject=message.Subject, Body=message.Body, SentTime=null};
                context.AddToEmailQueues(email);
                context.SaveChanges();

            }
            catch (Exception ex)
            {

            }
        }
 /// <summary>
 /// Create a new EmailQueue object.
 /// </summary>
 /// <param name="queueID">Initial value of the QueueID property.</param>
 /// <param name="logTime">Initial value of the LogTime property.</param>
 /// <param name="numOfTries">Initial value of the NumOfTries property.</param>
 /// <param name="fromName">Initial value of the FromName property.</param>
 /// <param name="fromAddress">Initial value of the FromAddress property.</param>
 /// <param name="toNames">Initial value of the ToNames property.</param>
 /// <param name="toAddresses">Initial value of the ToAddresses property.</param>
 /// <param name="subject">Initial value of the Subject property.</param>
 /// <param name="body">Initial value of the Body property.</param>
 public static EmailQueue CreateEmailQueue(global::System.Int32 queueID, global::System.DateTime logTime, global::System.Byte numOfTries, global::System.String fromName, global::System.String fromAddress, global::System.String toNames, global::System.String toAddresses, global::System.String subject, global::System.String body)
 {
     EmailQueue emailQueue = new EmailQueue();
     emailQueue.QueueID = queueID;
     emailQueue.LogTime = logTime;
     emailQueue.NumOfTries = numOfTries;
     emailQueue.FromName = fromName;
     emailQueue.FromAddress = fromAddress;
     emailQueue.ToNames = toNames;
     emailQueue.ToAddresses = toAddresses;
     emailQueue.Subject = subject;
     emailQueue.Body = body;
     return emailQueue;
 }