コード例 #1
0
ファイル: EmailHelper.cs プロジェクト: accuit/IqHealth
        public static int PrepareAndSendAppointmentEmail(DoctorAppointment model)
        {
            string body = string.Empty;

            using (StreamReader reader = new StreamReader(HttpContext.Current.Server.MapPath("~/Helpers/EmailTemplates/DoctorAppointmentConfirmation.html")))
            {
                body = reader.ReadToEnd();
            }
            body = body.Replace("{Name}", model.Name);
            body = body.Replace("{Age}", model.Age.ToString());
            body = body.Replace("{Sex}", model.Sex == 1 ? "Male" : "Female");
            body = body.Replace("{BookingDate}", model.BookingDate.ToString());
            body = body.Replace("{Email}", model.Email);
            body = body.Replace("{Mobile}", model.Mobile);

            var C = GetCompanyDetails(Convert.ToInt32(model.CompanyID));

            body = body.Replace("{Company}", C.Name);
            body = body.Replace("{Logo}", C.LogoUrl);

            EmailServiceDTO email = new EmailServiceDTO();

            email.ToEmail      = model.Email;
            email.Status       = (int)AspectEnums.EmailStatus.Pending;
            email.Body         = body;
            email.Priority     = 2;
            email.IsAttachment = false;
            return(SendEmail(email));
        }
コード例 #2
0
ファイル: EmailHelper.cs プロジェクト: accuit/IqHealth
        public static int PrepareAndSendEnquiryEmail(OnlineEnquiry model)
        {
            string body = string.Empty;

            using (StreamReader reader = new StreamReader(HttpContext.Current.Server.MapPath("~/Helpers/EmailTemplates/OnlineEnquiryResponse.html")))
            {
                body = reader.ReadToEnd();
            }

            var C = GetCompanyDetails(model.CompanyID);

            body = body.Replace("{Name}", model.Name);

            body = body.Replace("{Company}", C.Name);
            body = body.Replace("{Logo}", C.LogoUrl);

            EmailServiceDTO email = new EmailServiceDTO();

            email.ToEmail      = model.Email;
            email.Status       = (int)AspectEnums.EmailStatus.Pending;
            email.Body         = body;
            email.Priority     = 2;
            email.IsAttachment = false;
            return(SendEmail(email));
        }
コード例 #3
0
ファイル: EmailHelper.cs プロジェクト: accuit/IqHealth
        public static int PrepareAndSendBookingEmail(BookingMaster model)
        {
            string body = string.Empty;

            using (StreamReader reader = new StreamReader(HttpContext.Current.Server.MapPath("~/Helpers/EmailTemplates/UserBookingConfirmation.html")))
            {
                body = reader.ReadToEnd();
            }
            body = body.Replace("{Name}", model.FirstName + " " + model.LastName);
            body = body.Replace("{Age}", model.Age.ToString());
            body = body.Replace("{Sex}", model.Sex == 1 ? "Male" : "Female");
            body = body.Replace("{CollectionType}", model.CollectionType == 1 ? "Collection Centre" : "Home");
            body = body.Replace("{BookingDate}", model.BookingDate.ToString());
            body = body.Replace("{Email}", model.Email);
            body = body.Replace("{Mobile}", model.Mobile);
            body = body.Replace("{Address}", model.Address);
            body = body.Replace("{Landmark}", model.Landmark);
            body = body.Replace("{PinCode}", model.PinCode);

            var C = GetCompanyDetails(1);

            body = body.Replace("{Company}", C.Name);
            body = body.Replace("{Logo}", C.LogoUrl);


            EmailServiceDTO email = new EmailServiceDTO();

            email.ToEmail      = model.Email;
            email.Status       = (int)AspectEnums.EmailStatus.Pending;
            email.Body         = body;
            email.Priority     = 2;
            email.IsAttachment = false;
            return(SendEmail(email));
        }
コード例 #4
0
ファイル: EmailHelper.cs プロジェクト: accuit/IqHealth
        public static int ForgetPasswordEmail(string email, string name, string key)
        {
            string resetUrl         = AppUtil.GetAppSettings(AspectEnums.ConfigKeys.ForgotPasswordURL);
            string PasswordResetURL = resetUrl + key;

            string body = string.Empty;

            using (StreamReader reader = new StreamReader(HttpContext.Current.Server.MapPath("~/Helpers/EmailTemplates/ResetPassword.html")))
            {
                body = reader.ReadToEnd();
            }
            body = body.Replace("{{EMAIL}}", email);
            body = body.Replace("{{NAME}}", name);
            body = body.Replace("{{PASSWORDRESETURL}}", PasswordResetURL);

            EmailServiceDTO emailService = new EmailServiceDTO();

            emailService.ToEmail      = email;
            emailService.Status       = (int)AspectEnums.EmailStatus.Pending;
            emailService.Body         = body;
            emailService.Subject      = "Reset your account password.";
            emailService.Priority     = 2;
            emailService.IsAttachment = false;
            return(SendEmail(emailService));
        }
コード例 #5
0
ファイル: EmailHelper.cs プロジェクト: accuit/IqHealth
        public int PrepareAndSendEntrepreneurEmail(EntrepreneurEnquiryDTO model)
        {
            ActivityLog.SetLog("[START][PrepareAndSendEntrepreneurEmail]", LogLoc.INFO);
            string body = string.Empty;

            using (StreamReader reader = new StreamReader(System.Web.HttpContext.Current.Server.MapPath("~/Helpers/EmailTemplates/BusinessEnquiry.html")))
            {
                body = reader.ReadToEnd();
            }
            body = body.Replace("{Name}", model.Name);
            body = body.Replace("{Date}", DateTime.Now.ToShortDateString());
            body = body.Replace("{Email}", model.Email);
            body = body.Replace("{Mobile}", model.Mobile);
            body = body.Replace("{Address}", model.Address);
            body = body.Replace("{PinCode}", model.Pincode);
            body = body.Replace("{Location}", model.Location);
            body = body.Replace("{Profession}", model.Profession);
            body = body.Replace("{Investment}", model.Investment.ToString());

            EmailServiceDTO email = new EmailServiceDTO();

            email.ToEmail      = model.Email;
            email.Status       = (int)AspectEnums.EmailStatus.Pending;
            email.Body         = body;
            email.ToName       = model.Name;
            email.Priority     = 2;
            email.IsAttachment = false;
            ActivityLog.SetLog("[END][PrepareAndSendEntrepreneurEmail]", LogLoc.INFO);
            return(SendEmail(email));
        }
