Save Attachments, Message: Index was out of range. Must be non-negative and less than the size of the collection

Hello there, I have a bug in save attachment activity when running my project

and that’s the error message

21.10.4+Branch.master.Sha.8f864e3db4251aecabea63041087de2634460029

Source: Save Attachments

Message: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index

Exception Type: System.ArgumentOutOfRangeException

RemoteException wrapping System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
at lambda_method(Closure , ActivityContext )
at Microsoft.VisualBasic.Activities.VisualBasicValue1.Execute(CodeActivityContext context) at System.Activities.CodeActivity1.InternalExecuteInResolutionContext(CodeActivityContext context)
at System.Activities.Runtime.ActivityExecutor.ExecuteInResolutionContext[T](ActivityInstance parentInstance, Activity1 expressionActivity) at System.Activities.InArgument1.TryPopulateValue(LocationEnvironment targetEnvironment, ActivityInstance activityInstance, ActivityExecutor executor)
at System.Activities.RuntimeArgument.TryPopulateValue(LocationEnvironment targetEnvironment, ActivityInstance targetActivityInstance, ActivityExecutor executor, Object argumentValueOverride, Location resultLocation, Boolean skipFastPath)
at System.Activities.ActivityInstance.InternalTryPopulateArgumentValueOrScheduleExpression(RuntimeArgument argument, Int32 nextArgumentIndex, ActivityExecutor executor, IDictionary2 argumentValueOverrides, Location resultLocation, Boolean isDynamicUpdate) at System.Activities.ActivityInstance.ResolveArguments(ActivityExecutor executor, IDictionary2 argumentValueOverrides, Location resultLocation, Int32 startIndex)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)

Hey @Hisham_Alshareef ,

Do you happen to have a sample project reproducing this issue? Additionally, when you are getting the outlook message, is there an object being retrieved?

Thanks,
Raluca

@Hisham_Alshareef to me it looks like Get Outlook Mail Message returned no emails (i.e. MailMessages has 0 items).

1 Like

I have the same issue and does not seem to be getting over, could not locate a solution, were you able to get a fix @Hisham_Alshareef ?

I have the same issue and can share sample project / Workflow files, How to?

I’ve tested that and indeed the empty MailMessages variable will return this error.

You can check that either during debugging or by using a Log Message with the following code:
MailMessages.Count.ToString

I’m getting the same exact issue as @Hisham_Alshareef. I have tried debugging and also I’ve tried tying the code you provided. I’ve uninstalled UiPath Studio and re installed it and tried the whole process over again from scratch and I haven’t had any progress. Is there something else that could be wrong by any chance?

Hi @perez786305

What is your Mail activity package version?

I have the same issue, but only with certain mail messages but all having attachments. The count is 1 I can view the mail message properties and when it moves to save attachments I get the error. But I see where the attachment is part of the mail message within the message properties. Mail Package version: 1.12.3. It appears to be a bug with certain mail messages with the UiPath platform. As I can download the attachment manually but UiPath cannot even though it appears nothing is wrong with the mail object.

Hey @Rookie

Could you please post a sample xaml file that reproduces your issue or enough screenshots for us to try to reproduce? (also of the email, if you can blur any sensitive information)

There are 2 Inbox folder in Outlook keep you mail in both the folder mark them as unread and try running you bot again. It will work.

1 Like

That worked really well. Thank you!

¿Estoy en el mismo problema se encontró alguna solución?

Gracias