[BUG] Get Outlook Mail Messages failed with 'Invalid cast' because of recalled email

Hello,

when there is an email that is recalled, the activity “Get Outlook Mail Message” is failed and no further mails could be processed.
Is there any workaround or planed bugfix?

22.10.4+Branch.support-v22.10.Sha.b4be88e3b45fb05c4bcd71885c763d4f2095f959

Source: Get Outlook Mail Messages

Message: Specified cast is not valid.

Exception Type: System.InvalidCastException

System.InvalidCastException: Specified cast is not valid.   at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode)
   at Microsoft.CSharp.RuntimeBinder.ComInterop.ComRuntimeHelpers.CheckThrowException(Int32 hresult, ExcepInfo& excepInfo, UInt32 argErr, String message)
   at CallSite.Target(Closure , CallSite , ComObject )
   at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0)
   at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0)
   at UiPath.Mail.OutlookAPI.AddCategoriesToMailMessageFromOutlookDynamicItem(MailMessage mailMessage, Object item)
   at System.Dynamic.UpdateDelegates.UpdateAndExecuteVoid3[T0,T1,T2](CallSite site, T0 arg0, T1 arg1, T2 arg2)
   at UiPath.Mail.OutlookAPI.CreateMailMessageFromOutlookDynamicItem(Object item, Boolean saveattachments, String folderpath)
   at System.Dynamic.UpdateDelegates.UpdateAndExecute4[T0,T1,T2,T3,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3)
   at UiPath.Mail.OutlookAPI.GetMessages(MAPIFolder inboxFolder, Int32 count, MailFilterVariant filterVariant, EOrderByDate orderByDate, Boolean onlyUnread, Boolean markAsRead, Boolean getAttachments, CancellationToken cancellationToken)
   at UiPath.Mail.OutlookAPI.GetMessages(String account, String folderMail, Int32 count, MailFilterVariant filter, EOrderByDate orderByDate, Boolean onlyUnread, Boolean markAsRead, Boolean getAttachments, CancellationToken cancellationToken)
   at UiPath.Mail.Outlook.Activities.GetOutlookMailMessages.<>c__DisplayClass40_0.<GetMessages>b__0()
   at System.Threading.Tasks.Task`1.InnerInvoke()
   at System.Threading.Tasks.Task.<>c.<.cctor>b__272_0(Object obj)
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location ---
   at UiPath.Mail.Activities.Extensions.TaskExtensions.TimeoutAfter[TResult](Task`1 task, Int32 timeoutMs)
   at UiPath.Mail.Activities.GetMailActivity.ExecuteAsync(AsyncCodeActivityContext context, CancellationToken cancellationToken)
   at UiPath.Shared.Activities.AsyncTaskCodeActivityImplementation.EndExecute(AsyncCodeActivityContext context, IAsyncResult result)
   at UiPath.Shared.Activities.AsyncTaskCodeActivity.EndExecute(AsyncCodeActivityContext context, IAsyncResult result)
   at System.Activities.AsyncCodeActivity.System.Activities.IAsyncCodeActivity.FinishExecution(AsyncCodeActivityContext context, IAsyncResult result)
   at System.Activities.AsyncCodeActivity.CompleteAsyncCodeActivityData.CompleteAsyncCodeActivityWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)

Same question here. Somebody who is able to help?

+1 Ran into the same issue. Deleting the recall message fixes the issue but happens again the next time a recall message is in the inbox.

I’ve raised an issue, and we will return once we have a resolution.

Any additional info to replicate the bug is more than helpful.

Thank you,

According to (https://docs.uipath.com/activities/other/latest/productivity/release-notes-uipath-mail-activities) the issue should have been fixed in the latest update v1.22.1 to the GetOutlookMailMessages activity.

BUT the error persists in Outlook 2016 32-bit when trying to receive e-mails from a folder where there is a recalled message within.

What is the current status of this issue? It is impossible to make a smart robot take care of these mails before fetching them.

bug BUMP#
I just tested the new outlook activity version 1.22.2, and the problem still persists,
When attempting to get mail via UiPath’s GetOutlookMailMessages, from Outlook 2016, this error occurs if a mail in said folder has been “Recalled”

System.InvalidCastException: Specified cast is not valid. at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode)
at Microsoft.CSharp.RuntimeBinder.ComInterop.ComRuntimeHelpers.CheckThrowException(Int32 hresult, ExcepInfo& excepInfo, UInt32 argErr, String message)
at CallSite.Target(Closure, CallSite, ComObject)
at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0)
at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0)
at UiPath.Mail.OutlookAPI.AddCategoriesToMailMessageFromOutlookDynamicItem(MailMessage mailMessage, Object item)
at System.Dynamic.UpdateDelegates.UpdateAndExecuteVoid3[T0,T1,T2](CallSite site, T0 arg0, T1 arg1, T2 arg2)
at UiPath.Mail.OutlookAPI.CreateMailMessageFromOutlookDynamicItem(Object item, Boolean saveattachments, String folderpath)
at System.Dynamic.UpdateDelegates.UpdateAndExecute4[T0,T1,T2,T3,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3)
at UiPath.Mail.OutlookAPI.GetMessages(MAPIFolder inboxFolder, Int32 count, MailFilterVariant filterVariant, EOrderByDate orderByDate, Boolean onlyUnread, Boolean markAsRead, Boolean getAttachments, CancellationToken cancellationToken)
at UiPath.Mail.OutlookAPI.GetMessages(String account, String folderMail, Int32 count, MailFilterVariant filter, EOrderByDate orderByDate, Boolean onlyUnread, Boolean markAsRead, Boolean getAttachments, CancellationToken cancellationToken)
at UiPath.Mail.Outlook.Activities.GetOutlookMailMessages.<>c__DisplayClass40_0.b__0()
at System.Threading.Tasks.Task1.InnerInvoke() at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state) --- End of stack trace from previous location --- at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread) --- End of stack trace from previous location --- at UiPath.Mail.Activities.Extensions.TaskExtensions.TimeoutAfter[TResult](Task1 task, Int32 timeoutMs)
at UiPath.Mail.Activities.GetMailActivity.ExecuteAsync(AsyncCodeActivityContext context, CancellationToken cancellationToken)
at UiPath.Shared.Activities.AsyncTaskCodeActivityImplementation.EndExecute(AsyncCodeActivityContext context, IAsyncResult result)
at UiPath.Shared.Activities.AsyncTaskCodeActivity.EndExecute(AsyncCodeActivityContext context, IAsyncResult result)
at UiPath.Mail.Activities.BaseMailAsyncActivity.EndExecute(AsyncCodeActivityContext context, IAsyncResult result)
at System.Activities.AsyncCodeActivity.CompleteAsyncCodeActivityData.CompleteAsyncCodeActivityWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)

Thank you for checking it. We have reopened the issue.