コード例 #6
0
        /// <summary>
        /// Method to insert email record into database
        /// </summary>
        /// <param name="email">email entity</param>
        /// <returns>returns boolean status</returns>
        public bool InsertEmailRecord(EmailServiceDTO email)
        {
            EmailService emailDetail = new EmailService();

            ObjectMapper.Map(email, emailDetail);
            return(SystemRepository.InsertEmailRecord(emailDetail));
        }
コード例 #7
0
        /// <summary>
        /// Method to get notifications
        /// </summary>
        /// <returns>returns notifications to user</returns>
        ///
        //VC20140827
        //public IList<NotificationServiceBO> GetBatchNotifications()
        //{
        //    List<NotificationServiceBO> notifications = new List<NotificationServiceBO>();
        //    List<object> paramObjects = new List<object>() { System.DateTime.Now.Date, System.DateTime.Today.AddDays(1).Date };
        //    using (IDataReader reader = DataAccess.ExecuteReader("SpGetBatchNotifications", paramObjects.ToArray()))
        //    {
        //        if (reader != null)
        //        {
        //            while (reader.Read())
        //            {
        //                NotificationServiceBO notification = new NotificationServiceBO()
        //                {
        //                    NotificationServiceID = Convert.ToInt64(reader[reader.GetOrdinal("NotificationServiceID")]),
        //                    NotificationID = Convert.ToInt64(GetReaderValue(reader, "NotificationID")),
        //                    AndroidID = Convert.ToString(reader[reader.GetOrdinal("AndroidID")]),
        //                    Frequency = Convert.ToInt32(reader[reader.GetOrdinal("Frequency")]),
        //                    Notification = Convert.ToString(GetReaderValue(reader, "PushNotificationMessage")),
        //                    NotificationDate = Convert.ToDateTime(reader[reader.GetOrdinal("NotificationDate")]),
        //                    EndDate = Convert.ToDateTime(reader[reader.GetOrdinal("EndDate")]),
        //                    UserID = Convert.ToInt64(reader[reader.GetOrdinal("UserID")]),
        //                };
        //                notifications.Add(notification);
        //            }
        //            reader.Close();
        //        }
        //    }

        //    return notifications;
        //}
        //VC20140827

        /// <summary>
        /// Method to fetch batch emails to send email
        /// </summary>
        /// <returns>returns batch emails</returns>
        public IList <EmailServiceDTO> GetBatchEmails()
        {
            List <EmailServiceDTO> emails = new List <EmailServiceDTO>();

            using (IDataReader reader = DataAccess.ExecuteReader("SpGetBatchEmail"))
            {
                if (reader != null)
                {
                    while (reader.Read())
                    {
                        EmailServiceDTO systemMail = new EmailServiceDTO()
                        {
                            EmailServiceID     = Convert.ToInt64(reader[reader.GetOrdinal("EmailServiceID")]),
                            Remarks            = Convert.ToString(GetReaderValue(reader, "Remarks")),
                            IsAttachment       = Convert.ToBoolean(reader[reader.GetOrdinal("IsAttachment")]),
                            Body               = Convert.ToString(GetReaderValue(reader, "Body")),
                            Subject            = Convert.ToString(GetReaderValue(reader, "Subject")),
                            Status             = Convert.ToInt32(reader[reader.GetOrdinal("Status")]),
                            IsHtml             = Convert.ToBoolean(GetReaderValue(reader, "IsHtml")),
                            ToName             = Convert.ToString(GetReaderValue(reader, "ToName")),
                            ToEmail            = Convert.ToString(GetReaderValue(reader, "ToEmail")),
                            CcEmail            = Convert.ToString(GetReaderValue(reader, "CcEmail")),
                            BccEmail           = Convert.ToString(GetReaderValue(reader, "BccEmail")),
                            AttachmentFileName = Convert.ToString(GetReaderValue(reader, "AttachmentFileName")),
                        };
                        emails.Add(systemMail);
                    }
                    //reader.Close();
                }
            }

            return(emails);
        }
コード例 #8
0
        public void SendEmailNotification(EmailServiceDTO emailModel, TemplateMasterBO emailTemplate)
        {
            string CCAddress = string.Empty;

            if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["CCAddress"]))
            {
                CCAddress = ConfigurationManager.AppSettings["CCAddress"];
            }
            SendEmail(emailModel, CCAddress);
        }
コード例 #9
0
        public int SendEmail(EmailServiceDTO emailmodel)
        {
            string fromPass, fromAddress, fromName = "";

            PrepareMergeField(emailmodel);
            MailMessage message     = new MailMessage();
            SmtpClient  smtpClient  = new SmtpClient();
            bool        isDebugMode = ConfigurationManager.AppSettings["IsDebugMode"] == "Y" ? true : false;

            try
            {
                if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["CCAddress"]))
                {
                    emailmodel.CcEmail = ConfigurationManager.AppSettings["CCAddress"];
                }

                if (isDebugMode)
                {
                    message.To.Add(ConfigurationManager.AppSettings["DbugToEmail"].ToString());
                    fromAddress            = ConfigurationManager.AppSettings["DbugFromEmail"].ToString();
                    fromPass               = ConfigurationManager.AppSettings["DbugFromPass"];
                    smtpClient.Host        = ConfigurationManager.AppSettings["DbugSMTPHost"];                  //"relay-hosting.secureserver.net";   //-- Donot change.
                    smtpClient.Port        = Convert.ToInt32(ConfigurationManager.AppSettings["DbugSMTPPort"]); // 587; //--- Donot change
                    smtpClient.EnableSsl   = true;
                    smtpClient.Credentials = new System.Net.NetworkCredential(fromAddress, fromPass);
                    message.Subject        = "[Debug Mode ON] - " + emailmodel.Subject;
                }
                else
                {
                    fromName        = ConfigurationManager.AppSettings["FromName"].ToString();
                    fromAddress     = ConfigurationManager.AppSettings["FromEmail"].ToString();
                    smtpClient.Host = ConfigurationManager.AppSettings["SMTPHost"];
                    message.To.Add(emailmodel.ToEmail);
                    message.Subject = emailmodel.Subject;
                }

                message.BodyEncoding = Encoding.UTF8;
                message.From         = new System.Net.Mail.MailAddress(fromAddress, emailmodel.FromName);
                message.IsBodyHtml   = true;
                message.Body         = emailmodel.Body;
                smtpClient.Send(message);
                message.Dispose();
                return((int)AspectEnums.EmailStatus.Sent);
                //var isInsert =  DBEntities.EmailServices.Add(emailModel);
                //DBEntities.SaveChanges();
            }
            catch (Exception ex)
            {
                return((int)AspectEnums.EmailStatus.Failed);
            }
        }
