public string SendEmail(Email email) { WebClient client = new WebClient(); NameValueCollection values = new NameValueCollection(); values.Add("username", Username); values.Add("api_key", ApiKey); values.Add("from", email.From); values.Add("from_name", email.Name); values.Add("subject", email.Subject); if (email.BodyHtml != null) values.Add("body_html", email.BodyHtml); if (email.BodyText != null) values.Add("body_text", email.BodyText); values.Add("to", email.To); byte[] response = client.UploadValues("https://api.elasticemail.com/mailer/send", values); return Encoding.UTF8.GetString(response); }
public HttpResponseMessage Send(Email message) { var retObj = new SendResult(); if (message.To != null && message.From != null) { var mailer = new Mailer(); retObj.Message = mailer.SendEmail(message); if (retObj.Message.Contains("Error")) { retObj.Status=false; return Request.CreateResponse(HttpStatusCode.BadRequest, retObj); } retObj.Status = true; return Request.CreateResponse(HttpStatusCode.OK, retObj); } retObj.Status = false; retObj.Message = "Invalid Content"; return Request.CreateResponse(HttpStatusCode.NotFound, retObj); }