示例#1
0
        public void HtmlOnlyMailInput()
        {
            var input = new SendMailInput
            {
                From    = "PolyHx <*****@*****.**>",
                To      = new [] { "*****@*****.**" },
                Subject = "Sponsorship PolyHx",
                Html    = "<h3>I want to give you some money</h3>"
            };

            var content = input.ToString();

            Assert.AreEqual("{\"from\":\"PolyHx <*****@*****.**>\"," +
                            "\"to\":[\"[email protected]\"]," +
                            "\"subject\":\"Sponsorship PolyHx\"," +
                            "\"text\":null," +
                            "\"html\":\"<h3>I want to give you some money</h3>\"," +
                            "\"template\":null," +
                            "\"variables\":null}", content);
        }
示例#2
0
        public async Task <bool> SendEmail(SendMailInput input)
        {
            var content = new StringContent(input.ToString(), Encoding.UTF8, "application/json");

            HttpResponseMessage result;

            try
            {
                var token = await _stsService.GetAccessToken();

                _httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
                result = await _httpClient.PostAsync(ApiUrl + "/email", content);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }

            return(result.StatusCode == HttpStatusCode.OK || result.StatusCode == HttpStatusCode.Created);
        }
示例#3
0
        public void TemplateVariablesInput()
        {
            var input = new SendMailInput
            {
                From      = "PolyHx <*****@*****.**>",
                To        = new [] { "*****@*****.**" },
                Subject   = "Sponsorship PolyHx",
                Template  = "test",
                Variables = new Dictionary <string, string>
                {
                    { "name", "PolyHx" }
                }
            };

            var content = input.ToString();

            Assert.AreEqual("{\"from\":\"PolyHx <*****@*****.**>\"," +
                            "\"to\":[\"[email protected]\"]," +
                            "\"subject\":\"Sponsorship PolyHx\"," +
                            "\"text\":null," +
                            "\"html\":null," +
                            "\"template\":\"test\"," +
                            "\"variables\":{\"name\":\"PolyHx\"}}", content);
        }