Read the body of an Email

Hi :slight_smile:

I am trying to read the body of an email but keep getting an error message, please see diagram below…


Is anyone able to offer any advice please.

Thanks
Raychel

Ensure that the TypeArgument of the for each Activity is set to MailMessage

Feel free to delete Item.body and retype it with the assistance of intelisense

Hello @raychel.hall

Try
Place your email retrieval activities here (e.g., Get IMAP Mail Messages).
Assign the retrieved email to the ‘email’ variable.

If email IsNot Nothing Then
    Email found. Now, you can access the email body.
    Dim emailBody As String = email.Body.ToString()
    Do something with the email body (e.g., print it, store it, or process it).
Else
    Handle the case when the email is not found.
    Throw New Exception("Email not found or does not contain a body.")
End If

Catch ex As Exception
Handle any exceptions that may occur during the email retrieval process.
Log the error or perform any necessary error handling actions.
End Try

Thanks & Cheers!!!

1 Like

Hi @ppr

The type for NewEmail is set to MailMessage, the error I’m getting is that I can’t use ‘body’ to read the variable with that type.

Thanks Raychel

Change the TypeArgument of the “For Each” to MailMessage.

This has worked thank you :slight_smile:

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.