How to read outlook email and sort in ascending or descending order ?

This tutorial describes that how we can read the email from outlook and sort the email list into ascending or descending order.

Reading the email from the outlook

  1. Use Get outlook mail message activity
  • In the Account property pass the email account from which account we are trying to read the email, if we will leave this field blank it will read the email from the default account.

Once we will get this email into list and we want to sort it, let see how we can do it.

  1. Convert ListOfMailMessage To AscendingOder

image
(From email In ListOfMailMessage Order By email.Headers(“Date”)).ToList

  1. Convert ListOfMailMessage To DescendingOrder

image
ListOfMailMessage.OrderByDescending(Function(mail) mail.Headers(“Date”).ToString).ToList

Some Mail Message Header list is given below:-

  • Bcc
  • Cc
  • Content-ID
  • Content-Location
  • Content-Transfer-Encoding
  • Content-Type
  • Date
  • From
  • Importance
  • MIME-Version
  • Priority
  • Reply-To
  • Sender
  • To
  • X-Priority

I hope you enjoyed this article.