Exemple #1
0
        public static string ToXPriority(this EmailImportance importance)
        {
            switch (importance)
            {
            case EmailImportance.Normal:
                return("3");

            case EmailImportance.High:
                return("1");

            case EmailImportance.Low:
                return("5");
            }

            return(null);
        }
Exemple #2
0
 /// <summary>
 /// Returns <paramref name="importance"/> identifier.
 /// </summary>
 /// <param name="importance">Email message importance.</param>
 /// <returns>Message importance identifier.</returns>
 private Guid GetActivityPriority(EmailImportance importance)
 {
     return(EmailPriorityConverter.GetActivityPriority((int)importance));
 }
 /// <summary>
 /// Creates valid domain object
 /// </summary>
 public EmailMessage(EmailSender sender, string subject, string body, bool isBodyHTML, string fromAddress, EmailImportance importance, MessageQueuePriority priority)
     : this(sender, subject, body, isBodyHTML, fromAddress)
 {
     Importance = importance;
     Priority = priority;
 }
        public static void SendMail(string subject, string body, string emailType, string sentBy, Dictionary <string, byte[]> attachments = null, EmailImportance importance = EmailImportance.Normal, List <string> to = null, List <string> cc = null, List <string> bcc = null, int?dataKey = null, string dataKeyColumn = "None")
        {
            EmailPayLoad emailPayLoad = new EmailPayLoad
            {
                application   = "Fuel Purchasing",
                emailType     = "FuelPurchasing",
                dataKey       = 1,
                dataKeyColumn = "OrderId",
                from          = "*****@*****.**",
                to            = to,
                cc            = cc,
                bcc           = bcc,
                //  emailIt = false,

                subject = subject,



                body = body,

                attachments = attachments,
                sentBy      = sentBy
            };
            var url     = ConfigurationManager.AppSettings["EmailMicroService"] + "http://emailms/api/EmailService/sendMail";
            var payload = JsonConvert.SerializeObject(emailPayLoad);

            HttpResponseMessage response = null;

            var request = new HttpRequestMessage(HttpMethod.Post, url)
            {
                Content = new StringContent(
                    payload,
                    Encoding.UTF8,
                    "application/json")
            };

            using (var client =
                       new HttpClient(new HttpClientHandler {
                UseDefaultCredentials = true
            }))
            {
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(
                    new MediaTypeWithQualityHeaderValue("application/json"));

                response = client.SendAsync(request).Result;
                if (!response.IsSuccessStatusCode)
                {
                    var stringdata = response.Content.ReadAsStringAsync();
                    throw new Exception(stringdata.Result);
                }
            }
        }