Пример #1
0
        public async Task TestSendBatchMessage()
        {
            var mg = new MessageService(ApiKey);

            //build a message
            var builder = new MessageBuilder()
                          .SetTestMode(true)
                          .SetSubject("Plain text test")
                          .SetFromAddress(new Recipient {
                Email = "*****@*****.**", DisplayName = "Mailgun C#"
            })
                          .SetTextBody("This is a test");

            //add 1000 users
            for (var i = 0; i < 1000; i++)
            {
                builder.AddToRecipient(new Recipient()
                {
                    Email = string.Format("test{0}@test.com", i)
                }, JObject.Parse("{\"id\":" + i + "}"));
            }

            var content = await mg.SendMessageAsync(Domain, builder.GetMessage());

            content.ShouldNotBeNull();
        }
Пример #2
0
        public void MessageBuilderRecipientVariables()
        {
            var builder = new MessageBuilder();

            var message =
                builder.AddToRecipient(new Recipient {
                DisplayName = "Charles King", Email = "*****@*****.**"
            },
                                       JObject.Parse("{\"id\":\"123\"}"))
                .GetMessage();

            message.RecipientVariables.ShouldNotBeNull();
            message.RecipientVariables["*****@*****.**"].ShouldNotBeNull();
        }