/// <summary>
        /// This endpoint allows you to deliver a JSON message into your private domain.
        /// This is similar to simply emailing a message to your private domain,
        /// except that you use HTTP Post and can programmatically inject the message.
        /// Note that injected JSON Messages can have any schema they choose.
        /// However, if you want the Web interface to display them,
        /// they must follow a general email format with the fields of From,
        /// Subject, and Parts(see "Fetch Message" above).
        /// </summary>
        /// <param name="request">InjectMessageRequest object.</param>
        /// <returns></returns>
        public async Task <InjectMessageResponse> InjectMessageAsync(InjectMessageRequest request)
        {
            var requestObject = httpClient.GetRequest(endpointUrl + "/{domain}/inboxes/{inbox}/messages", Method.POST);

            requestObject.AddUrlSegment("domain", request.Domain);
            requestObject.AddUrlSegment("inbox", request.Inbox);

            requestObject.JsonSerializer = new DynamicJsonSerializer();
            requestObject.AddJsonBody(request.Message);

            var response = await httpClient.ExecuteAsync <InjectMessageResponse>(requestObject);

            return(response);
        }
Example #2
0
        public async Task InjectMessageAsync()
        {
            var message = new MessageToPost()
            {
                Subject = "Testing message",
                From    = "*****@*****.**",
                Text    = "Hello World!"
            };
            var request = new InjectMessageRequest()
            {
                Domain = Domain.Name, Inbox = InboxAll, Message = message
            };
            var response = await mailinatorClient.MessagesClient.InjectMessageAsync(request);

            Assert.IsTrue(response != null);
            Assert.IsTrue(response.Status == "ok");
        }