Example #1
0
        /// <summary>
        /// Gets the communication provider details.
        /// </summary>
        /// <returns></returns>
        public JsonResult GetCommunicationProviderDetails()
        {
            GetServiceProviderRequest request = new GetServiceProviderRequest()
            {
                AccountId           = this.Identity.ToAccountID(),
                CommunicationTypeId = CommunicationType.Mail,
                MailType            = MailType.TransactionalEmail
            };
            GetServiceProviderResponse response = serviceProviderService.GetAccountServiceProviders(request);

            return(Json(response.ServiceProviderViewModel, JsonRequestBehavior.AllowGet));
        }
Example #2
0
        private bool EmailSend(string subject, string emailBody, string toEmail, int accountId, int userId)
        {
            Logger.Current.Informational("In Email Send Method:  " + toEmail);
            var success     = false;
            var mailService = new MailService();
            ServiceProviderViewModel serviceProviderViewModel = communicationService.GetAccountServiceProviders(new GetServiceProviderRequest()
            {
                CommunicationTypeId = CommunicationType.Mail,
                AccountId           = accountId,
                MailType            = MailType.TransactionalEmail
            }).ServiceProviderViewModel.FirstOrDefault();
            MailRegistrationDb mailRegistration = mailService.GetMailRegistrationDetails(serviceProviderViewModel.LoginToken);

            LandmarkIT.Enterprise.CommunicationManager.Requests.SendMailRequest sendMailRequest = new LandmarkIT.Enterprise.CommunicationManager.Requests.SendMailRequest();
            var senderEmail = serviceProviderRepository.GetServiceProviderEmail(serviceProviderViewModel.CommunicationLogID);

            sendMailRequest.TokenGuid     = mailRegistration.Guid;
            sendMailRequest.RequestGuid   = Guid.NewGuid();
            sendMailRequest.IsBodyHtml    = true;
            sendMailRequest.From          = senderEmail.EmailId;
            sendMailRequest.Subject       = subject;
            sendMailRequest.ScheduledTime = DateTime.Now.ToUniversalTime().AddSeconds(5);
            sendMailRequest.Body          = emailBody;
            sendMailRequest.DisplayName   = mailRegistration.Name;
            sendMailRequest.To            = new List <string>()
            {
                toEmail
            };
            sendMailRequest.CategoryID = (short)EmailNotificationsCategory.InvalidCouponReport;
            sendMailRequest.AccountID  = accountId;
            try
            {
                mailService.Send(sendMailRequest);
                success = true;
            }
            catch (Exception ex)
            {
                ex.Data.Clear();
                ex.Data.Add("AccountId", accountId);
                ex.Data.Add("UserID", userId);
                ex.Data.Add("TO Email", toEmail);
                Logger.Current.Error("Error while sending email through transaction provider ", ex);
                success = false;
            }
            return(success);
        }