This sample function code parse HTTP POST request that mime type is multipart/form-data and dump to log stream. This would be usefull for receiving webhook from SendGrid's inbound parse.
- Create Azure Functions app in your Azure account
- Deploy this in wwwroot or sync with repo
When you want to parse HTTP request body encoded by multipart/form-data , you can get MultipartMemoryStreamProvider object by calling ReadAsMultipartAsync() method, then you can enumerate Contents property and parse each part of POSTed body with HttpContent object.
If you want to specific part of email, query MultipartMemoryStreamProvider.Contents property by the name of ContentDisposition header
--- MultiPart Content ["from"] ---
Content-Disposition: form-data; name="from"
"[email protected]" <[email protected]>
--- MultiPart Content ["to"] ---
Content-Disposition: form-data; name="to"
"[email protected]" <[email protected]>
--- MultiPart Content ["html"] ---
Content-Disposition: form-data; name="html"
<html><body> Hello world !</body><html>
etc...