using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.IO; using RestSharp; using RestSharp.Authenticators; namespace MailGunTest { public class SendSimpleMailChunk { public static void Main(string[] args) { Console.WriteLine(SendSimpleMessage().Content.ToString()); } public static IRestResponse SendSimpleMessage() { RestClient client = new RestClient(); client.BaseUrl = new Uri("https://api.eu.mailgun.net/v3"); client.Authenticator = new HttpBasicAuthenticator("api", "c416cb13b5937e7c2274f9f3038101cd-c485922e-70545ed4"); RestRequest request = new RestRequest(); request.AddParameter("domain", "mg.tfoman.me", ParameterType.UrlSegment); request.Resource = "{domain}/messages"; request.AddParameter("from", "Excited User "); request.AddParameter("to", "tommy@oeman.se"); request.AddParameter("to", "tommy.oman@mg.tfoman.me"); request.AddParameter("to", "tommy.oman@gmail.com"); request.AddParameter("subject", "Api-sent message TEST"); request.AddParameter("text", "Let's see how it works!"); request.Method = Method.POST; return client.Execute(request); } } }