Save Attachment - Length cannot be less than zero

Just tried to change position value to 11349, does not work, still got same error.

Hello Aditya,
Thanks for the help.
the email does have attachment and can be saved manually without any issue. The length of attachment is 113499, not 0. Is there any other parameter I can check?

@Louis_liu I’ve just run successfully a workflow with the following activities:

  1. Get Outlook Mail Messages → return one email having a 24 MB *.pdf attachment
  2. Save Attachments → it successfully saved the attached *.pdf file (even if Position = 0)

For the time being I have no idea what can be the root cause of your issue.
Can you please try to attach that file to another test email and check whether it can be saved?

Hi @Hiba_B
I am having similar issue to this. When I look at the attachment variable (and click in the pen like you suggest), here is the local value it gives me below:

Attachment { ContentDisposition=[attachment], ContentId=“d13379cc-625a-4b2f-a69a-14154a6a1123”, ContentStream=MemoryStream { CanRead=true, CanRead=true, CanSeek=true, CanSeek=true, CanTimeout=false, CanWrite=true, CanWrite=true, Capacity=201407, Length=201407, Length=201407, Position=0, Position=0, ReadTimeout=!, WriteTimeout=! }, ContentType=[application/octet-stream; name=+1855228-0427-144027-134.pdf], Name="+1855228-0427-144027-134.pdf", NameEncoding=null, TransferEncoding=Base64 }

Hi @DylanT !
Thank you for sharing with us the whole error message.
As @ovidiuponoran suggests, may you try to send yourself a mail with the specific attachment called “+1855228-0427-144027-134.pdf” and use save attachment with the robot to see if the error concerns only the attachment or if it’s a specific bug with save attachment activity ?

1 Like

I had a similar issue and found a solution by implementing my own workflow for saving attachments. The solution is based on the answer found on this page. (3.0 KB)


@aaskov - I had to make little adjustments to make it work, because in the for each loop initially it was given as Mail(0).attachments which I guess will fetch the attachment only from the first item, so I was getting the empty result.

Plus added this , so that anyone can run…

Path.Combine(Environment.ExpandEnvironmentVariables("%USERPROFILE%\Downloads"), attachment.Name)

I’ve got the same issue. It worked just fine for 2 months. All of a sudden it doesn’t work anymore. It also works for 99% of the attachments, but some give the error message. Anyone got a solution?

Example: it throws an error for the pdf “dee01382495.pdf”

Same here…
A week ago the save attchments activity was just working fine with every letter, but now it is not working with a specific one, but the robot had worked on it before.

Please UiPath masters, help us! :smiley:

@m.slagter when the activity started to fail: did this happen with the same version of the mail activities package that had worked before?

Thanks for your reply.
I’ve checked with a backup. it’s indeed the package that has been updated… Any solutions?

@m.slagter can you please confirm the activity from Mail package 1.9.5 (or an earlier version!? - please let me know which version exactly) correctly saves the attachment of that particular email?

I can confirm it works for Mail package 1.9.5. and it doesn’t work for the newer version 1.10.4. I’ve just tested it.

1 Like

Faced the same issue. Had to uninstall the mail activities package and install the lower version

@Louis_liu when downgrading the mail package does it work again for you ?

I was having this issue so tested on a bunch, noting down some successful and some failed content stream as attached. Seems like no relationship with position equaling zero.

Hello friends, any update on this @ovidiuponoran ?

Hi everyone, Hi @Nicolas_Lamoureux
We’ve just implemented a fix, can you please confirm using the attached alpha build (warning: do not use this in production, it is intended only t give us feedback on this issue)
uipath.mail.activities.1.11.1-alpha.1672677.nupkg (2.2 MB)

1 Like

Tanxs @ovidiuponoran

but I download it and the manage package do not see it in the folder i set for it.
Any idea ?

@Nicolas_Lamoureux I downloaded the attachment and I copied it in the local folder set as a “User defined package source” in Manage Packages dialog. I see this in Manage Packages:

I have this in the local folder: