/// <summary>/// A model with the data format of the Inbound Parse API's POST/// </summary>publicclassEmail{/// <summary>/// The Domain Keys Identified Email code for the email/// </summary>publicstringDkim{get;set;}/// <summary>/// The email address that the email was sent to/// </summary>publicstringTo{get;set;}/// <summary>/// The HTML body of the email/// </summary>publicstringHtml{get;set;}/// <summary>/// The email address the email was sent from/// </summary>publicstringFrom{get;set;}/// <summary>/// The Text body of the email/// </summary>publicstringText{get;set;}/// <summary>/// The Ip address of the sender of the email/// </summary>publicstringSenderIp{get;set;}/// <summary>/// A JSON string containing the SMTP envelope. This will have two variables: to, which is an array of recipients, and from, which is the return path for the message./// </summary>publicstringEnvelope{get;set;}/// <summary>/// Number of attachments included in email/// </summary>publicintAttachments{get;set;}/// <summary>/// The subject of the email/// </summary>publicstringSubject{get;set;}/// <summary>/// A JSON string containing the character sets of the fields extracted from the message./// </summary>publicstringCharsets{get;set;}/// <summary>/// The results of the Sender Policy Framework verification of the message sender and receiving IP address./// </summary>publicstringSpf{get;set;}}
// POST api/inbound[HttpPost]publicasyncTask<HttpResponseMessage>Post(){varroot=HttpContext.Current.Server.MapPath("~/App_Data");varprovider=newMultipartFormDataStreamProvider(root);awaitRequest.Content.ReadAsMultipartAsync(provider);varemail=newEmail{Dkim=provider.FormData.GetValues("dkim").FirstOrDefault(),To=provider.FormData.GetValues("to").FirstOrDefault(),Html=provider.FormData.GetValues("html").FirstOrDefault(),From=provider.FormData.GetValues("from").FirstOrDefault(),Text=provider.FormData.GetValues("text").FirstOrDefault(),SenderIp=provider.FormData.GetValues("sender_ip").FirstOrDefault(),Envelope=provider.FormData.GetValues("envelope").FirstOrDefault(),Attachments=int.Parse(provider.FormData.GetValues("attachments").FirstOrDefault()),Subject=provider.FormData.GetValues("subject").FirstOrDefault(),Charsets=provider.FormData.GetValues("charsets").FirstOrDefault(),Spf=provider.FormData.GetValues("spf").FirstOrDefault()};// The email is now stored in the email variablereturnnewHttpResponseMessage(HttpStatusCode.OK);}