I'm a beginner with Azure and want to be able to have a Logic App to read the contents of an email and output it in JSON such as:
{
"from": "[email protected]",
"subject": "Azure Exception - A task was canceled.",
"body": "An exception has occurred in an Azure function"
}
The logic app is very basic, I have a 'when an email is received trigger' leading then to my Function App in which i am passing the Email Body as the request body. I am currently getting the http body request stuff back from the logic app such as:
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta content="text/html; charset=us-ascii"><meta name="Generator" content="Microsoft Word 15 (filtered medium)"><style>
<!--
@font-face
{font-family:"Cambria Math"}
@font-face
{font-family:Calibri}
This is not what I want as the main bit of the email that I want is at the bottom as html.
In my function app I am doing the following, taking the req and
public static async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
ILogger log)
{
log.LogInformation("C# HTTP trigger function processed a request.");
string emailBodyContent = await new StreamReader(req.Body).ReadToEndAsync();
return new OkObjectResult(emailBodyContent);
}
I'm not really sure how this works but I'm returning the req.Body
.
I am assuming that it might be something to do with the below? As we could do from: Email From, Subject: header
Any guidelines or answers is much appreciated.