Office 365 Download Email Attachments - Filename Confusion

So I have an automation that downloads email attachments, then uploads to Storage Bucket for onward processing.

However the email attachment has had its filename changed to something else

ibxiwly5.q2x.csv

it was

CPAGCards - Copy.csv

Hi @rmorgan

At what point in the workflow, it changed?

While downloading from email?

During upload to storage bucket?

Is actual name in the email same as it used to be? Or it’s changed there as well?

Run the process in debug mode, and check the value of file name in locals panels before, during and after every stage, you will find where it is getting changed.

Im not sure

I use the Download Email Attachments Activity

That has a List Variable for the included attachments.

I then do a For Each to Loop through the list and upload to Storage Bucket.

No where in my code do I instruct it to change the file name.

here’s how you can do…

  1. download all email attachments into a folder : <mention the path in the argument of the activity “{Destination path}”.
  2. Then get files(fileinfo object) from the folder “{Destination path}” and for each file in the fileinfo object array, rename the file names as you want. if you dont want to change the names then, add step 3 in this loop.
  3. then upload each file to SB.

I’m assuming the enumerable array of email attachments that you are looping is the issue since you are trying to upload the file from the o365 email object(ig its the cache path of the outlook files) but not from fileinfo object.
SG.

@rmorgan

after downloading all the files into folder use for each activity with output of download email attachments, use rename file activity inside of the loop specify with your expected filename then after upload that file into storage bucket.

Happy Automation.!

I don’t know what the expected name is, fhe filename will floow a format but I can’t second guess what thye are…

don’t use your Email attachment object for looping, that’s where the problem is… these are temporary file names that you get from the path.GetFileName(…)
check my earlier response…

also. just wondering if you have mentioned the destination path to save.. if not, it is probably saving in outlook temp location.

SG.

Hi @rmorgan

Use save attachments and read the property attachment.Name when saving:

Path.Combine(folderPath, attachment.Name)

If helpful, mark as solution. Happy automation with UiPath

1 Like

That activity assigns a random name because it saves all attachments to the same folder. Rather than using Download Email Attachments, you’d be better off looping through yourEmailVar.Attachments and saving them one by one to preserve the filename and so you can control where they’re saved.

Also, the Download Email Attachments will delete the files when the process reaches the end of the scope (ie 365 Scope) that the Download Email Attachments activity is inside.

1 Like

Hi @rmorgan

This happens because the file is being uploaded using a temp filename instead of the original attachment name.

When downloading the attachment, make sure you use the attachment Name property and pass that as the file/blob name when saving or uploading to the Storage Bucket. If you don’t set it explicitly, UiPath generates a random filename like ibxiwly5.q2x.csv.

Cool all sorted

Im using .LocalPath which is giving me the randomised file name. if I use .Fullname it gives me the actual filename

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.