Question

How to use VBScript in A360

  • 28 July 2023
  • 1 reply
  • 180 views

Userlevel 3
Badge +10

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

 

 

 

Here S_emailMessage is email message of the email in the loop for each mail action.

 

It says “bot error”


1 reply

Badge +4

Unfortunately Automation Anywhere doesn’t give descriptive feedback from scripts, so if something causes your script to stop, you will be returned ‘bot error’.

 

There are two things I have done to work with these error messages:

 

  1. Implement error handling within the script so that it outputs something useful when an error occurs.
  2. If step one still doesn’t fix the issue, then comment out lines of your code run the bot, slowly uncomment lines to find the offending one.

 

Good Luck!

Reply