How to print the Mail message list value?

I am getting unread email message from the outlook and tried to print the list value in immediate panel but it’s only showing “System.Collections.Generic.List`1[System.Net.Mail.MailMessage]”. The list contains data and can be obtained in the loop but not able to print the whole list
Could someone suggest a possible solution for this.

The Immediate panel might not display the content of complex objects directly, so you need to extract and print the information

If you want to view the content of each email message in the list within the Immediate panel, you can iterate through the list and print the details of each message one by one.

1 Like

Hi @athira.aneesh

If you want count of emails then MailMessage.Count

If you want to read the body of mail then in For Each currentItem.Body


If you want to read the subject of mail then in For Each  currentItem.Subject

Cheers!!

Hi @athira.aneesh

Instead of printing whole Mail Message you can split the Mail Messages into parts and print it in message Box.

currentItem.Subject.Tostring will print Subject
currentItem.Body will print the body
currentItem.SenderEmailAddress will print sender email address

Like this way you can print in message box.

Regards

Hi @athira.aneesh

You can use Loop for get all the details like Subject, From address, Body etc.

For check all in Immediate Panel according to your Question.
Use below expression in Immediate Panel or Message Box

String.Join(Environment.NewLine, MailList.Select(Function(mailMessage) $“Subject: {mailMessage.Subject}, From: {mailMessage.From.Address}”))

Replace MailList with you variable i.e MailMessage

Hope it will helps you :slight_smile:
Cheers!!

1 Like

Hey, You wont be able to get subject, body by printing the whole message.

Try doing the below :-

currentItem.Subject.Tostring for Subject
currentItem.Body for body

similary , you can print different elements from mails.

1 Like

yes, I did that and working but my requirement is to see/print the whole data in the mail Message List

Is there any way to print/view the whole data in the mail message list.

@athira.aneesh

Do you want to print the whole Mail message.

You can follow this way and see the entire Mail Message. I have count because If you have two or three mails three text files will get created for three emails.

Regards

1 Like

@athira.aneesh
If it helps you. Mark my answer as Solution.

Happy Automation :slight_smile:

Its working now … Thank you

@athira.aneesh

Welcome :slight_smile:

Happy Automation
Cheers!!

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