Email Attachments Overriding Issue

Hi all,

I have a scenario in inbox i have 10 Unread Emails all emails having PDF Attachment there is 8 emails containing same file Name when I download the attachments because of same file name I am not able to save all files in Folder its overriding the files. after that I have to read each file from folder and I need to mark it as a read.

Can any one help me on this.

Hello. What I believe you will need to do is rename the files after you save them.

To create a filename that is unique for each file, you can add a timestamp using the format “hhmmssff”, and you can use the Move File activity to perform the renames.

So let’s take this pseudocode to represent the logic used for this:

Get Mails: store in messages variable.
For each msg in messages    
    Save Attachments: output to enumerable of string, I'll call attachments
    For each att in attachments
        Move File: from att to Path.Combine(Path.GetDirectory(att),Path.GetFilenameWithoutExtension(att)+"_"+Now.ToString("yyyyMMdd.hhmmssff")+Path.GetExtension(att))

So something like that where you use GetDirectory, GetFilenameWithoutExtension, concatenate the timestamp to the filename and GetExtension(), then Combine to join the filepath together.

Hope that helps.


Hi Claytonm,

Thanks for replying, Could you please make small .xaml and give to me.

Thanks in Advance