コード例 #10
0
        public JsonResponse <int> SendAppointmentEmail(int UserId)
        {
            JsonResponse <int> response = new JsonResponse <int>();

            try
            {
                #region Prepare OTP Data
                string UniqueString = AppUtil.GetUniqueGuidString();
                string OTPString    = AppUtil.GetUniqueRandomNumber(100000, 999999); // Generate a Six Digit OTP
                OTPDTO objOTP       = new OTPDTO()
                {
                    GUID = UniqueString, OTP = OTPString, CreatedDate = DateTime.Now, UserID = UserId, Attempts = 0
                };
                #endregion

                #region Save OTP and Send Email
                if (SecurityBusinessInstance.SaveOTP(objOTP))
                {
                    #region Send Email
                    string hostName         = AppUtil.GetAppSettings(AspectEnums.ConfigKeys.HostName);
                    string rawURL           = AppUtil.GetAppSettings(AspectEnums.ConfigKeys.ForgotPasswordURL);
                    string PasswordResetURL = String.Format(rawURL, hostName) + "?id=" + UniqueString;

                    EmailTemplateDTO objEmailTemplate = SecurityBusinessInstance.GetEmailTemplate(AspectEnums.EmailTemplateType.ForgotPassword);
                    var             userProfile       = new Object();// UserBusinessInstance.DisplayUserProfile(UserId);
                    EmailServiceDTO emailService      = new EmailServiceDTO();
                    //emailService.Body = string.Format(objEmailTemplate.Body, userProfile.FirstName, OTPString, PasswordResetURL);
                    //emailService.Priority = 1;
                    //emailService.IsHtml = true;
                    //emailService.Status = (int)AspectEnums.EmailStatus.Pending;
                    //emailService.ToName = userProfile.FirstName;
                    //emailService.ToEmail = userProfile.EmailID;
                    //emailService.FromEmail = userProfile.EmailID;
                    //emailService.Subject = objEmailTemplate.Subject;
                    //BatchBusinessInstance.InsertEmailRecord(emailService);

                    response.IsSuccess = true;
                    #endregion
                }
                #endregion
            }
            catch (Exception ex)
            {
                response.IsSuccess    = false;
                response.Message      = ex.Message;
                response.StatusCode   = "500";
                response.SingleResult = 0;
            }

            return(response);
        }
コード例 #11
0
        public void SendEmailNotification(EmailServiceDTO emailModel, TemplateMasterBO Template)
        {
            string CCAddress = string.Empty;

            if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["CCAddress"]))
            {
                CCAddress = ConfigurationManager.AppSettings["CCAddress"];
            }
            // string emailBody = PrepareEmailContent(emailModel, Template); //GetHtmlTextByName(templateName, templatelocation, "Content");
            // emailModel.Body = emailBody;
            emailModel.Body = FindReplace(emailModel.Body, "[CUSTOMERNAME]", emailModel.ToName);
            emailModel.Body = FindReplace(emailModel.Body, "[QUERYDATE]", DateTime.Now.ToShortDateString());
            SendEmail(emailModel, CCAddress, emailModel.Body);
        }
