Skip to main content
Cadet | Tier 2
March 13, 2025
Question

How to get the forwarded email section from an email message

  • March 13, 2025
  • 13 replies
  • 370 views

I need to create an automation anywhere bot to read bounced emails and extract the original mail subject and recipient from the email body.

But the ------------ Forwarded email---------- section is not captured in the email body

What can I do to sort this?

 

The process I used is mentioned below but the forwarded message section was not displayed in the message

 

Connect Email action - using imap

Loop action - Read email - assigned to a dictionary variable

Message action - display message was set to $EmailDetails{emailMessage}$

 

    13 replies

    Navigator | Tier 3
    March 17, 2025

    Hi ​@madhu subbegowda ,

    Is it possible to display $EmailDetails{emailMessageHtml}$ in a message?

    Even though email body not retrieved unread emails marked as read.

     

     

    There is no such key or any other key mentioned in above posts, refer documentation. You can check available keys in debug mode.

    https://github.com/A360-Tools | https://botstore.automationanywhere.com/vendor/botdev
    PamodiAuthor
    Cadet | Tier 2
    March 17, 2025

    @madhu subbegowda 

    Got the same error for $EmailDetails{rawEmailContent}$ and $EmailDetails{emailMessageText}$

    Field content must not be null

    The python script does not retrieve the forwarded email

    madhu subbegowda
    Most Valuable Pathfinder
    Most Valuable Pathfinder
    March 18, 2025

    Hello Pramodi,

    This seems to be a common issue since some email clients format forwarded content in ways that might not be readily accessible through standard email reading actions.
    Is it possible to try these approaches to solve this:

     

    Use Get property action: Instead of directly accessing the emailMessage property, try:
        $EmailDetails{emailAttachments}$
        $EmailDetails{emailHTML}$
    The HTML version of the email often contains the complete content including forwarded sections.

     

    Try different email reading modes:
        In the "Read email" action, try changing the "Read email mode" option to "HTML" instead of "Plain text"
        This preserves more of the original formatting and content

     

    Use Regular Expressions:
        After reading the email (using HTML format), use a regex pattern action to extract content between forwarding markers
        Example pattern: (?s)(?i)------+ ?Forwarded message ?------+(.*?)(?=------+|$)

     

    Check email headers:
        Sometimes the forwarded content may be stored in specific headers
        Try accessing $EmailDetails{emailHeaders}$ to see if that contains the information

     

    Save email as .eml and parse:
        Save the entire email as an .eml file
        Then use String actions to parse the file content, which often preserves the forwarded sections

     

    Which email service are you connecting to? Some services like Gmail might require specific approaches for accessing the complete forwarded content.

    Madhu Kumar T S || https://www.linkedin.com/in/madhukumarts/