Saving only pdfs

Hi as per my flow below I only want to save the pdf not the other attachements in the email.

Hi,

Hope the following helps you.

fs = New FileStream(yourPath,FileMode.Create,FileAccess.ReadWrite)
item.ContentStream.CopyTo(fs)
fs.Close()

Regards,

1 Like

Hi Yoichi,

Thanks for your reply but how does this limit to saving only pdfs?

Hi,

Can you try to add the following IF activity? (Like you already put)

Regards,

how do I set the parameters?

Hi,

Do you mean parameters of InvokeMethod activity? Please click ... button in Parameters property.
Parameters dialog will be shown as the following.

Regards,

Do you have an xaml of this I can download?

Hi,

Hope the following helps you.

Main.xaml (11.0 KB)

Sometimes, InvokeMethod shows error due to mismatch parameters even if it’s correct.
If you faces the above, can you try to use Stream type variable as the following?

fs = New FileStream(yourPath,FileMode.Create,FileAccess.ReadWrite)
s = item.ContentStream
s.CopyTo(fs)
fs.Close()

s : System.IO.Stream

Regards,

sorry still having an issue. can you please checFetchMail.xaml (16.7 KB)
k the attached file/

Hi,

Can you check the following?

  • TargetType should be null because it’s exclusive with TargetOgbject
  • Targetobject should be not item.ContentStream.CopyTo(fs) but item.ContentStream
  • fs should be defined as System.IO.FileStream in variable panel.

Regards,

Thanks that seems to be working. Can I reference the file name that the try catch is working on?

Hi,

item.Name will return its filename in the above workflow.

Regards,

yes just worked it out… Im not feeling it today!!

Last question… I am receiving the error below on the assign task

Assign: Access to the path ‘C:\Users\uipath\Documents\UiPath\INV\TestFolder’ is denied.

Hi,

It seems access control of file system matter.
Can you check if the user has write permission to the folder?
Or security software might block to write.

Regards,

Checked everything, even gave everyone full access to the folder. I can write to that folder with saveattachments and move file activities

I found the issue. I was only passing the path not including the filename.

New FileStream(strdocpath + "\" + item.name,FileMode.OpenOrCreate,FileAccess.ReadWrite)

Hi,

Sorry, I tried to open to not file but directory in the above workflow.
Can you modify as the following?

fs = New FileStream(System.IO.Path.Combine(yourPath,item.Name),FileMode.Create,FileAccess.ReadWrite)

Regards,