c# 4.0 - SendGrid incoming mail webhook - how to save the JSON format email data into my application folder in C# -
this regarding sendgrid incoming mail webhook, have referred url sendgrid incoming mail webhook - how secure endpoint, , got idea how go this, but, new mvc / webapi, give me controller method code snippet catch json format http post , save application folder.
this solution found after googling , slight modifications:
[httppost, httpget] [enablecors(origins: "*", headers: "*", methods: "*")] public async task post() { if (request.content.ismimemultipartcontent("form-data")) try { //to complete post in string use below line, not used here string strcompletepost = await request.content.readasstringasync(); httpcontext context = httpcontext.current; string strfrom = context.request.form.getvalues("from")[0]; string stremailtext = context.request.form.getvalues("email")[0]; string strsubject = context.request.form.getvalues("subject")[0]; //not useful guess, because return sendgrid ip string strsenderip = context.request.form.getvalues("sender_ip")[0]; } catch (exception ex) { } } i tried, retrieving values
string = context.request.params["to"]; but, value returned not consistent, i.e. of times returning null , returns actual value stored in it.
if have better solution, please let me know.
thank you
Comments
Post a Comment