public void Dispose()
 {
     objDB = null;
 }
Beispiel #2
0
        public AppEmails(EmailSettingIDs emailSettingID)
        {
            // TODO: Complete member initialization
            this.emailSettingID = emailSettingID;

            MAIL         = new MailMessage();
            emailSetting = new EmailSettings();
            using (airbornefrsDataContext objDB = new airbornefrsDataContext())
            {
                var emailData = (from o in objDB.emailSettings_GET_sp_V02(Convert.ToInt32(emailSettingID)) select o).ToList();
                var email     = emailData[0];

                if (!string.IsNullOrEmpty(email.defaultbcc))
                {
                    emailSetting.DefaultBCC = email.defaultbcc;
                    string[] BCC = emailSetting.DefaultBCC.Split(',');
                    foreach (var item in BCC)
                    {
                        if (!string.IsNullOrEmpty(item))
                        {
                            MAIL.Bcc.Add(item);
                        }
                    }
                }
                if (!string.IsNullOrEmpty(email.defaultcc))
                {
                    emailSetting.DefaultCC = email.defaultcc;
                    string[] CC = emailSetting.DefaultCC.Split(',');
                    foreach (var item in CC)
                    {
                        if (!string.IsNullOrEmpty(item))
                        {
                            MAIL.CC.Add(item);
                        }
                    }
                }

                MAIL.Body = email.defaultmailbody;


                if (!string.IsNullOrEmpty(email.defaultto))
                {
                    emailSetting.DefaultTo = email.defaultto;
                    string[] TO = emailSetting.DefaultTo.Split(',');
                    foreach (var item in TO)
                    {
                        if (!string.IsNullOrEmpty(item))
                        {
                            MAIL.To.Add(item);
                        }
                    }
                }
                emailSetting.EmailSettingID = Convert.ToInt32(emailSettingID);

                //email.enablessl
                if (!string.IsNullOrEmpty(email.fromemailaddress))
                {
                    emailSetting.FromEmailAddress = email.fromemailaddress;
                    if (!string.IsNullOrEmpty(email.fromemailname))
                    {
                        emailSetting.FromName = email.fromemailname;
                    }
                    else
                    {
                        emailSetting.FromName = "";
                    }
                    MAIL.From = new MailAddress(emailSetting.FromEmailAddress, emailSetting.FromName);
                }

                MAIL.IsBodyHtml         = Convert.ToBoolean(email.isbodyhtml);
                emailSetting.IsBodyHtml = Convert.ToBoolean(email.isbodyhtml);

                MAIL.Subject         = email.subject;
                emailSetting.Subject = email.subject;

                emailSetting.SMTP = email.outgoingsmtp;
                emailSetting.Port = email.port;
                emailSetting.FromEmailPassword = email.emailpwd;
            }
        }