示例#1
0
 private async void Button_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         IMailService service = new SendGridService();
         var          model   = new MailModel
         {
             From  = tbFrom.Text,
             ToStr = tbTo.Text,
             Title = tbTitle.Text,
             Body  = new TextRange(rtbBody.Document.ContentStart, rtbBody.Document.ContentEnd).Text,
         };
         if (file != null)
         {
             model.Attachments.Add(new MailModel.Attachment
             {
                 Name    = lFile.Content.ToString(),
                 Content = file
             });
         }
         MessageBox.Show(await service.Send(model));
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
示例#2
0
        public void SendTestEmailWithTwoAttachments()
        {
            SendGridService sendGridService = new SendGridService(_sendGridConfig);

            var response = sendGridService.Send("*****@*****.**", "SendTestEmailWithTwoAttachments Test Body", "SendTestEmailWithTwoAttachments Test Subject", _images);

            Assert.IsTrue(response.StatusCode == System.Net.HttpStatusCode.Accepted);
        }
示例#3
0
        public void SendTestEmailWithOneAttachment()
        {
            SendGridService sendGridService = new SendGridService(_sendGridConfig);

            var attachment = new Dictionary <string, string>()
            {
                { _images.FirstOrDefault().Key, _images.FirstOrDefault().Value }
            };

            var response = sendGridService.Send("*****@*****.**", "SendTestEmailWithOneAttachment Test Body", "SendTestEmailWithOneAttachment Test Subject", attachment);

            Assert.IsTrue(response.StatusCode == System.Net.HttpStatusCode.Accepted);
        }
        public async Task Send_Mail_Test()
        {
            var mail = new SendGridService(new SendGridMailServiceConfiguration()
            {
                ApiKey = Environment.GetEnvironmentVariable("SendGridApiKey")
            });

            var mailResponse = await mail.Send(
                new System.Net.Mail.MailAddress(Environment.GetEnvironmentVariable("SendGridIntegrationTestEmail"), "Receiver display name"),
                new System.Net.Mail.MailAddress("*****@*****.**", "Sender display name"),
                "Integration test mail",
                "<b>Integration test mail");

            Assert.AreEqual(mailResponse, true);
        }
示例#5
0
        private void OnSendEmailClicked(object sender, EventArgs e)
        {
            string          emailAddress    = EmailAddress.Text;
            string          customText      = EmailCustomText.Text;
            SendGridService sendGridService = new SendGridService(GetSendGridConfig());

            Dictionary <string, string> images = new Dictionary <string, string>()
            {
                { "TestImage1.png", @"..\Appx\Assets\Square44x44Logo.scale-200.png" }
            };

            var response = sendGridService.Send(emailAddress, customText, "Instant PhotoBooth Image Delivery", images);

            DisplayAlert("Message Result", response.StatusCode.ToString(), "OK");
        }
示例#6
0
        protected async void sendButton_Click(object sender, EventArgs e)
        {
            // Prepare the email message info model
            var messageInfo = new EmailMessageInfo
            {
                FromEmailAddress = fromInput.Value,
                ToEmailAddress   = toInput.Value,
                CcEmailAddress   = ccInput.Value,
                BccEmailAddress  = bccInput.Value,
                EmailSubject     = subjectInput.Value,
                EmailBody        = bodyInput.Value
            };

            // Make an API call, and save the response
            var apiResponse = await _sendGridService.Send(messageInfo);

            await SetResponseInfoContainers(apiResponse);
        }