如何从 Office 365 API 响应正文中获取热门对话
How to get top conversation from office 365 API response body
我正在尝试弄清楚如何从正在进行的对话中获取 top/latest 对话。我正在从 Outlook Office 365 API 作为 JSON 检索数据。
JSON 用于电子邮件正文
"Body": {
<html>
\r\n
<head>
</head>
<body lang=\"EN-US\" link=\"blue\" vlink=\"purple\">
\r\n<div class=\"WordSection1\">
\r\n
<p class=\"MsoNormal\">
<span style=\"color:#1F497D\">
Hi Team,
</span>
</p>\r\n<p class=\"MsoNormal\">
<span style=\"color:#1F497D\"> </span>
</p>\r\n<p class=\"MsoNormal\">
<span style=\"color:#1F497D\">
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
</span>
</p>\r\n<p class=\"MsoNormal\">
<span style=\"color:#1F497D\"> </span>
</p>\r\n<p class=\"MsoNormal\">
<span style=\"color:#1F497D\"> </span>
</p>\r\n<div>
\r\n<p class=\"MsoNormal\">
<span style=\"color:#1F497D\">Thanks and Regards,</span>
</p>\r\n<p class=\"MsoNormal\">
<span style=\"color:#1F497D\">Demo Person</span>
</p>\r\n<p class=\"MsoNormal\">
<span style=\"font-size:10.0pt; font-family:"Arial",sans-serif; color:#E36C0A\">
Team Demo
</span><span style=\"font-size:9.0pt; color:#E36C0A\">
- TSS\r\n
</span>
<span style=\"font-size:9.0pt; color:#F79646\">
ASQT |dsfsf | +919642739170
</span><span style=\"font-size:9.0pt; color:#F79646\"></span>
</p>\r\n<p class=\"MsoNormal\">
<span style=\"color:#1F497D\">
<img width=\"163\" height=\"39\" id=\"Picture_x0020_1\" src=\"cid:image002.jpg@01D29C08.E3FC4D40\" alt=\"sign\">
</span>
</p>\r\n
</div>\r\n<p class=\"MsoNormal\">
<span style=\"color:#1F497D\"> </span>
</p>\r\n<div>
\r\n
<div style=\"border:none; border-top:solid #E1E1E1 1.0pt; padding:3.0pt 0in 0in 0in\">
\r\n
<p class=\"MsoNormal\">
<b>From:</b> Demo Person
<br>\r\n<b>Sent:</b> Monday, March 13, 2017 2:09 PM<br>\r\n<b>To:</b> Tempe@Email.com
<Temp1@email.com><br>\r\n<b>Cc:</b> Support@email.comt <
<br>\r\n<b>Subject:</b> RE: Demo Subject 1
</p>\r\n
</div>\r\n
</div>\r\n<p class=\"MsoNormal\"> </p>
\r\n<p class=\"MsoNormal\">
<span style=\"color:#1F497D\">HI Demo Team,</span>
</p>\r\n<p class=\"MsoNormal\">
<span style=\"color:#1F497D\"> </span>
</p>\r\n<p class=\"MsoNormal\">
<span style=\"color:#1F497D\">
Kindly check and confirm if you are working on this\r\n
</span>
</p>\r\n<p class=\"MsoNormal\">
<span style=\"color:#1F497D\"> </span>
</p>\r\n<p class=\"MsoNormal\">
<span style=\"color:#1F497D\">.</span>
</p>\r\n<p class=\"MsoNormal\">
<span style=\"color:#1F497D\"> </span>
</p>\r\n<p class=\"MsoNormal\">
</p>\r\n<p class=\"MsoNormal\">
</p>\r\n<p class=\"MsoNormal\"></p>\r\n<p class=\"MsoNormal\">
</p>\r\n<p class=\"MsoNormal\">
<span style=\"color:#1F497D\">
</span>
</p>\r\n<p class=\"MsoNormal\">
<span style=\"color:#1F497D\">
Task assigned to you.
</span>
</p>\r\n<p class=\"MsoNormal\">
<span style=\"color:#1F497D\"> </span>
</p>\r\n<p class=\"MsoNormal\">
<span style=\"color:#1F497D\">Thanks & Regards,</span>
</p>\r\n<p class=\"MsoNormal\">
<span style=\"color:#1F497D\">Demo,</span>
</p>\r\n<p class=\"MsoNormal\"><span style=\"color:#1F497D\">Sample Team</span></p>
\r\n<p class=\"MsoNormal\">
<span style=\"color:#1F497D\"> </span>
</p>\r\n<div>
\r\n<div style=\"border:none; border-top:solid #E1E1E1 1.0pt; padding:3.0pt 0in 0in 0in\">
\r\n<p class=\"MsoNormal\">
<b>From:</b> Temp person
<br>\r\n<b>Sent:</b> Monday, March 13, 2017 1:13 PM<br>\r\n<b>To:</b> Demo person
<<a href=\"mailto:demp@email.com\">Demop@email.com.com</a>><br>
\r\n<b>Cc:</b> Support@email.com <<a href=\"mailto:Demo@email.com\">Demo@email.com</a>>;
<br>\r\n<b>Subject:</b> RE: Demo Subject 1
</p>\r\n
</div>\r\n
</div>\r\n<p class=\"MsoNormal\"> </p>\r\n
<p class=\"MsoNormal\">
<span style=\"color:#1F497D\">Hi Demo,</span>
</p>\r\n<p class=\"MsoNormal\">
<span style=\"color:#1F497D\"> </span>
</p>\r\n<p class=\"MsoNormal\">
<span style=\"color:#1F497D\">
We are working on it.
</span>
</div>\r\n
</body>\r\n
</html>
}
我想获取最高记录并搜索其中是否有table。我认为我们可以尝试将整个 html 正文转换为一个字符串,然后使用 Regex 签入该字符串。将不胜感激。
我已成功获得 Regex
和 string.Substring()
的热门话题。希望这对有需要的人有所帮助。
//emailBody is a string variable
//Get the Index of first "From:"
int fromIndex = emailBody.Trim().IndexOf("From:");
if (fromIndex<0)//fromIndex will be -1 if it's fresh conversation
{
//It's fresh conversation.
//Reges.Replace will remove the unnecessary HTML tags before <body> tag
conversation = Regex.Replace(emailBody.Trim(), "[\s\S]*<body", "");
//Do further action on topmost conversation.
}
else
{
//It's ongoing conversation with more than one email.
conversation = Regex.Replace(emailBody.Trim().Substring(0, fromIndex), "[\s\S]*<body", "");
//Do further action on topmost conversation.
}
注意 - 我仍在研究如何从最上面的对话中获取 table。我会 post 很快。
我正在尝试弄清楚如何从正在进行的对话中获取 top/latest 对话。我正在从 Outlook Office 365 API 作为 JSON 检索数据。 JSON 用于电子邮件正文
"Body": {
<html>
\r\n
<head>
</head>
<body lang=\"EN-US\" link=\"blue\" vlink=\"purple\">
\r\n<div class=\"WordSection1\">
\r\n
<p class=\"MsoNormal\">
<span style=\"color:#1F497D\">
Hi Team,
</span>
</p>\r\n<p class=\"MsoNormal\">
<span style=\"color:#1F497D\"> </span>
</p>\r\n<p class=\"MsoNormal\">
<span style=\"color:#1F497D\">
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
</span>
</p>\r\n<p class=\"MsoNormal\">
<span style=\"color:#1F497D\"> </span>
</p>\r\n<p class=\"MsoNormal\">
<span style=\"color:#1F497D\"> </span>
</p>\r\n<div>
\r\n<p class=\"MsoNormal\">
<span style=\"color:#1F497D\">Thanks and Regards,</span>
</p>\r\n<p class=\"MsoNormal\">
<span style=\"color:#1F497D\">Demo Person</span>
</p>\r\n<p class=\"MsoNormal\">
<span style=\"font-size:10.0pt; font-family:"Arial",sans-serif; color:#E36C0A\">
Team Demo
</span><span style=\"font-size:9.0pt; color:#E36C0A\">
- TSS\r\n
</span>
<span style=\"font-size:9.0pt; color:#F79646\">
ASQT |dsfsf | +919642739170
</span><span style=\"font-size:9.0pt; color:#F79646\"></span>
</p>\r\n<p class=\"MsoNormal\">
<span style=\"color:#1F497D\">
<img width=\"163\" height=\"39\" id=\"Picture_x0020_1\" src=\"cid:image002.jpg@01D29C08.E3FC4D40\" alt=\"sign\">
</span>
</p>\r\n
</div>\r\n<p class=\"MsoNormal\">
<span style=\"color:#1F497D\"> </span>
</p>\r\n<div>
\r\n
<div style=\"border:none; border-top:solid #E1E1E1 1.0pt; padding:3.0pt 0in 0in 0in\">
\r\n
<p class=\"MsoNormal\">
<b>From:</b> Demo Person
<br>\r\n<b>Sent:</b> Monday, March 13, 2017 2:09 PM<br>\r\n<b>To:</b> Tempe@Email.com
<Temp1@email.com><br>\r\n<b>Cc:</b> Support@email.comt <
<br>\r\n<b>Subject:</b> RE: Demo Subject 1
</p>\r\n
</div>\r\n
</div>\r\n<p class=\"MsoNormal\"> </p>
\r\n<p class=\"MsoNormal\">
<span style=\"color:#1F497D\">HI Demo Team,</span>
</p>\r\n<p class=\"MsoNormal\">
<span style=\"color:#1F497D\"> </span>
</p>\r\n<p class=\"MsoNormal\">
<span style=\"color:#1F497D\">
Kindly check and confirm if you are working on this\r\n
</span>
</p>\r\n<p class=\"MsoNormal\">
<span style=\"color:#1F497D\"> </span>
</p>\r\n<p class=\"MsoNormal\">
<span style=\"color:#1F497D\">.</span>
</p>\r\n<p class=\"MsoNormal\">
<span style=\"color:#1F497D\"> </span>
</p>\r\n<p class=\"MsoNormal\">
</p>\r\n<p class=\"MsoNormal\">
</p>\r\n<p class=\"MsoNormal\"></p>\r\n<p class=\"MsoNormal\">
</p>\r\n<p class=\"MsoNormal\">
<span style=\"color:#1F497D\">
</span>
</p>\r\n<p class=\"MsoNormal\">
<span style=\"color:#1F497D\">
Task assigned to you.
</span>
</p>\r\n<p class=\"MsoNormal\">
<span style=\"color:#1F497D\"> </span>
</p>\r\n<p class=\"MsoNormal\">
<span style=\"color:#1F497D\">Thanks & Regards,</span>
</p>\r\n<p class=\"MsoNormal\">
<span style=\"color:#1F497D\">Demo,</span>
</p>\r\n<p class=\"MsoNormal\"><span style=\"color:#1F497D\">Sample Team</span></p>
\r\n<p class=\"MsoNormal\">
<span style=\"color:#1F497D\"> </span>
</p>\r\n<div>
\r\n<div style=\"border:none; border-top:solid #E1E1E1 1.0pt; padding:3.0pt 0in 0in 0in\">
\r\n<p class=\"MsoNormal\">
<b>From:</b> Temp person
<br>\r\n<b>Sent:</b> Monday, March 13, 2017 1:13 PM<br>\r\n<b>To:</b> Demo person
<<a href=\"mailto:demp@email.com\">Demop@email.com.com</a>><br>
\r\n<b>Cc:</b> Support@email.com <<a href=\"mailto:Demo@email.com\">Demo@email.com</a>>;
<br>\r\n<b>Subject:</b> RE: Demo Subject 1
</p>\r\n
</div>\r\n
</div>\r\n<p class=\"MsoNormal\"> </p>\r\n
<p class=\"MsoNormal\">
<span style=\"color:#1F497D\">Hi Demo,</span>
</p>\r\n<p class=\"MsoNormal\">
<span style=\"color:#1F497D\"> </span>
</p>\r\n<p class=\"MsoNormal\">
<span style=\"color:#1F497D\">
We are working on it.
</span>
</div>\r\n
</body>\r\n
</html>
}
我想获取最高记录并搜索其中是否有table。我认为我们可以尝试将整个 html 正文转换为一个字符串,然后使用 Regex 签入该字符串。将不胜感激。
我已成功获得 Regex
和 string.Substring()
的热门话题。希望这对有需要的人有所帮助。
//emailBody is a string variable
//Get the Index of first "From:"
int fromIndex = emailBody.Trim().IndexOf("From:");
if (fromIndex<0)//fromIndex will be -1 if it's fresh conversation
{
//It's fresh conversation.
//Reges.Replace will remove the unnecessary HTML tags before <body> tag
conversation = Regex.Replace(emailBody.Trim(), "[\s\S]*<body", "");
//Do further action on topmost conversation.
}
else
{
//It's ongoing conversation with more than one email.
conversation = Regex.Replace(emailBody.Trim().Substring(0, fromIndex), "[\s\S]*<body", "");
//Do further action on topmost conversation.
}
注意 - 我仍在研究如何从最上面的对话中获取 table。我会 post 很快。