コード例 #1
0
        private Boolean SendEmail(AspNetUser user, string message, string DestinationEmail, string channelId, string SenderEmail, LanguageCode culture, string RecipientName, string SenderName, List <email_attachment> attachmentList)
        {
            EmailProvider client = new EmailProvider(channelId);

            Dictionary <string, string> emailContents = new Dictionary <string, string>();

            emailContents.Add("TABLEBODY", message);
            emailContents.Add("from", SenderEmail);
            emailContents.Add("NAME", RecipientName);
            emailContents.Add("MEMBER", SenderName);
            //emailContents.Add("cc", SenderEmail);
            bool sent = false;

            if (attachmentList != null && attachmentList.ToList().Count > 0)
            {
                sent = client.Send(DestinationEmail, emailContents, client.GetTemplateType("CustomerOrder", culture), attachmentList);
            }
            else
            {
                sent = client.Send(DestinationEmail, emailContents, client.GetTemplateType("CustomerOrder", culture));
            }

            Logger.Info(String.Format("Sent {0}", sent));
            Logger.Info(String.Format("Email Sent to {0} with Email {1}", RecipientName, DestinationEmail));
            return(true);
        }
コード例 #2
0
        private void SendOrderToPrimaryEmail(AspNetUser user, string subject, string body, int caseId, string supplier, List <email_attachment> attachmentList, string channelId, int customerId, int deptId, ICollection <CustomerOrderAttachment> customer_Order_Attachment)
        {
            try
            {
                Logger.Info(String.Format("Email Sending to {0} with PrimaryEmail {1}", user.FirstName, user.Email));
                EmailProvider client = new EmailProvider(channelId);

                var cwaUrl = ConfigurationManager.AppSettings["ChannelOneLoginUrl"] + channelId;

                if (channelId == "12")
                {
                    cwaUrl = ConfigurationManager.AppSettings["ChannelTwoLoginUrl"] + channelId;
                }

                var emailContents = new Dictionary <string, string>();
                emailContents.Add("SUPPLIER", supplier);
                emailContents.Add("NAME", user.FirstName + " " + user.LastName);
                emailContents.Add("URL", cwaUrl);
                emailContents.Add("TABLEBODY", body);

                var type = client.GetTemplateType("OfferRequestOrder", user.LanguageCode, Convert.ToInt32(channelId));
                var slug = client.GetTemplateName(type);

                bool sent = false;
                if (attachmentList != null && attachmentList.ToList().Count > 0)
                {
                    sent = client.Send(user.Email, emailContents, type, attachmentList);
                }
                else
                {
                    sent = client.Send(user.Email, emailContents, type);
                }

                var mail = new MailMessage()
                {
                    CustomerId      = customerId,
                    DepartmentId    = deptId,
                    CauseTrackingId = caseId,
                    Kind            = MessageKind.Received,
                    ToAddress       = user.Email,
                    UserId          = user.Id,
                    HideFromUser    = true,
                    Tracking        = EntityTracker.StartTracking(ServiceId) // not directly by user, disputable
                };

                _mailMessageService.SaveMailMessage(mail, slug, channelId, emailContents);
                if (attachmentList != null && attachmentList.ToList().Count > 0)
                {
                    SaveCustomerAttachmentsInMailMessage(customer_Order_Attachment, mail.MessageId);
                }

                Logger.Info($"Email Sent to {user.FirstName} with PrimaryEmail {user.Email}");
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
            }
        }