Read mail from end of outlook inbox folder

my requirement is read mail from end of outlook inbox or any folder. but reading email starting point should be last email of list. without using sorting list of email. only read from end of mail folder.

You can filter the emails byt “[ReceivedTime]” I belice to get the oldest one

@Ellboy but i don’t know how to filter. to find last one email

Main.xaml (4.5 KB)

Try this, looks like thr list of mail messages is organised by date anyway, this will give you the last one

@Ellboy not working

Well what’s wrong?

it’s not reading last mail

@samir
I don’t want to pick all or top any number of email. And then reverse or any sorting.
I just want to pick top 1 last email.

@pankajs3

  1. After reading mails using Get Outlook MailMessage Activity and will give you output as List of mail messages and say mailMessages.

  2. Then find the count of it: Int32 mailCount = mailMessages.count

  3. To read last mail:

System.Net.MailMessage lastmail = mailMessages(mailCount - 1)

hi @pankajs3

see If mails (List of MailMessage) is your output variable of Get Outlook Mail Message.
Then,

  1. If you want the latest then, mails.First
  2. If you want the oldest one then, mails.Last —> this is (System.Net.Mail.MailMessage)
    so you can apply anything related to System.Net.Mail.MailMessage object,
    e.g. mails.Last.Subject.toString OR mails.Last.From.toString.
1 Like

@samir and @lakshman

I am reading only one mail.
i am not reading multiple mails.
So i want i read one mail, that should be last mail

@pankajs3

You want to read particular day last mail or want to read last mail from entire mail box.

@lakshman
partially correct.
i want pick only one last email.

@pankajs3

Have tried the steps mentioned in above post or not ?

Hello @pankajs3
Check this workflow for better understanding This’ll get you the last email
Mail.xaml (6.8 KB)

Those steps are firstly reading multiple emails then getting last email. But my requirement is not that.

Hello @pankajs3
what exactly is your requirment ?

@pankajs3

To read mails from outlook, we have to use Get Outlook MailMessage Activity and output is list of mail Messages. Then we are trying to read last mail from that but we are not processing all mails.

Do one thing if you know the subject of the mail then specify it in Filter option. It will read that particular mail only.

@vickydas
email