コード例 #12
0
 public void PrepareMergeField(EmailServiceDTO emailModel)
 {
     try
     {
         emailModel.Subject = emailModel.Subject.FindReplace("[COMPANY]", AppUtil.GetAppSettings(ConfigurationManager.AppSettings["CompanyName"]));
         emailModel.Body.FindReplace("[COMPANY]", AppUtil.GetAppSettings(AspectEnums.ConfigKeys.CompanyName));
         emailModel.Body.FindReplace("[COMPANYLOGOURL]", AppUtil.GetAppSettings(AspectEnums.ConfigKeys.CompanyLogoURL));
         emailModel.Body.FindReplace("[COMPANYWEBURL]", AppUtil.GetAppSettings(AspectEnums.ConfigKeys.CompanyWebsite));
         emailModel.Body.FindReplace("[COMPANYEMAIL]", AppUtil.GetAppSettings(AspectEnums.ConfigKeys.FromEmail));
         emailModel.Body.FindReplace("[QUERYDATE]", DateTime.Now.ToShortDateString());
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #13
0
ファイル: UserManager.cs プロジェクト: accuit/BaseProject
        ///// <summary>
        ///// Method to find beat coverage days
        ///// </summary>
        ///// <returns>returns days list</returns>
        //private List<int> GetBeatCoverageDays(long RoleID)
        //{
        //    List<int> days = new List<int>();
        //    //SystemSetting settings = SystemRepository.GetSystemSettings();
        //    BeatWindowSetting settings = SystemRepository.GetBeatWindowSettings((int)RoleID);
        //    if (settings != null)
        //    {
        //        if (!String.IsNullOrEmpty(settings.CoveragePlanFirstWindow))
        //        {
        //            string[] dayArray = settings.CoveragePlanFirstWindow.Trim().Split('-');
        //            if (dayArray.Length > 0)
        //            {
        //                int firstSlot = Convert.ToInt32(dayArray[0]);
        //                int secondSlot = Convert.ToInt32(dayArray[1]);

        //                for (int i = firstSlot; i <= secondSlot; i++)
        //                {
        //                    days.Add(i);
        //                }
        //                if (!String.IsNullOrEmpty(settings.CoveragePlanSecondWndow))
        //                {
        //                    dayArray = settings.CoveragePlanSecondWndow.Trim().Split('-');
        //                    firstSlot = Convert.ToInt32(dayArray[0]);
        //                    secondSlot = Convert.ToInt32(dayArray[1]);
        //                    for (int i = firstSlot; i <= secondSlot; i++)
        //                    {
        //                        days.Add(i);
        //                    }
        //                }
        //            }
        //        }
        //    }
        //    return days;
        //}

        //private bool IsBeatCreationEnabled(int month, long userID, int year)
        //{
        //    return UserRepository.IsBeatCreationAllowed(month, userID, year);
        //}

        ///// <summary>
        ///// Method to check whether beat creation modules is enabled or not
        ///// </summary>
        ///// <param name="userID">user ID</param>
        ///// <returns>returns boolean status</returns>
        //private bool IsBeatCreationEnabled(long userID)
        //{
        //    bool isAllowed = false;
        //    int coverageFirstWindowDay = 0;
        //    int coverageSecondWindowDay = 0;
        //    List<int> days = new List<int>();
        //    SystemSetting settings = SystemRepository.GetSystemSettings();
        //    if (settings != null)
        //    {
        //        if (!String.IsNullOrEmpty(settings.CoveragePlanFirstWindow))
        //        {
        //            string[] dayArray = settings.CoveragePlanFirstWindow.Trim().Split('-');
        //            if (dayArray.Length > 0)
        //            {
        //                int firstSlot = Convert.ToInt32(dayArray[0]);
        //                coverageFirstWindowDay = firstSlot;
        //                int secondSlot = Convert.ToInt32(dayArray[1]);

        //                for (int i = firstSlot; i <= secondSlot; i++)
        //                {
        //                    days.Add(i);
        //                }
        //                if (days.Contains(DateTime.Today.Day))
        //                {
        //                    isAllowed = IsBeatCreationEnabled(DateTime.Today.Month, userID, DateTime.Today.Year);
        //                    return isAllowed;
        //                }
        //                if (!String.IsNullOrEmpty(settings.CoveragePlanSecondWndow))
        //                {
        //                    dayArray = settings.CoveragePlanSecondWndow.Trim().Split('-');
        //                    firstSlot = Convert.ToInt32(dayArray[0]);
        //                    coverageSecondWindowDay = firstSlot;
        //                    secondSlot = Convert.ToInt32(dayArray[1]);
        //                    for (int i = firstSlot; i <= secondSlot; i++)
        //                    {
        //                        days.Add(i);
        //                    }
        //                    if (days.Contains(DateTime.Today.Day))
        //                    {
        //                        isAllowed = IsBeatCreationEnabled(DateTime.Today.AddMonths(1).Month, userID, DateTime.Today.Year);
        //                        return isAllowed;
        //                    }
        //                }
        //            }
        //        }
        //    }
        //    if (!isAllowed)
        //    {
        //        UserSystemSetting userSettings = UserRepository.GetUserSystemSettings(userID);
        //        if (userSettings != null)
        //        {
        //            List<int> exceptionDays = new List<int>();
        //            if (userSettings.IsCoverageException && userSettings.CoverageExceptionWindow.HasValue)
        //            {
        //                string[] dayArray = new string[] { userSettings.CoverageExceptionWindow.Value.Day.ToString() };
        //                if (dayArray.Length > 0)
        //                {
        //                    int firstSlot = Convert.ToInt32(dayArray[0]);
        //                    if (dayArray.Length > 1)
        //                    {
        //                        int secondSlot = Convert.ToInt32(dayArray[1]);

        //                        for (int i = firstSlot; i <= secondSlot; i++)
        //                        {
        //                            exceptionDays.Add(i);
        //                        }
        //                        if (secondSlot >= coverageSecondWindowDay)
        //                        {
        //                            isAllowed = IsBeatCreationEnabled(DateTime.Today.AddMonths(1).Month, userID, DateTime.Today.Year);
        //                            return isAllowed;
        //                        }
        //                        else
        //                        {
        //                            isAllowed = IsBeatCreationEnabled(DateTime.Today.Month, userID, DateTime.Today.Year);
        //                            return isAllowed;
        //                        }
        //                    }
        //                    else
        //                    {
        //                        if (firstSlot >= coverageFirstWindowDay)
        //                        {
        //                            isAllowed = IsBeatCreationEnabled(DateTime.Today.Month, userID, DateTime.Today.Year);
        //                            return isAllowed;
        //                        }
        //                        else
        //                        {
        //                            isAllowed = IsBeatCreationEnabled(DateTime.Today.AddMonths(1).Month, userID, DateTime.Today.Year);
        //                            return isAllowed;
        //                        }

        //                    }
        //                }

        //            }
        //        }
        //    }
        //    return isAllowed;
        //}

        ///// <summary>
        ///// Method to check user exception beat settings
        ///// </summary>
        ///// <param name="userID">user ID</param>
        ///// <returns>returns boolean status</returns>
        //private bool IsUserExceptionDateAdded(long userID)
        //{
        //    UserSystemSetting userSettings = UserRepository.GetUserSystemSettings(userID);
        //    if (userSettings != null)
        //    {
        //        List<int> days = new List<int>();
        //        if (userSettings.IsCoverageException && userSettings.CoverageExceptionWindow.HasValue)
        //        {
        //            string[] dayArray = new string[] { userSettings.CoverageExceptionWindow.Value.Day.ToString() };
        //            if (dayArray.Length > 0)
        //            {
        //                int firstSlot = Convert.ToInt32(dayArray[0]);
        //                if (dayArray.Length > 1)
        //                {
        //                    int secondSlot = Convert.ToInt32(dayArray[1]);

        //                    for (int i = firstSlot; i <= secondSlot; i++)
        //                    {
        //                        days.Add(i);
        //                    }
        //                }
        //                else
        //                {
        //                    days.Add(firstSlot);
        //                }
        //            }
        //            return days.Count > 0 && days.Contains(System.DateTime.Today.Day);
        //        }
        //    }
        //    return false;
        //}

        /// <summary>
        /// Method to send reset password email to user
        /// </summary>
        /// <param name="emailID">email ID</param>
        /// <param name="toName">to name</param>
        /// <param name="password">new password</param>
        private void SendResetPasswordEmail(string emailID, string toName, string password)
        {
            EmailServiceDTO emailService = new EmailServiceDTO();

            emailService.ToEmail            = emailID;
            emailService.ToName             = toName;
            emailService.Subject            = "Your Password Details";
            emailService.FromEmail          = emailID;
            emailService.Body               = "Hi, <br/>Please check your Login Details<br/><br/>Your Username: "******"<br/><br/>Your Password: "******"<br/><br/>";
            emailService.IsHtml             = true;
            emailService.IsAttachment       = false;
            emailService.AttachmentFileName = string.Empty;
            emailService.Priority           = 1;
            emailService.Status             = (int)AspectEnums.EmailStatus.Pending;
            //IBatchService batchInstance = AopEngine.Resolve<IBatchService>(AspectEnums.AspectInstanceNames.BatchManager, AspectEnums.ApplicationName.Samsung);
            //batchInstance.InsertEmailRecord(emailService);
        }
コード例 #14
0
ファイル: EmailHelper.cs プロジェクト: accuit/IqHealth
        public static int PrepareAndSendEmail <T>(T model, string otherDetails = "") where T : EmailModel
        {
            string body = string.Empty;

            using (StreamReader reader = new StreamReader(HttpContext.Current.Server.MapPath("~/Helpers/EmailTemplates/OnlineEnquiry.html")))
            {
                body = reader.ReadToEnd();
            }
            body = body.Replace("{Name}", model.Name = string.IsNullOrEmpty(model.Name) ? (model.FirstName + " " + model.LastName) : model.Name);

            if (model.Age > 0)
            {
                body = body.Replace("{Age}", model.Age.ToString());
            }
            if (model.Sex > 0)
            {
                body = body.Replace("{Sex}", model.Sex == 1 ? "Male" : "Female");
            }
            if (model.BookingDate != null)
            {
                body = body.Replace("{BookingDate}", model.BookingDate.ToString());
            }

            body = body.Replace("{Email}", model.Email);
            body = body.Replace("{Mobile}", model.Mobile ?? model.Phone);
            body = body.Replace("{Message}", model.Message);
            body = body.Replace("{Subject}", model.Subject);
            body = body.Replace("{Other}", otherDetails);
            var C = GetCompanyDetails(1);

            body = body.Replace("{Company}", C.Name);
            body = body.Replace("{Logo}", C.LogoUrl);

            EmailServiceDTO email = new EmailServiceDTO();

            email.ToEmail      = model.Email;
            email.Status       = (int)AspectEnums.EmailStatus.Pending;
            email.Body         = body;
            email.Priority     = 2;
            email.IsAttachment = false;
            email.Subject      = model.Subject;
            return(SendEmail(email));
        }
コード例 #15
0
ファイル: EmailHelper.cs プロジェクト: accuit/IqHealth
        public static int PrepareAndSendStudentEnquiryEmail(OnlineEnquiry model)
        {
            string body = string.Empty;

            using (StreamReader reader = new StreamReader(HttpContext.Current.Server.MapPath("~/Helpers/EmailTemplates/Student_Enquiry.html")))
            {
                body = reader.ReadToEnd();
            }

            body = body.Replace("{Name}", model.Name);
            body = body.Replace("{Email}", model.Email);
            body = body.Replace("{Mobile}", model.Phone);

            EmailServiceDTO email = new EmailServiceDTO();

            email.ToEmail      = model.Email;
            email.Status       = (int)AspectEnums.EmailStatus.Pending;
            email.Body         = body;
            email.Subject      = "Student enquiry received.";
            email.Priority     = 2;
            email.IsAttachment = false;
            return(SendEmail(email));
        }
コード例 #16
0
ファイル: HomeController.cs プロジェクト: accuit/BaseProject
        public ActionResult Contact(EmailServiceDTO email)
        {
            try
            {
                int templateCode          = (int)AspectEnums.EmailTemplateCode.ContactUsReply; // DreamWedds Contact Us Reply
                TemplateMasterBO template = new TemplateMasterBO();
                template = SystemBusinessInstance.GetTemplateData(0, templateCode);

                email.TemplateID   = template.TemplateID;
                email.Body         = template.TemplateContent;
                email.CreatedDate  = DateTime.Now;
                email.IsHtml       = true;
                email.Priority     = 2;
                email.IsAttachment = false;
                try
                {
                    EmailNotificationService eNotification = new EmailNotificationService();
                    eNotification.SendEmailNotification(email, template);
                    ViewBag.IsSuccess = true;
                    return(View());
                }
                catch (DbEntityValidationException ex)
                {
                    ViewBag.IsFail = true;
                    var newException = new FormattedDbEntityValidationException(ex);
                }
                catch (Exception ex)
                {
                    ViewBag.IsFail = true;
                }
                return(View(email));
            }
            catch
            {
                return(RedirectToAction("Index", "Error"));
            }
        }
コード例 #17
0
        /// <summary>
        /// Method to send email
        /// </summary>
        /// <param name="mail">mail details</param>
        /// <param name="setting">smtp server details</param>
        private void SendEmail(EmailServiceDTO mail, SMTPServer setting)
        {
            AspectEnums.EmailStatus mailStatus = AspectEnums.EmailStatus.None;
            SMTPServerDTO           smtpDetail = new SMTPServerDTO();
            Mapper mapper = new Mapper();

            mapper.CreateMap <SMTPServer, SMTPServerDTO>();
            mapper.Map(setting, smtpDetail);
            string remarks = string.Empty;
            //call mathod to send email
            bool isSent = MailingEngine.SendEmail(mail, smtpDetail);

            if (isSent)
            {
                mailStatus = AspectEnums.EmailStatus.Delivered;
                remarks    = "Success";
            }
            else
            {
                mailStatus = AspectEnums.EmailStatus.Failed;
                remarks    = "Failure";
            }
            SystemRepository.UpdateEmailServiceStatus(mail.EmailServiceID, (int)mailStatus, remarks);
        }
コード例 #18
0
        public void SendEmail(EmailServiceDTO emailModel, string ccAddress)
        {
            string fromPass = "";

            try
            {
                MailMessage message    = new MailMessage();
                SmtpClient  smtpClient = new SmtpClient();

                if (isDebugMode)
                {
                    emailModel.Subject     = "[DEBUG MODE] Email To : " + emailModel.FromName + ". | Subject: " + emailModel.Subject;
                    emailModel.ToEmail     = ConfigurationManager.AppSettings["DbugToEmail"].ToString();
                    emailModel.FromEmail   = ConfigurationManager.AppSettings["DbugFromEmail"].ToString();
                    emailModel.FromName    = ConfigurationManager.AppSettings["DebugFromName"].ToString();
                    fromPass               = ConfigurationManager.AppSettings["DbugFromPass"];
                    smtpClient.Host        = ConfigurationManager.AppSettings["DbugSMTPHost"];                  //"relay-hosting.secureserver.net";   //-- Donot change.
                    smtpClient.Port        = Convert.ToInt32(ConfigurationManager.AppSettings["DbugSMTPPort"]); // 587; //--- Donot change
                    smtpClient.EnableSsl   = true;
                    smtpClient.Credentials = new System.Net.NetworkCredential(emailModel.FromEmail, fromPass);
                    message.To.Add(emailModel.ToEmail);
                }
                else
                {
                    if (ccAddress != "")
                    {
                        message.CC.Add(ccAddress);
                    }
                    emailModel.FromEmail = ConfigurationManager.AppSettings["FromEmail"].ToString();
                    emailModel.FromName  = ConfigurationManager.AppSettings["FromName"].ToString();
                    smtpClient.Host      = ConfigurationManager.AppSettings["SMTPHost"];
                    message.To.Add(emailModel.FromEmail);
                }

                message.BodyEncoding = Encoding.UTF8;
                message.From         = new System.Net.Mail.MailAddress(emailModel.FromEmail, "The DreamWedds");
                message.IsBodyHtml   = true;
                message.Body         = emailModel.Body;
                message.Subject      = emailModel.Subject;

                bool isInsert = EmailBusinessInstance.InsertEmailRecord(emailModel);// EmailBu.EmailServices.Add(emailModel);

                if (isInsert)
                {
                    smtpClient.Send(message);
                }

                ActivityLog.SetLog("Email sent to " + emailModel.FromEmail, LogLoc.DEBUG);
                message.Dispose();
            }
            catch (DbEntityValidationException ex)
            {
                var newException = new FormattedDbEntityValidationException(ex);
                ActivityLog.SetLog("Email failed.", LogLoc.DEBUG);
                throw newException;
            }
            catch (Exception ex)
            {
                ActivityLog.SetLog("Email failed.", LogLoc.DEBUG);
                throw ex;
            }
        }
コード例 #19
0
        private string PrepareEmailContent(EmailServiceDTO model, TemplateMasterBO Template)
        {
            var    MergeFields        = SystemBusinessInstance.GetTemplateMergeFields(Template.TemplateID);
            string emailContent       = model.Body;
            string path               = ConfigurationManager.AppSettings["WeddingTemplatePath"].ToString();
            string welcomeRegisterUrl = string.Empty;

            if (isDebugMode)
            {
                welcomeRegisterUrl = ConfigurationManager.AppSettings["DebugWelcomeLoginURL"].ToString();
            }
            else
            {
                welcomeRegisterUrl = ConfigurationManager.AppSettings["WelcomeLoginURL"].ToString();
            }
            foreach (var field in MergeFields)
            {
                if (field.SRC_FIELD == "{{IDENTIFIER}}")
                {
                    emailContent = FindReplace(emailContent, "{{IDENTIFIER}}", welcomeRegisterUrl + Template.UrlIdentifier);
                }

                else if (field.SRC_FIELD == "{{TONAME}}")
                {
                    emailContent = FindReplace(emailContent, field.SRC_FIELD, model.ToName);
                }

                else if (field.SRC_FIELD == "{{PURCHASE_DATE}}")
                {
                    emailContent = FindReplace(emailContent, field.SRC_FIELD, DateTime.Now.ToShortDateString());
                }

                else if (field.SRC_FIELD == "{{TEMPLATENAME}}")
                {
                    emailContent = FindReplace(emailContent, field.SRC_FIELD, Template.TemplateName);
                }

                else if (field.SRC_FIELD == "{{TEMPLATEPREVIEWIMAGE}}")
                {
                    emailContent = FindReplace(emailContent, field.SRC_FIELD, path + Template.TemplateName + "/images/ScreenShots/1.png");
                }

                else if (field.SRC_FIELD == "{{DEMO_URL}}")
                {
                    emailContent = FindReplace(emailContent, field.SRC_FIELD, path + Template.TemplateName + "/index.html");
                }

                else if (field.SRC_FIELD == "{{PRICE}}")
                {
                    if (Template.IsTrial)
                    {
                        emailContent = FindReplace(emailContent, field.SRC_FIELD, "TRIAL");
                    }
                    else
                    {
                        emailContent = FindReplace(emailContent, field.SRC_FIELD, "INR " + Template.COST.ToString());
                    }
                }

                else if (field.SRC_FIELD == "{{ABOUT_TEMPLATE}}")
                {
                    emailContent = FindReplace(emailContent, field.SRC_FIELD, Template.AboutTemplate);
                }
            }
            model.Body = emailContent;
            return(emailContent);
        }
コード例 #20
0
        private bool SendOTPAndEmail(int UserId)
        {
            bool IsSuccess = false;

            #region Prepare OTP Data

            string UniqueString = AppUtil.GetUniqueGuidString();
            string OTPString    = AppUtil.GetUniqueRandomNumber(100000, 999999); // Generate a Six Digit OTP
            OTPBO  objOTP       = new OTPBO()
            {
                GUID = UniqueString, OTP = OTPString, CreatedDate = DateTime.Now, UserID = UserId, Attempts = 0
            };

            #endregion
            try
            {
                if (SecurityBusinessInstance.SaveOTP(objOTP))
                {
                    #region Send Email Servie and OTP
                    //string hostName = AppUtil.GetAppSettings(AspectEnums.ConfigKeys.HostName);
                    string resetUrl         = AppUtil.GetAppSettings(AspectEnums.ConfigKeys.ForgotPasswordURL);
                    string PasswordResetURL = resetUrl + UniqueString;
                    //string PasswordResetURL = Request.Url.AbsoluteUri.Split('/')[0] + Request.Url.AbsoluteUri.Split('/')[1]  + resetUrl + "?id=" + UniqueString;
                    EmailNotificationService eNotification = new EmailNotificationService();
                    var userProfile = UserBusinessInstance.DisplayUserProfile(UserId); // empBusinessInstance.DisplayEmpProfile(EmpId);
                    TemplateMasterBO            objEmailTemplate = EmailBusinessInstance.GetEmailTemplate((int)AspectEnums.EmailTemplateCode.ResetPassword);
                    List <TemplateMergeFieldBO> mergeFields      = EmailBusinessInstance.GetEmailMergeFields(objEmailTemplate.TemplateID);
                    foreach (var field in mergeFields)
                    {
                        if (field.SRC_FIELD == "{{PASSWORDRESETURL}}")
                        {
                            objEmailTemplate.TemplateContent = eNotification.FindReplace(objEmailTemplate.TemplateContent, "{{PASSWORDRESETURL}}", PasswordResetURL);
                        }

                        else if (field.SRC_FIELD == "{{TONAME}}")
                        {
                            objEmailTemplate.TemplateContent = eNotification.FindReplace(objEmailTemplate.TemplateContent, field.SRC_FIELD, userProfile.FirstName + " " + userProfile.LastName);
                        }
                    }
                    objEmailTemplate.TemplateContent = eNotification.FindReplace(objEmailTemplate.TemplateContent, "{{COMPANY}}", AppUtil.GetAppSettings(AspectEnums.ConfigKeys.CompanyName));


                    EmailServiceDTO emailService = new EmailServiceDTO();
                    emailService.Priority     = 1;
                    emailService.CreatedBy    = userProfile.UserID;
                    emailService.IsHtml       = true;
                    emailService.ToName       = userProfile.FirstName + " " + userProfile.LastName;
                    emailService.Body         = objEmailTemplate.TemplateContent;
                    emailService.Status       = (int)AspectEnums.EmailStatus.Pending;
                    emailService.ToEmail      = userProfile.Email;
                    emailService.FromName     = AppUtil.GetAppSettings(AspectEnums.ConfigKeys.FromName);
                    emailService.FromEmail    = AppUtil.GetAppSettings(AspectEnums.ConfigKeys.FromEmail);
                    emailService.Subject      = eNotification.FindReplace(objEmailTemplate.TemplateSubject, "{{COMPANY}}", AppUtil.GetAppSettings(AspectEnums.ConfigKeys.CompanyName));
                    emailService.IsAttachment = false;
                    emailService.TemplateID   = objEmailTemplate.TemplateID;
                    emailBusinessInstance.InsertEmailRecord(emailService);

                    eNotification.SendEmailNotification(emailService, objEmailTemplate);
                    IsSuccess = true;

                    #endregion
                }
            }
            catch (Exception ex)
            {
                IsSuccess = false;
            }


            return(IsSuccess);
        }
コード例 #21
0
ファイル: MailingEngine.cs プロジェクト: accuit/BaseProject
        /// <summary>
        ///
        /// </summary>
        /// <param name="mail">mail need to be sent</param>
        /// <param name="smtpSettings">smtp settings</param>
        /// <returns>TRUE if the email sent successfully, FALSE otherwise</returns>
        public bool SendEmail(EmailServiceDTO mail, SMTPServerDTO smtpSettings)
        {
            bool isSuccess = false;

            try
            {
                // setup email header
                MailMessage mailMessage = new MailMessage();
                // Set the message sender
                // sets the from address for this e-mail message.
                mailMessage.From = new MailAddress(smtpSettings.FromEmail, smtpSettings.FromName);
                // Sets the address collection that contains the recipients of this e-mail message.
                ManageMailMessageAddress(mail.ToEmail, mail.ToName, mailMessage, MailAddressType.ToAddress);
                ManageMailMessageAddress(mail.CcEmail, string.Empty, mailMessage, MailAddressType.CcAddress);
                ManageMailMessageAddress(mail.BccEmail, string.Empty, mailMessage, MailAddressType.BccAddress);
                // sets the message subject.
                mailMessage.Subject = mail.Subject;
                // sets the message body.
                mailMessage.Body = mail.Body;
                // sets a value indicating whether the mail message body is in Html.
                // if this is false then ContentType of the Body content is "text/plain".
                mailMessage.IsBodyHtml   = mail.IsHtml;
                mailMessage.BodyEncoding = System.Text.Encoding.UTF8;
                // add all the file attachments if we have any
                if (mail.IsAttachment && !String.IsNullOrEmpty(mail.AttachmentFileName))
                {
                    string[] files = mail.AttachmentFileName.Split(';');
                    foreach (string attachment in files)
                    {
                        string reportFileLocation = AppDomain.CurrentDomain.BaseDirectory + "\\" + AppUtil.GetAppSettings(AspectEnums.ConfigKeys.ReportFileFolder);
                        ActivityLog.SetLog(reportFileLocation + " - " + AppVariables.AppLogTraceCategoryName.EmailListener, LogLoc.DEBUG);
                        reportFileLocation = String.Format(@"{0}\{1}", reportFileLocation, attachment);
                        if (File.Exists(reportFileLocation))
                        {
                            mailMessage.Attachments.Add(new Attachment(reportFileLocation));
                        }
                    }
                }

                // SmtpClient Class Allows applications to send e-mail by using the Simple Mail Transfer Protocol (SMTP).
                SmtpClient smtpClient = new SmtpClient(smtpSettings.ServerName, Convert.ToInt32(smtpSettings.PortNumber));

                //Specifies how email messages are delivered. Here Email is sent through the network to an SMTP server.
                smtpClient.Credentials = new System.Net.NetworkCredential(smtpSettings.UserName, smtpSettings.Password);
                smtpClient.Port        = Convert.ToInt32(smtpSettings.PortNumber);
                smtpClient.Host        = smtpSettings.ServerName;
                smtpClient.EnableSsl   = smtpSettings.IsSSL;

                //Let's send it
                smtpClient.Send(mailMessage);
                isSuccess = true;
                // Do cleanup
                mailMessage.Dispose();
                smtpClient = null;
            }
            catch (Exception ex)
            {
                string response = String.Format("Email Failure for {0}, {1}", mail.ToEmail, ex.Message);
                isSuccess = false;
                ActivityLog.SetLog(response + " - " + AppVariables.AppLogTraceCategoryName.EmailListener, LogLoc.ERROR);
                if (ex.InnerException != null)
                {
                    ActivityLog.SetLog(ex.InnerException.ToString() + " - " + AppVariables.AppLogTraceCategoryName.EmailListener, LogLoc.ERROR);
                }
            }

            return(isSuccess);
        }
コード例 #22
0
ファイル: EmailHelper.cs プロジェクト: accuit/IqHealth
        public int SendEmail(EmailServiceDTO email)
        {
            string fromPass = string.Empty;

            ActivityLog.SetLog("[STARTED] SendEmail", LogLoc.INFO);
            MailMessage message     = new MailMessage();
            SmtpClient  smtpClient  = new SmtpClient();
            bool        isDebugMode = ConfigurationManager.AppSettings["IsDebugMode"] == "Y" ? true : false;

            message.Subject = string.IsNullOrEmpty(email.Subject) ? ConfigurationManager.AppSettings["Subject"].ToString() : email.Subject;
            email.BccEmail  = ConfigurationManager.AppSettings["BCCAddress"].ToString();
            email.CcEmail   = ConfigurationManager.AppSettings["CCAddress"].ToString();

            try
            {
                if (isDebugMode)
                {
                    message.To.Add(ConfigurationManager.AppSettings["DbugToEmail"].ToString());
                    email.FromEmail      = ConfigurationManager.AppSettings["DbugFromEmail"].ToString();
                    smtpClient.EnableSsl = ConfigurationManager.AppSettings["DbugIsSSL"].ToString() == "Y" ? true : false;
                    fromPass             = ConfigurationManager.AppSettings["DbugFromPass"];
                    smtpClient.Host      = ConfigurationManager.AppSettings["DbugSMTPHost"];                  //"relay-hosting.secureserver.net";   //-- Donot change.
                    smtpClient.Port      = Convert.ToInt32(ConfigurationManager.AppSettings["DbugSMTPPort"]); // 587; //--- Donot change
                    message.Subject      = "[Debug Mode ON] - " + message.Subject;
                }
                else
                {
                    smtpClient.EnableSsl = ConfigurationManager.AppSettings["IsSSL"].ToString() == "Y" ? true : false;
                    email.FromName       = ConfigurationManager.AppSettings["FromName"].ToString();
                    email.FromEmail      = ConfigurationManager.AppSettings["FromEmail"].ToString();
                    fromPass             = ConfigurationManager.AppSettings["Password"].ToString();
                    smtpClient.Port      = Convert.ToInt32(ConfigurationManager.AppSettings["SMTPPort"]);
                    smtpClient.Host      = ConfigurationManager.AppSettings["SMTPHost"].ToString();
                    message.To.Add(email.ToEmail);
                }
                ActivityLog.SetLog("Sending Email to : " + message.To + " from account " + email.FromEmail + " having host and port: " + smtpClient.Host + " & " + smtpClient.Port, LogLoc.INFO);
                smtpClient.Credentials = new NetworkCredential(email.FromEmail, fromPass);
                message.BodyEncoding   = Encoding.UTF8;
                message.From           = new MailAddress(email.FromEmail, email.FromName);
                message.IsBodyHtml     = true;
                message.Body           = email.Body;
                message.Bcc.Add(email.BccEmail);
                if (email.CcEmail != string.Empty)
                {
                    message.CC.Add(email.CcEmail);
                }
                smtpClient.Send(message);
                message.Dispose();
                ActivityLog.SetLog("[SUCCESS] SendEmail", LogLoc.INFO);
                return((int)AspectEnums.EmailStatus.Sent);
            }
            catch (Exception ex)
            {
                ActivityLog.SetLog("[FAILURE] Sending Email " + ex.Message.ToString() + ex.InnerException.ToString(), LogLoc.ERROR);
                return((int)AspectEnums.EmailStatus.Failed);
            }
            finally
            {
                message.Dispose();
                smtpClient.Dispose();
                ActivityLog.SetLog("[FINISHED] SendEmail", LogLoc.INFO);
            }
        }
コード例 #23
0
        public ActionResult Purchase(UserPurchaseViewModel model)
        {
            try
            {
                ViewBag.ShowMessage = true;
                ViewBag.IsTrial     = false;


                if (model.subscriptions.SubscriptionType == (int)AspectEnums.SubscriptionType.Trial)
                {
                    ViewBag.IsTrial        = true;
                    model.template.IsTrial = true;
                }

                #region Create NEW USER - SUBMIT USERMASTER

                bool isUserExist = UserBusinessInstance.GetUserByLoginName(model.user.Email).UserID > 0 ? true : false;

                if (isUserExist)
                {
                    ViewBag.Message   = "This email address already exist.";
                    ViewBag.IsSuccess = false;
                    return(View(model));
                }

                model.user.CreatedBy     = 1;
                model.user.CreatedDate   = DateTime.Now;
                model.user.AccountStatus = (int)AspectEnums.UserAccountStatus.Pending;
                model.user.isActive      = true;
                model.user.isDeleted     = false;
                model.user.IsEmployee    = false;
                model.user.LoginName     = model.user.Email;
                model.user.Password      = "******";
                string sessionID = HttpContext.Session.SessionID.ToString();
                int    newUserID = UserBusinessInstance.SubmitNewEmployee(model.user, sessionID);
                #endregion

                #region CREATE NEW ORDER - SUBMIT ORDERMASTER
                model.order.UserID = newUserID;
                decimal cost     = 0;
                int     Discount = Convert.ToInt32(ConfigurationManager.AppSettings["Discount"]);
                if (model.subscriptions.SubscriptionType == (int)AspectEnums.SubscriptionType.Trial)
                {
                    cost = 0;
                    model.subscriptions.EndDate = DateTime.Now.AddDays(10);
                }
                if (model.subscriptions.SubscriptionTypeList == AspectEnums.SubscriptionType.Annual)
                {
                    cost = Convert.ToDecimal(model.template.COST);
                    model.subscriptions.EndDate = DateTime.Now.AddMonths(12);
                }
                else if (model.subscriptions.SubscriptionTypeList == AspectEnums.SubscriptionType.HalfYearly)
                {
                    cost = Convert.ToDecimal(model.template.COST * .60);
                    model.subscriptions.EndDate = DateTime.Now.AddMonths(06);
                }
                else if (model.subscriptions.SubscriptionTypeList == AspectEnums.SubscriptionType.Quarterly)
                {
                    cost = Convert.ToDecimal(model.template.COST * 0.30);
                    model.subscriptions.EndDate = DateTime.Now.AddMonths(3);
                }

                model.order.Discount = Discount;
                model.order.Amount   = cost - (cost * (Discount / 100));
                model.template.COST  = Convert.ToInt32(model.order.Amount);
                int OrderID = SystemBusinessInstance.SubmitNewOrder(model.order);
                #endregion

                #region CREATE NEW SUBSCRIPTION - SUBMIT USERWEDDINGSUBSCRIPTION
                model.subscriptions.UserId    = newUserID;
                model.subscriptions.InvoiceNo = OrderID;


                int SubscriptionID = SystemBusinessInstance.SubmitUserSubscription(model.subscriptions);
                #endregion

                if (newUserID > 1)
                {
                    EmailServiceDTO  email         = new EmailServiceDTO();
                    TemplateMasterBO emailTemplate = new TemplateMasterBO();
                    int emailTemplateCode          = (int)AspectEnums.EmailTemplateCode.WelcomeEmail;

                    if (DreamWeddsData.DreamWeddsWeb == null)
                    {
                        emailTemplate = SystemBusinessInstance.GetTemplateData(0, emailTemplateCode);
                    }
                    else
                    {
                        emailTemplate = DreamWeddsData.DreamWeddsWeb.templateMasters.Where(x => x.TemplateCode == emailTemplateCode).FirstOrDefault();
                    }

                    model.template.UrlIdentifier = EncryptionEngine.Encrypt(newUserID.ToString() + "," + model.user.FirstName + "," + model.user.LastName + "," + model.user.LoginName + "," + model.template.TemplateName);
                    //string encodedValue = HttpUtility.UrlEncode(model.template.UrlIdentifier);
                    string decrypt = EncryptionEngine.Decrypt(model.template.UrlIdentifier);
                    email.ToName         = model.user.FirstName + " " + model.user.LastName;
                    email.Subject        = emailTemplate.TemplateSubject;
                    email.ToEmail        = model.user.Email;
                    email.Status         = (int)AspectEnums.EmailStatus.Pending;
                    email.Message        = emailTemplate.TemplateName;
                    email.Phone          = model.user.Phone;
                    email.Mobile         = model.user.Mobile;
                    email.IsCustomerCopy = false;
                    email.TemplateID     = emailTemplate.TemplateID;
                    email.Body           = emailTemplate.TemplateContent;
                    email.CreatedDate    = DateTime.Now;
                    email.CreatedBy      = newUserID;
                    email.IsHtml         = true;
                    email.Priority       = 2;
                    email.IsAttachment   = false;
                    email.Body           = PrepareEmailContent(email, emailTemplate);
                    EmailNotificationService eNotification = new EmailNotificationService();
                    eNotification.SendEmailNotification(email, model.template);
                    ViewBag.IsSuccess = true;
                }
            }
            catch (DbEntityValidationException ex)
            {
                ViewBag.IsSuccess = false;
                var newException = new FormattedDbEntityValidationException(ex);
                ViewBag.Message = "Error: " + ex;
            }
            catch (Exception e)
            {
                ViewBag.IsSuccess = false;
                ViewBag.Message   = "Error: " + e;
            }
            return(View(model));
        }