09-05-22 07:21 AM
Hi,
I need to get flag/Category information on emails in Outlook by entryID. The process will first add the information when getting the cases from an Outlook folder but then it will defer cases and I need to check the status (for flag and category) on the email again before handling. Does anyone have an suggesting on how I can do that?
Blue Prism version 6.10.3
09-05-22 08:12 AM
Dim app = CreateObject("Outlook.Application")
Dim _nameSpace = app.GetNameSpace("MAPI")
Dim internetHeaders As String
Dim folder = _nameSpace.GetDefaultFolder(Outlook_Folder_ID)
If Sub_Folder <> "" Then
For each name as string in Sub_Folder.Split("\")
folder = folder.Folders(name)
Next
End If
'See https://msdn.microsoft.com/en-us/library/office/aa210946(v=office.11).aspx
'for mail item properties
Dim dataTable As New Data.DataTable
dataTable.Columns.Add("EntryID", Type.GetType("System.String"))
dataTable.Columns.Add("To", Type.GetType("System.String"))
dataTable.Columns.Add("CC", Type.GetType("System.String"))
dataTable.Columns.Add("Subject", Type.GetType("System.String"))
dataTable.Columns.Add("Body", Type.GetType("System.String"))
dataTable.Columns.Add("Attachments", Type.GetType("System.String"))
dataTable.Columns.Add("ReceivedOn", Type.GetType("System.DateTime"))
dataTable.Columns.Add("SentOn", Type.GetType("System.DateTime"))
dataTable.Columns.Add("SenderName", Type.GetType("System.String"))
dataTable.Columns.Add("SenderEmailAddress", Type.GetType("System.String"))
dataTable.Columns.Add("Unread", Type.GetType("System.Boolean"))
dataTable.Columns.Add("Categories", Type.GetType("System.String"))
dataTable.Columns.Add("FlagRequest", Type.GetType("System.String"))
Dim folderItems = If(Filter_Expression <> "", folder.Items.Restrict(Filter_Expression), folder.Items)
For Each item As Object In folderItems
If Not TypeOf item Is MailItem Then Continue For
Dim row As Data.DataRow = dataTable.NewRow
row("EntryID") = item.EntryID
row("To") = item.To
row("CC") = item.CC
row("Subject") = item.Subject
row("Body") = item.Body
Dim attachments As String = ""
For Each attachment As Object In item.Attachments
If attachment.Type = 1 Then
attachments = attachments & "|" & attachment.DisplayName
End If
Next
row("Attachments") = If (attachments.Length = 0, "", attachments.SubString(1))
row("SentOn") = item.SentOn
row("ReceivedOn") = item.ReceivedTime
row("SenderName") = item.SenderName
row("SenderEmailAddress") = If (item.SenderEmailType = "EX",item.Sender.GetExchangeUser.PrimarySmtpAddress,item.SenderEmailAddress)
row("Unread") = item.Unread
row("Categories") = item.Categories.ToString
row("FlagRequest") = item.FlagRequest.ToString
dataTable.Rows.Add(row)
Item_Count += 1
Next
Items = dataTable
09-05-22 08:39 AM
Thanks for the reply 😊
The problem I have is after I added the items in the queue with information about flag/category there might be a change for the flag/category made in Outlook by a human so before I handle each case I need to do an extra check on the mail item to see if the flag/category has change. My though was to use the EntryID to get the information about flag/category status. But I can’t get any modification to the code to work regarding that. I only get the information when I retrieve cases base on folder or recipient. I guess I could retrieve all items by a particular folder and then filter on entryID but thought I would ask and see if anyone had an other solution.
09-05-22 01:02 PM