Save specific word from subject as folder name structured in a folder

Hello I am trying to perform this action:

I have a folder on my outlook named rpa. Inside that folder it will income mails with same form but different inputs.

The Subject looks like this

M3 Booking confirmed VRN: VH91428 Ordernumber: 0000400334

I want to store this line VRN: VH91428 Ordernumber: 0000400334 as title on each folder inside another folder called Attachment. The VRN number and OrderNumber will always be different from each mail.

For each folder title VRN: VH91428 Ordernumber: 0000400334 i also want to store the actual mail body so i can perfrom another action on it later ( will be a read and write action)

Thanks in advanced

NettbestillingBeta.xaml (15.5 KB)

@langsem

A file or Folder name can’t contain some special charcters like " : , /, ?, | " etcc…

1 Like

Is it possible to save it as ?

VRN VH91428 Ordernumber 0000400334

@langsem

Yes, you can.

String mailSubject = “VRN: VH91428 Ordernumber: 0000400334”

mailSubject = mailSubject.Replace(“VRN:”,“VRN”).Replace(“Ordernumber:”,“Ordernumber”)

Folder 1: “Path”+mailSubject.Split(" “.ToCharArray)(0)+” “+mailSubject.Split(” ".ToCharArray)(1)

Folder 2: “Path”+mailSubject.Split(" “.ToCharArray)(2)+” “+mailSubject.Split(” ".ToCharArray)(3)

1 Like

How will the proceedure be based on my project?( Sorry very new to this )

@langsem

  1. use Get Outlook MailMessage activity to read mails from outlook and specify folder path “rpa”. It will give you output as List of Mail Messages and say ‘mailMessage’.

  2. Then use For Each loop activity to iterate that list of mail messages and specify object type as System.Net.Mail.MailMessage.

    ForEach item in mailMessage
    - String mailSubject = item.Subject.ToString
    - use Create File activity to create file and pass below fields to it.

File Name: "Name.txt"

String folder1 = mailSubject.Split(" “.ToCharArray)(0)+” “+mailSubject.Split(” ".ToCharArray)(1)

String folder2 = mailSubject.Split(" “.ToCharArray)(2)+” “+mailSubject.Split(” ".ToCharArray)(3)

                            File Path: "folderPath\"+folder1+"\"+folder2

Note: Where, mailSubject = “VRN: VH91428 Ordernumber: 0000400334”

It will create file under this folder.

1 Like

but this only stores one folder with the same name VRN: VH91428 Ordernumber: 0000400334

the thing its that VH91428 and 00000400334 can be different from each mail

1 Like

@langsem

Here, it is in loop. And it will iterate one by one mail and read subject and then will create folder.

I said this as an example of mail subject.

oh i see, ok going to try

1 Like

what do you mean by this ?
ForEach item in mailMessage

  • String mailSubject = item.Subject.ToString

will also

File Name: "Name.txt"

String folder1 = mailSubject.Split(" “.ToCharArray)(0)+” “+mailSubject.Split(” ".ToCharArray)(1)

String folder2 = mailSubject.Split(" “.ToCharArray)(2)+” “+mailSubject.Split(” ".ToCharArray)(3)

be a variable?

1 Like

@langsem

We are storing output of Get Outlook Mail Message activity in mailMessages and it is of type List<System.Net.Mail.Message>

And then we are using For Each loop to iterate that list of mail messages.

Storing subject of the mail in mailSubject variable and it is of type String.

To create file, we are using Create File activity and we have to pass two input arguments to this like Name and Path.

Here, folder1 and folder2 are string variables. We are splitting mail subject and storing into it and then passing into Path under Create File activity.

1 Like

like this ?

@langsem

just create mailSubject variable of type string but don’t pass any default value to this.

we have to assign value inside For each loop to this variable.

1 Like

getting this

Ok it was just a typo. but its just storing one file inside attachment folder, also its not making a new folder inside attachment folder with the name of the subject from mail. It just reads the mail and then make one file and not for all those who are unread

@langsem

Could you please share your workflow once. Will check and update you.

the project?NettbestillingBeta.xaml (12.2 KB)

@langsem

Yes. Not whole project. Just send me this workflow xaml file only.

here its the email, how it looks

@langsem

Please find the attached workflow and let me know if you face any issues.

NettbestillingBeta.xaml (9.4 KB)