Get outlook mail message filter yang lama terlebih dahulu

Halo kawan,

Ada yang bisa bantu soal pemakaian filter field di outlook get mail message activity?

Dari forum ada contoh begini: “[ReceivedTime] < ‘03-02-2020’"
Tapi ini hanya mengembalikan list mail message yang lebih tua dari tanggal di atas.

Problem saya adalah:

  • inbox email sangat banyak (2000+)
  • email yang lama perlu diproses terlebih dahulu
  • get outlook mail message hanya menarik jumlah email terbatas (~100?)

Hi @drkeek,

Have you tried something like this?

If you have too many emails, you could potentially create chunks of emails and put them into separate folders and process the folders one by one with this sort of method.

Thanks

Thanks @Kristopher,

The solution posted in that link sorts the list of mailmessages AFTER the get outlook mail message activity.


According to this post, I can set the activity to just get all emails by setting the top value to negative or Int32.MaxValue but realistically, if the value is large it slows down the process considerably, so the client has a limit of 1000 to their Outlook deployment.

I’m looking for a UiPath activity that retrieves the oldest mail from the get go so we don’t just process new mails and leave old ones untouched forever.

Hi @drkeek,

If out of the box + Marketplace activities cannot accomplish the task, then we fall back on an invoke code block.
EmailByDate.xaml (6.8 KB)

Thanks

Thanks @Kristopher! This is very helpful!

Just for the record, this is the eventual code I got to work.
With ability to loop through all accounts in Outlook and specify which account to use.
And what folder to move to.

Probably not the most elegant as I’m still new with VB.NET.
Any suggestions are welcome.

'Init'
Dim myOlApp As New Microsoft.Office.Interop.Outlook.Application
Dim myNameSpace As Microsoft.Office.Interop.Outlook.Namespace
Dim myInbox As Microsoft.Office.Interop.Outlook.MAPIFolder
Dim myitems As Microsoft.Office.Interop.Outlook.Items
Dim strFilter As String
Dim myAccounts As Microsoft.Office.Interop.Outlook.Stores
Dim myitem As Microsoft.Office.Interop.Outlook.MailItem
Dim myitemobject As Object
Dim myDestFolder As MAPIFolder

'Grab all accounts that exists in Outlook'
myAccounts = myOlApp.GetNamespace("MAPI").Stores
'Step through to find correct email account'
For i As Integer = 1 To myAccounts.count
	Console.WriteLine(myAccounts.Item(i).DisplayName)
	'Account found, check inbox'
	If  myAccounts.Item(i).DisplayName = "youremail@website.com"
		myInbox = myAccounts.Item(i).GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox)
		'Get all items in Inbox'
		myitems = myInbox.Items
		'Get oldest item'
		myitemobject = myitems.GetLast
		'Cast into MailItem type to enable moving'
		myItem = CType(myitemobject, Microsoft.Office.Interop.Outlook.MailItem)
		'Write out subject and received time for logging'
		Console.WriteLine(myitem.Subject)
		Console.WriteLine(myitem.CreationTime)
		Console.WriteLine(myitem.SenderEmailAddress)
		'Move to InProgress folder'
		myDestFolder = myInbox.Folders("InProgress")
		myItem.Move(myDestFolder)
	End If 
Next

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