I have a process that gets 10 emails from an inbox at at time. The inbox can have more emails in it than this, but the process is limited to 10 emails for processing purposes.
Ideally the emails would be picked up oldest first, so those that have been waiting longest are the first dealt with. However, Get Outlook Mail Messages picks up most recent first, regardless of sort order in outlook.
Can this be rectified? Perhaps with a filter? I’m afraid the assign mail messages to a sorted mail messages variable doesn’t work, as it will only sort the 10 emails it picks up.
As I explained in my original post, I cannot use this exact approach as it gets all emails (lets say that’s 300) and this will a) take forever and b) not give me my batch of 10.
Set Top as Int32.MaxValue and then it will read all unread mails from the mail box. And then use Invoke Method activity as mentioned by @suruchi120294 to reverse mail list and read top 10 mails from that.
But top is set in the get outlook mail messages activity, which is prior to the invoke method.
In order for this to sort all the messages in the inbox it has to get them all, else it is only sorting the 10.
I already have top set to 10 in my get Outlook Mail Messages activity, but it gets the most recent 10. Sorting these 10 emails into date order is completely useless to me. I need the 10 most recent from the 300.
So just to clarify for others seaching to solve this problem (like myself):
What you are saying is, that it is NOT possible to get a list of emails, in reverse reception date, directly from the get outlook emails activity.
You will have to get ALL emails, and then reverse the resulting list.
Is this correct?
The process time for many large emails is rather extensive, so it seams like an oversight that you cannot do this directly from the activity.
Just out of curiosity, what does that (“g”) means?
Besides that, In my opinion as an overall idea, I would use not specifically the Outlook activity but a simple ‘getIMAPMailMessages’ in order to get the emails and then, yes, you will definitely have to come up with a filter based on the date to get the oldest ones as you said. I did it but in my case I needed the most recent which I know the opposite but just saying!
As expressed before, this does not solve the issue.
Your ‘solution’ just gets emails from a specific date and onwards.
What is discussed is getting all emails in reverse order, from mailboxes with many/large mails where getting every email takes a long time.
Getting every email and reversing the list is, as far as i can see, still the best solution, but it’s just not a very good one