cancel
Showing results for 
Search instead for 
Did you mean: 

Outlook get flag/category information on email by entryID

emjemed
Level 3

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

3 REPLIES 3

Hi Emma,

By default, these options are not available in the 'Get Received Emails (Basic)' action of the Outlook VBO. However, you can do the following modifications to your business object in order to get these extra values.

NOTE: I would recommend you to create a duplicate of the business object first before doing any such changes so that you can always refer to the backup business object in case of issues where you might get stuck.


So first, go  to the 'Get Received Emails (Basic)' action of the Outlook VBO and add two columns in the 'Items' collection as follows:

- Categories (Text) : It will have the category of the email if any is associated with the mail item.
- FlagRequest (Text) : It will have the flag request type value if any is associated with the mail item.

36579.png

36580.png
Now, go to the 'Internal_Get Items' page of the Outlook VBO and there also make the similar changes to the 'Items' collection:


36581.png

36582.png

No, go inside the code stage of the workflow in the 'Get_Internal Items' page:

36583.png

Now, here you can add the following code where the highlighted text are the additional codes which I have inserted:

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


Here, we are just mapping the newly added columns to the 'Categories' and 'FlagRequest' method calls of the MailItem object.

After running the workflow, you can see I am getting the values for one such email:

36584.png
36585.png

------------------------------
----------------------------------
Hope it helps you out and if my solution resolves your query, then please mark it as the 'Best Answer' so that the others members in the community having similar problem statement can track the answer easily in future

Regards,
Devneet Mohanty
Intelligent Process Automation Consultant | Sr. Consultant - Automation Developer,
Wonderbotz India Pvt. Ltd.
Blue Prism Community MVP | Blue Prism 7x Certified Professional
Website: https://devneet.github.io/
Email: devneetmohanty07@gmail.com

----------------------------------
------------------------------
---------------------------------------------------------------------------------------------------------------------------------------
Hope this helps you out and if so, please mark the current thread as the 'Answer', so others can refer to the same for reference in future.
Regards,
Devneet Mohanty,
SS&C Blueprism Community MVP 2024,
Automation Architect,
Wonderbotz India Pvt. Ltd.

emjemed
Level 3

Hi @devneetmohanty07

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.

Hi Emma,

Firstly, I just found it bit weird when you say that any human might change the category or flag. If I am correct these changes are mapped too individual Outlook accounts. So in your case, are the human workers also using the same outlook account as bot? Such a thing in production can make things bit messier at times if it is the case. 

However Emma, even if that is the case you still can use the approach I mentioned above the only difference would be while you are adding the items to the queue, just add the Entry ID, Category value and Flag Request value as a part of your Item Data. Now, let say whenever you are processing the work item, you can have a logic which will call the 'Get Received Items(Basic)' action, get you the entire collection of emails and then you can use a 'Filter Collection' action from 'Utility - Collection Manipulation' and filter the collection based on the Entry ID of your currently locked work item. So this will essentially return you the current email details for that locked item in your Outlook. If you do not want to filter such a large subset of collection, one suggestion that I can give you is that you can store additional details such as 'Subject', 'Sender Name' etc while you are adding the item to the queue and use the filter expression while querying the Outlook messages when you are working on the item. Post this you use the filter collection logic just as a double check and this way the processing time can get a bit faster since you are not querying the entire list of emails from Outlook but rather the list of emails with satisfy the initial filter criteria.

You can then compare the Category and the Flag Request value between both the filtered collection and the item data which is returning you the initial values when you set up the work item in your queue. This comparison can tell you if the category or the flag request value changed anytime in between the period you added the item and the time now when you are retrieving the item details.

So if this intervention happens let say within 2-3 days you can keep the item in deferred state as soon as you add the item so that it will be only picked after those 2-3 days have been passed and then the entire comparison logic will work.
---------------------------------------------------------------------------------------------------------------------------------------
Hope this helps you out and if so, please mark the current thread as the 'Answer', so others can refer to the same for reference in future.
Regards,
Devneet Mohanty,
SS&C Blueprism Community MVP 2024,
Automation Architect,
Wonderbotz India Pvt. Ltd.