Hello, I have a script that will find the email body in a html message.
Here is the vbs:
Option Explicit
Function FindFirstEmailBody(htmlMessage)
Dim regEx, bodyPattern
Set regEx = New RegExp
' Regular expression pattern to match the first occurrence of HTML body
bodyPattern = "<body=^>]*>(.*?)</body>"
' Ignore case and multiline
regEx.IgnoreCase = True
regEx.MultiLine = True
' Execute the regular expression
Dim matches
Set matches = regEx.Execute(htmlMessage)
' Check if a match was found
If matches.Count > 0 Then
FindFirstEmailBody = matches(0).SubMatches(0)
Else
FindFirstEmailBody = ""
End If
End Function
' Find the first email body
Dim emailBody
emailBody = FindFirstEmailBody(htmlMessage)
' Output the first email body
MsgBox emailBody
![](https://uploads-us-west-2.insided.com/automationanywhere-en/attachment/7862dc40-70ea-4a2f-9f04-fb8611b05af4.png)
Here S_emailMessage is email message of the email in the loop for each mail action.
![](https://uploads-us-west-2.insided.com/automationanywhere-en/attachment/c254e8c2-0fc1-46d6-bdc0-c71437884edd.png)
It says “bot error”