예제 #1
0
        private TemplatedPostmarkMessage BuildTemplatedMessage(long templateId, string testValue)
        {
            var message = new TemplatedPostmarkMessage
            {
                TemplateId    = templateId,
                TemplateModel = new { testKey = $"{testValue}" },
                From          = WRITE_TEST_SENDER_EMAIL_ADDRESS,
                To            = WRITE_TEST_SENDER_EMAIL_ADDRESS,
                Headers       = new HeaderCollection
                {
                    new MailHeader("X-Integration-Testing-Postmark-Type-Message", TESTING_DATE.ToString("o"))
                },
                Metadata = new Dictionary <string, string> {
                    { "test-key", "test-value" }, { "client-id", "42" }
                },
                Tag = "integration-testing"
            };

            var content = "{ \"name\" : \"data\", \"age\" : null }";

            message.Attachments.Add(new PostmarkMessageAttachment
            {
                ContentType = "application/json",
                Name        = "test.json",
                Content     = Convert.ToBase64String(Encoding.UTF8.GetBytes(content))
            });
            return(message);
        }
        public async Task notify(ArbitrageData T, string pEmail)
        {
            try
            {
                var message = new TemplatedPostmarkMessage
                {
                    From          = "*****@*****.**",
                    To            = pEmail,
                    TemplateAlias = "bitcoinArbitrage",
                    TemplateModel = new Dictionary <string, object> {
                        { "percent", Convert.ToString(T.PercentageProfitBeforeCost * 100) },
                        { "date", Convert.ToString(T.DateCaptured) },
                        { "krakenprice", Convert.ToString(T.KrakenXBTEUR) },
                        { "lunoprice", Convert.ToString(T.LunoXBTZAR) },
                        { "eurotozar", Convert.ToString(T.EURZAR) }
                    },
                };

                var client = new PostmarkClient("ba0d1e9f-0b0b-442f-a350-9504a5015caf");

                var response = await client.SendMessageAsync(message);

                if (response.Status != PostmarkStatus.Success)
                {
                    Console.WriteLine("Response was: " + response.Message);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Email fail: " + e.Message);
            }
        }
예제 #3
0
        public async Task SendCouldNotFindUser(string username)
        {
            var message = new TemplatedPostmarkMessage
            {
                To            = username,
                From          = "*****@*****.**",
                TemplateId    = 15914912,
                TemplateModel = new Dictionary <string, object>
                {
                    { "username", username }
                }
            };

            var client     = new PostmarkClient("20222232-ba77-4976-b1c5-921816baa7e2");
            var sendResult = await client.SendMessageAsync(message);

            if (sendResult.Status == PostmarkStatus.Success)
            {
                Console.WriteLine(sendResult.Status);
            }
            else
            {
                Console.WriteLine(sendResult.Status);
            }
        }
예제 #4
0
        public async Task SendResetPasswordEmail(string username, string resetToken)
        {
            var message = new TemplatedPostmarkMessage
            {
                To            = username,
                From          = "*****@*****.**",
                TemplateId    = 15914723,
                TemplateModel = new Dictionary <string, object>
                {
                    { "username", username },
                    //   { "action_url",  "http://farmboek.dankospark.co.za/resetpassword/"+ username + "/" + resetToken}
                    { "action_url", "http://localhost:4200/resetpassword/" + username + "/" + resetToken.Replace('/', '_') }
                }
            };

            var client     = new PostmarkClient("20222232-ba77-4976-b1c5-921816baa7e2");
            var sendResult = await client.SendMessageAsync(message);

            if (sendResult.Status == PostmarkStatus.Success)
            {
                Console.WriteLine(sendResult.Status);
            }
            else
            {
                Console.WriteLine(sendResult.Status);
            }
        }
예제 #5
0
        public async Task SendNotifyAdmin(string type, string productorremedy, string name, string lastname, string idnumber, string cell, string email, string brand, string action_url)
        {
            var message = new TemplatedPostmarkMessage
            {
                To            = "*****@*****.**",
                From          = "*****@*****.**",
                TemplateId    = 16196502,
                TemplateModel = new Dictionary <string, object>
                {
                    { "name", name },
                    { "lastname", lastname },
                    { "type", type },
                    { "productorremedy", productorremedy },
                    { "idnumber", idnumber },
                    { "brand", brand },
                    { "cell", cell },
                    { "email", email },
                    { "action_url", action_url }
                }
            };

            var client     = new PostmarkClient("20222232-ba77-4976-b1c5-921816baa7e2");
            var sendResult = await client.SendMessageAsync(message);

            if (sendResult.Status == PostmarkStatus.Success)
            {
                Console.WriteLine(sendResult.Status);
            }
            else
            {
                Console.WriteLine(sendResult.Status);
            }
        }
예제 #6
0
        public void SendCancellationReciept(string name, string email, string endDate, string departmentName)
        {
            var message = new TemplatedPostmarkMessage
            {
                From          = FROM_EMAIL,
                To            = email,
                TemplateId    = Config.OutboundEmailServerConfig.PostmarkCancelRecieptTemplateId,
                TemplateModel = new Dictionary <string, object> {
                    { "action_url", $"{Config.SystemBehaviorConfig.ResgridBaseUrl}/User/Subscription" },
                    { "subscriptions_url", $"{Config.SystemBehaviorConfig.ResgridBaseUrl}/User/Subscription" },
                    { "feedback_url", LIVECHAT_URL },
                    { "help_url", HELP_URL },
                    { "trial_extension_url", $"{Config.SystemBehaviorConfig.ResgridBaseUrl}/User/Subscription" },
                    { "export_url", "" },
                    { "plans_url", $"{Config.SystemBehaviorConfig.ResgridBaseUrl}/Home/Pricing" },
                    { "close_account_url", HELP_URL },
                },
            };

            var client   = new PostmarkClient(Config.OutboundEmailServerConfig.PostmarkApiKey);
            var response = client.SendMessageAsync(message).Result;

            if (response.Status != PostmarkStatus.Success)
            {
                //Console.WriteLine("Response was: " + response.Message);
            }
        }
        //New Invoice Generated
        public async Task NewInvoiceGenerated(string invoiceNum, int stockId)
        {
            var message = new TemplatedPostmarkMessage
            {
                To            = "*****@*****.**",
                From          = EmailFrom,
                TemplateAlias = "newInvoice",
                TemplateModel = new Dictionary <string, object>
                {
                    { "invoiceNum", invoiceNum },
                    { "stockId", stockId },
                }
            };

            var client     = new PostmarkClient("ba4b7707-54c8-49d7-83d5-e215483fe37c");
            var sendResult = await client.SendMessageAsync(message);

            if (sendResult.Status == PostmarkStatus.Success)
            {
                Console.WriteLine(sendResult.Status);
            }
            else
            {
                Console.WriteLine(sendResult.Status);
            }
        }
예제 #8
0
        public async Task SendNotifyEnquireRemedy(ProductBaseDto T, string email)
        {
            var message = new TemplatedPostmarkMessage
            {
                To            = email,
                From          = "*****@*****.**",
                TemplateId    = 15937570,
                TemplateModel = new Dictionary <string, object>
                {
                    { "username", email },
                    { "remedyname", T.Name },
                    { "brand", dc.Brand.Where(o => o.BrandId == T.BrandId).First().Name },
                    { "registration", T.Registration },
                    { "formulation", T.Formulation },
                    { "concentration", T.Concentration },
                    { "active", dc.ProductActiveIngredient.Include(o => o.ActiveIngredient).Where(o => o.ProductBaseId == T.ProductBaseId).First().ActiveIngredient.Name },
                    { "enquiredURL", "http://farmboek.dankospark.co.za/details/brand/" + T.BrandId }
                }
            };

            var client     = new PostmarkClient("20222232-ba77-4976-b1c5-921816baa7e2");
            var sendResult = await client.SendMessageAsync(message);

            if (sendResult.Status == PostmarkStatus.Success)
            {
                Console.WriteLine(sendResult.Status);
            }
            else
            {
                Console.WriteLine(sendResult.Status);
            }
        }
예제 #9
0
        public void SendChargeFailed(string name, string email, string endDate, string departmentName, string planName)
        {
            // Example request
            var message = new TemplatedPostmarkMessage
            {
                From          = FROM_EMAIL,
                To            = email,
                TemplateId    = Config.OutboundEmailServerConfig.PostmarkChargeFailedTemplateId,
                TemplateModel = new Dictionary <string, object> {
                    { "plan_name", planName },
                    { "action_url", UPDATEBILLINGINFO_URL },
                    { "subscriptions_url", $"{Config.SystemBehaviorConfig.ResgridBaseUrl}/User/Subscription" },
                    { "feedback_url", LIVECHAT_URL },
                    { "help_url", HELP_URL },
                    { "trial_extension_url", $"{Config.SystemBehaviorConfig.ResgridBaseUrl}/User/Subscription" },
                    { "export_url", "" },
                    { "close_account_url", HELP_URL },
                },
            };

            var client = new PostmarkClient(Config.OutboundEmailServerConfig.PostmarkApiKey);

            try
            {
                PostmarkResponse response = client.SendMessageAsync(message).Result;

                if (response.Status != PostmarkStatus.Success)
                {
                    //Console.WriteLine("Response was: " + response.Message);
                }
            }
            catch (Exception) { }
        }
예제 #10
0
        public void SendInviteMail(string code, string departmentName, string email, string senderName, string senderEmail)
        {
            // Example request
            var message = new TemplatedPostmarkMessage
            {
                From          = FROM_EMAIL,
                To            = email,
                TemplateId    = Config.OutboundEmailServerConfig.PostmarkInviteTemplateId,
                TemplateModel = new Dictionary <string, object> {
                    { "invite_sender_name", senderName },
                    { "department_name", departmentName },
                    { "action_url", $"{Config.SystemBehaviorConfig.ResgridBaseUrl}/Account/CompleteInvite?inviteCode={code}" },
                    { "support_email", FROM_EMAIL },
                    { "live_chat_url", LIVECHAT_URL },
                    { "help_url", HELP_URL },
                    { "sender_email", senderEmail },
                    { "invite_sender_organization_name", departmentName },
                },
            };

            var client = new PostmarkClient(Config.OutboundEmailServerConfig.PostmarkApiKey);

            try
            {
                PostmarkResponse response = client.SendMessageAsync(message).Result;

                if (response.Status != PostmarkStatus.Success)
                {
                    //Console.WriteLine("Response was: " + response.Message);
                }
            }
            catch (Exception) { }
        }
예제 #11
0
        public async Task SendNotifyEnquireProblemAndService(string email, string brand, string entry, int id)
        {
            var message = new TemplatedPostmarkMessage
            {
                To            = email,
                From          = "*****@*****.**",
                TemplateId    = 15925178,
                TemplateModel = new Dictionary <string, object>
                {
                    { "name", email },
                    { "entryName", entry },
                    { "brandName", brand },
                    { "enquiredURL", "http://farmboek.dankospark.co.za/details/brand/" + id }
                }
            };

            var client     = new PostmarkClient("20222232-ba77-4976-b1c5-921816baa7e2");
            var sendResult = await client.SendMessageAsync(message);

            if (sendResult.Status == PostmarkStatus.Success)
            {
                Console.WriteLine(sendResult.Status);
            }
            else
            {
                Console.WriteLine(sendResult.Status);
            }
        }
        public async Task SendNewEmailAsync(string email)
        {
            var message = new TemplatedPostmarkMessage
            {
                To            = EmailFrom,
                From          = EmailFrom,
                TemplateAlias = "newEmail",
                TemplateModel = new Dictionary <string, object>
                {
                    { "email", email }
                }
            };

            var client     = new PostmarkClient("ba4b7707-54c8-49d7-83d5-e215483fe37c");
            var sendResult = await client.SendMessageAsync(message);

            if (sendResult.Status == PostmarkStatus.Success)
            {
                Console.WriteLine(sendResult.Status);
            }
            else
            {
                Console.WriteLine(sendResult.Status);
            }
        }
        public async Task EmailToClientAsync(EnquiryDto T, Vacation stock, Resort resort, Supplier supplier, UnitSizes unitSize)
        {
            var message = new TemplatedPostmarkMessage
            {
                To            = T.Email,
                From          = EmailFrom,
                TemplateId    = 20752183,
                TemplateModel = new Dictionary <string, object>
                {
                    { "name", T.Name },
                    { "resort", resort.Description },
                    { "date", stock.Arrival.Date.ToString("dd/MM/yyyy") },
                    { "nights", stock.Nights },
                    { "unitsize", unitSize.Description },
                    { "priceToPay", stock.Price2Pay },
                    { "link", resort.Link },
                    { "adults", T.Adults },
                    { "kids", T.Under12 },
                    { "note", T.Note }
                }
            };

            var client     = new PostmarkClient("ba4b7707-54c8-49d7-83d5-e215483fe37c");
            var sendResult = await client.SendMessageAsync(message);

            if (sendResult.Status == PostmarkStatus.Success)
            {
                Console.WriteLine(sendResult.Status);
            }
            else
            {
                Console.WriteLine(sendResult.Status);
            }
        }
        public async Task EmailToProviderAsync(EnquiryDto T, Vacation stock, Resort resort, Supplier supplier, UnitSizes unitSize)
        {
            var message = new TemplatedPostmarkMessage
            {
                To            = supplier.Email,
                From          = EmailFrom,
                TemplateId    = 13249489,
                TemplateModel = new Dictionary <string, object>
                {
                    { "provider", supplier.Description },
                    { "resort", resort.Description },
                    { "arrival", stock.Arrival.Date.ToString("dd/MM/yyyy") },
                    { "nights", stock.Nights },
                    { "unitSize", unitSize.Description },
                    { "product_name", "Holiday Booker" },
                    { "company_name", "Holiday Booker" }
                }
            };

            var client     = new PostmarkClient("ba4b7707-54c8-49d7-83d5-e215483fe37c");
            var sendResult = await client.SendMessageAsync(message);

            if (sendResult.Status == PostmarkStatus.Success)
            {
                Console.WriteLine(sendResult.Status);
            }
            else
            {
                Console.WriteLine(sendResult.Status);
            }
        }
예제 #15
0
        public async Task <bool> SendMessageMail(string email, string subject, string messageSubject, string messageBody, string senderEmail, string senderName, string sentOn, int messageId)
        {
            var templateModel = new Dictionary <string, object> {
                { "sender_name", senderName },
                { "title", subject },
                { "body", HtmlToTextHelper.ConvertHtml(messageBody) },
                //{ "attachment_details", new []{
                //new Dictionary<string,object> {
                //	{ "attachmnet_url", "attachmnet_url_Value" },
                //	{ "attachment_name", "attachment_name_Value" },
                //	{ "attachment_size", "attachment_size_Value" },
                //	{ "attachment_type", "attachment_type_Value" },
                //}
                //}
                //},

                { "action_url", $"https://resgrid.com/User/Messages/ViewMessage?messageId={messageId}" },
                { "timestamp", sentOn },
                { "commenter_name", senderName }
            };

            if (SystemBehaviorConfig.OutboundEmailType == OutboundEmailTypes.Postmark)
            {
                var message = new TemplatedPostmarkMessage
                {
                    From          = DONOTREPLY_EMAIL,
                    To            = email,
                    TemplateId    = Config.OutboundEmailServerConfig.PostmarkMessageTemplateId,
                    TemplateModel = templateModel,
                };

                var client = new PostmarkClient(Config.OutboundEmailServerConfig.PostmarkApiKey);
                try
                {
                    PostmarkResponse response = await client.SendMessageAsync(message);

                    if (response.Status != PostmarkStatus.Success)
                    {
                        return(false);
                    }

                    return(true);
                }
                catch (Exception) {     }
            }
            else
            {
                var template = Mustachio.Parser.Parse(GetTempate("Message.html"));
                var content  = template(templateModel);

                Email newEmail = new Email();
                newEmail.HtmlBody = content;
                newEmail.Sender   = FROM_EMAIL;
                newEmail.To.Add(email);

                return(await _emailSender.Send(newEmail));
            }

            return(false);
        }
예제 #16
0
        public void SendNewDepartmentLinkMail(string name, string departmentName, string data, string email, int departmentId)
        {
            // Example request
            var message = new TemplatedPostmarkMessage
            {
                From          = FROM_EMAIL,
                To            = email,
                TemplateId    = Config.OutboundEmailServerConfig.PostmarkNewDepLinkTemplateId,
                TemplateModel = new Dictionary <string, object> {
                    { "name", name },
                    { "action_url", $"{Config.SystemBehaviorConfig.ResgridBaseUrl}" },
                    { "login_url", $"{Config.SystemBehaviorConfig.ResgridBaseUrl}/Account/LogOn" },
                    { "department_name", departmentName },
                    { "data", data },
                    { "support_email", FROM_EMAIL },
                    { "live_chat_url", LIVECHAT_URL },
                    { "help_url", HELP_URL },
                },
            };

            var client = new PostmarkClient(Config.OutboundEmailServerConfig.PostmarkApiKey);

            try
            {
                PostmarkResponse response = client.SendMessageAsync(message).Result;

                if (response.Status != PostmarkStatus.Success)
                {
                    //Console.WriteLine("Response was: " + response.Message);
                }
            }
            catch (Exception) { }
        }
예제 #17
0
        public async Task <bool> SendWelcomeMail(string name, string departmentName, string userName, string password, string email, int departmentId)
        {
            var templateModel = new Dictionary <string, object> {
                { "name", name },
                { "action_url", $"{Config.SystemBehaviorConfig.ResgridBaseUrl}" },
                { "login_url", $"{Config.SystemBehaviorConfig.ResgridBaseUrl}/Account/LogOn" },
                { "department_id", departmentId },
                { "department_name", departmentName },
                { "username", userName },
                { "password", password },
                { "support_email", FROM_EMAIL },
                { "live_chat_url", LIVECHAT_URL },
                { "help_url", HELP_URL },
            };

            if (SystemBehaviorConfig.OutboundEmailType == OutboundEmailTypes.Postmark)
            {
                var message = new TemplatedPostmarkMessage
                {
                    From          = FROM_EMAIL,
                    To            = email,
                    TemplateId    = Config.OutboundEmailServerConfig.PostmarkWelcomeTemplateId,
                    TemplateModel = templateModel,
                };

                var client = new PostmarkClient(Config.OutboundEmailServerConfig.PostmarkApiKey);
                try
                {
                    PostmarkResponse response = await client.SendMessageAsync(message);

                    if (response.Status != PostmarkStatus.Success)
                    {
                        return(false);
                    }

                    return(true);
                }
                catch (Exception) { }
            }
            else
            {
                var template = Mustachio.Parser.Parse(GetTempate("Welcome.html"));
                var content  = template(templateModel);

                Email newEmail = new Email();
                newEmail.HtmlBody = content;
                newEmail.Sender   = FROM_EMAIL;
                newEmail.To.Add(email);

                return(await _emailSender.Send(newEmail));
            }

            return(false);
        }
예제 #18
0
        public async Task <bool> SendPasswordResetMail(string name, string password, string userName, string email, string departmentName)
        {
            var templateModel = new Dictionary <string, object> {
                { "name", name },
                { "department_Name", departmentName },
                { "login_url", LOGIN_URL },
                { "username", userName },
                { "password", password },
                { "support_url", LIVECHAT_URL },
                { "action_url", LOGIN_URL },
                { "operating_system", "" },
                { "browser_name", "" },
            };

            if (SystemBehaviorConfig.OutboundEmailType == OutboundEmailTypes.Postmark)
            {
                var message = new TemplatedPostmarkMessage
                {
                    From          = FROM_EMAIL,
                    To            = email,
                    TemplateId    = Config.OutboundEmailServerConfig.PostmarkResetPasswordTemplateId,
                    TemplateModel = templateModel,
                };

                var client = new PostmarkClient(Config.OutboundEmailServerConfig.PostmarkApiKey);
                try
                {
                    PostmarkResponse response = await client.SendMessageAsync(message);

                    if (response.Status != PostmarkStatus.Success)
                    {
                        return(false);
                    }

                    return(true);
                }
                catch (Exception) { }
            }
            else
            {
                var template = Mustachio.Parser.Parse(GetTempate("PasswordReset.html"));
                var content  = template(templateModel);

                Email newEmail = new Email();
                newEmail.HtmlBody = content;
                newEmail.Sender   = FROM_EMAIL;
                newEmail.To.Add(email);

                return(await _emailSender.Send(newEmail));
            }

            return(false);
        }
예제 #19
0
        public static async void Run([TimerTrigger("0 */20 * * * *")] TimerInfo myTimer, ILogger log)
        {
            log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");

            HttpClient client = new HttpClient();


            var res = client.GetAsync("http://active2.azurewebsites.net/api/values");

            string activeFlag = await res.Result.Content.ReadAsStringAsync();

            log.LogInformation($"Message was {activeFlag}");

            if (activeFlag == "true")
            {
                var message = new TemplatedPostmarkMessage()
                {
                    To            = "*****@*****.**",
                    From          = "*****@*****.**",
                    TemplateId    = 111718460,
                    TemplateModel = new
                    {
                        name = "Happy@Work Support",
                    }
                };


                string postmarkToken = Environment.GetEnvironmentVariable("POSTMARK_TOKEN");

                var pmClient   = new PostmarkClient(postmarkToken);
                var sendResult = await pmClient.SendMessageAsync(message);

                if (sendResult.Status == PostmarkStatus.Success)
                {
                    log.LogInformation("Success");
                }
                else
                {
                    log.LogError("Error occured");
                    log.LogError($"{sendResult.ErrorCode}");
                    log.LogError($"{sendResult.Message}");
                }
            }
            else
            {
                log.LogInformation("Configuration value was false");
            }
        }
예제 #20
0
        public async Task <bool> SendPaymentReciept(string departmentName, string name, string processDate, string amount, string email, string processor, string transactionId,
                                                    string planName, string effectiveDates, string nextBillingDate, int paymentId)
        {
            var message = new TemplatedPostmarkMessage
            {
                From          = FROM_EMAIL,
                To            = email,
                TemplateId    = Config.OutboundEmailServerConfig.PostmarkRecieptTemplateId,
                TemplateModel = new Dictionary <string, object> {
                    { "purchase_date", processDate },
                    { "name", name },
                    { "billing_url", UPDATEBILLINGINFO_URL },
                    { "uservoice_url", LIVECHAT_URL },
                    { "receipt_id", transactionId },
                    { "date", effectiveDates },
                    { "receipt_details", new [] {
                          new Dictionary <string, object> {
                              { "description", planName },
                              { "amount", amount }
                          }
                      } },
                    { "total", amount },
                    { "support_url", HELP_URL },
                    { "action_url", $"{Config.SystemBehaviorConfig.ResgridBaseUrl}User/Subscription/ViewInvoice?paymentId={paymentId}" },
                    { "credit_card_brand", "" },
                    { "credit_card_last_four", "" },
                    { "expiration_date", "" },
                },
            };

            var client = new PostmarkClient(Config.OutboundEmailServerConfig.PostmarkApiKey);

            try
            {
                PostmarkResponse response = await client.SendMessageAsync(message);

                if (response.Status != PostmarkStatus.Success)
                {
                    return(false);
                }

                return(true);
            }
            catch (Exception) { }

            return(false);
        }
        public async Task SendInvoiceAsync(int Id, string email, string name, string lastname, string dob
                                           , string cell, int kids, int adults)
        {
            var stock    = dc.Vacations.Where(o => o.Id == Id).FirstOrDefault();
            var resort   = dc.Resorts.Where(o => o.Id == stock.ResortId).FirstOrDefault();
            var unitSize = dc.UnitSizes.Where(o => o.Id == stock.UnitSizeId).FirstOrDefault();

            var message = new TemplatedPostmarkMessage
            {
                To            = email,
                From          = EmailFrom,
                TemplateAlias = "invoice",
                TemplateModel = new Dictionary <string, object>
                {
                    { "name", name },
                    { "lastname", lastname },
                    { "dob", dob },
                    { "cell", cell },
                    { "kids", kids },
                    { "adults", adults },
                    { "date", stock.Arrival.Date.ToString("dd/MM/yyyy") },
                    { "ddate", stock.Arrival.Date.AddDays(stock.Nights).ToString("dd/MM/yyyy") },
                    { "resort", resort.Description },
                    { "unitSize", unitSize.Description },
                    { "stockId", addInvoice(stock.Id) },
                    { "price2Pay", stock.Price2Pay },
                    { "adminFee", stock.AdminFee },
                    { "total", stock.Price2Pay + stock.AdminFee }
                }
            };

            var client = new PostmarkClient("ba4b7707-54c8-49d7-83d5-e215483fe37c");

            var response = await client.SendMessageAsync(message);

            if (response.Status == PostmarkStatus.Success)
            {
                Console.WriteLine(response.Status);
                Console.WriteLine(response.Message);
            }
            else
            {
                Console.WriteLine(response.Status);
                Console.WriteLine(response.Message);
            }
        }
예제 #22
0
        public async Task <bool> SendTroubleAlertMail(string email, string unitName, string gpsLocation, string personnel, string callAddress, string unitAddress, string dispatchedOn, string callName)
        {
            // Example request
            var message = new TemplatedPostmarkMessage
            {
                From          = DONOTREPLY_EMAIL,
                To            = email,
                TemplateId    = Config.OutboundEmailServerConfig.PostmarkTroubleAlertTemplateId,
                TemplateModel = new Dictionary <string, object> {
                    { "unit_name", unitName },
                    { "date", dispatchedOn },
                    { "active_call", callName },
                    { "call_address", callAddress },
                    { "address", unitAddress },
                    { "gps_location", gpsLocation },
                    { "personnel_names", personnel }
                },
            };

            if (SystemBehaviorConfig.OutboundEmailType == OutboundEmailTypes.Postmark)
            {
                var client = new PostmarkClient(Config.OutboundEmailServerConfig.PostmarkApiKey);

                try
                {
                    PostmarkResponse response = await client.SendMessageAsync(message);

                    if (response.Status != PostmarkStatus.Success)
                    {
                        return(false);
                    }

                    return(true);
                }
                catch (Exception) { }
            }
            else
            {
            }

            return(false);
        }
예제 #23
0
        private TemplatedPostmarkMessage MapToMailMessage(Message queueMessage)
        {
            var messageContents = JsonSerializer.Deserialize <NotifyBackersMessage>(queueMessage.Body);

            if (messageContents == null)
            {
                throw new Exception($"Message {queueMessage.MessageId} {queueMessage.Body} is invalid");
            }

            var message = new TemplatedPostmarkMessage
            {
                TemplateAlias = _configuration["PostMark:TemplateAlias"],
                TemplateModel = messageContents,
                To            = messageContents.Backer.EmailAddress,
                From          = _configuration["PostMark:FromAddress"],
                TrackLinks    = LinkTrackingOptions.HtmlAndText
            };

            return(message);
        }
        public async Task EmailToAdminAsync(EnquiryDto T, Vacation stock, Resort resort, Supplier supplier, UnitSizes unitSize)
        {
            var message = new TemplatedPostmarkMessage
            {
                //To = "*****@*****.**",
                To            = "*****@*****.**",
                From          = EmailFrom,
                TemplateId    = 20661200,
                TemplateModel = new Dictionary <string, object>
                {
                    { "name", T.Name },
                    { "lastname", T.Lastname },
                    { "resort", resort.Description },
                    { "date", stock.Arrival.Date.ToString("dd/MM/yyyy") },
                    { "unitSize", unitSize.Description },
                    { "priceToPay", stock.Price2Pay },
                    { "dob", T.Dob },
                    { "email", T.Email },
                    { "cell", T.Cell },
                    { "id", stock.Id },
                    { "adults", T.Adults },
                    { "kids", T.Under12 },
                    { "note", T.Note }
                }
            };

            var client     = new PostmarkClient("ba4b7707-54c8-49d7-83d5-e215483fe37c");
            var sendResult = await client.SendMessageAsync(message);

            if (sendResult.Status == PostmarkStatus.Success)
            {
                Console.WriteLine(sendResult.Status);
            }
            else
            {
                Console.WriteLine(sendResult.Status);
            }
        }
        public async Task SendNotificationAsync(int Id, string email, string name, string lastname)
        {
            var stock    = dc.Vacations.Where(o => o.Id == Id).FirstOrDefault();
            var resort   = dc.Resorts.Where(o => o.Id == stock.ResortId).FirstOrDefault();
            var unitSize = dc.UnitSizes.Where(o => o.Id == stock.UnitSizeId).FirstOrDefault();

            var message = new TemplatedPostmarkMessage
            {
                To            = email,
                From          = EmailFrom,
                TemplateAlias = "soldOut",
                TemplateModel = new Dictionary <string, object>
                {
                    { "name", name },
                    { "lastname", lastname },
                    { "date", stock.Arrival.Date.ToString("dd/MM/yyyy") },
                    { "resort", resort.Description },
                    { "unitSize", unitSize.Description },
                }
            };

            var client = new PostmarkClient("ba4b7707-54c8-49d7-83d5-e215483fe37c");

            var response = await client.SendMessageAsync(message);

            if (response.Status == PostmarkStatus.Success)
            {
                Console.WriteLine(response.Status);
                Console.WriteLine(response.Message);
            }
            else
            {
                Console.WriteLine(response.Status);
                Console.WriteLine(response.Message);
            }
        }
예제 #26
0
        public async Task <bool> SendCancellationReciept(string name, string email, string endDate, string departmentName)
        {
            var message = new TemplatedPostmarkMessage
            {
                From          = FROM_EMAIL,
                To            = email,
                TemplateId    = Config.OutboundEmailServerConfig.PostmarkCancelRecieptTemplateId,
                TemplateModel = new Dictionary <string, object> {
                    { "action_url", $"{Config.SystemBehaviorConfig.ResgridBaseUrl}/User/Subscription" },
                    { "subscriptions_url", $"{Config.SystemBehaviorConfig.ResgridBaseUrl}/User/Subscription" },
                    { "feedback_url", LIVECHAT_URL },
                    { "help_url", HELP_URL },
                    { "trial_extension_url", $"{Config.SystemBehaviorConfig.ResgridBaseUrl}/User/Subscription" },
                    { "export_url", "" },
                    { "plans_url", $"{Config.SystemBehaviorConfig.ResgridBaseUrl}/Home/Pricing" },
                    { "close_account_url", HELP_URL },
                },
            };

            var client = new PostmarkClient(Config.OutboundEmailServerConfig.PostmarkApiKey);

            try
            {
                PostmarkResponse response = await client.SendMessageAsync(message);

                if (response.Status != PostmarkStatus.Success)
                {
                    return(false);
                }

                return(true);
            }
            catch (Exception) { }

            return(false);
        }
예제 #27
0
        public async Task <bool> SendCallMail(string email, string subject, string title, string priority, string natureOfCall, string mapPage, string address,
                                              string dispatchedOn, int callId, string userId, string coordinates, string shortenedAudioUrl)
        {
            string callQuery = String.Empty;

            try
            {
                callQuery = HttpUtility.UrlEncode(SymmetricEncryption.Encrypt(callId.ToString(), Config.SystemBehaviorConfig.ExternalLinkUrlParamPassphrase));
            }
            catch { }

            var templateModel = new Dictionary <string, object>
            {
                { "subject", title },
                { "date", dispatchedOn },
                { "nature", HtmlToTextHelper.ConvertHtml(natureOfCall) },
                { "priority", priority },
                { "address", address },
                { "map_page", mapPage },
                { "action_url", $"{Config.SystemBehaviorConfig.ResgridBaseUrl}/User/Dispatch/CallExportEx?query={callQuery}" },
                { "userId", userId },
                { "coordinates", coordinates }
            };

            if (!String.IsNullOrWhiteSpace(shortenedAudioUrl))
            {
                templateModel.Add("hasCallAudio", "true");
                templateModel.Add("callAudio_url", shortenedAudioUrl);
            }

            if (SystemBehaviorConfig.OutboundEmailType == OutboundEmailTypes.Postmark)
            {
                var message = new TemplatedPostmarkMessage
                {
                    From          = DONOTREPLY_EMAIL,
                    To            = email,
                    TemplateId    = Config.OutboundEmailServerConfig.PostmarkCallEmailTemplateId,
                    TemplateModel = templateModel
                };

                var client = new PostmarkClient(Config.OutboundEmailServerConfig.PostmarkApiKey);

                try
                {
                    PostmarkResponse response = await client.SendMessageAsync(message);

                    if (response.Status != PostmarkStatus.Success)
                    {
                        return(false);
                    }

                    return(true);
                }
                catch (Exception) { }
            }
            else
            {
                var template = Mustachio.Parser.Parse(GetTempate("Call.html"));
                var content  = template(templateModel);

                Email newEmail = new Email();
                newEmail.HtmlBody = content;
                newEmail.Sender   = FROM_EMAIL;
                newEmail.To.Add(email);

                return(await _emailSender.Send(newEmail));
            }

            return(false);
        }