Get Email Bodies and Upload to a system later in the workflow

Hi,

I’m trying to extract oulook email bodies and update a system them one by one . When i use the stored string variable it takes only the last stored value. Any suggestions? Can i store the bodies in an array and pass one by one

Hi Thulini,

You can store the body content in arr_string variable by splitting as per the requirement and then you can access that one by one. You can use arr_string(0) for first content and arr_string(1) for second and so on.

Hi @Ankit074 , Could you please show me how to store in arr_string? currently its in a string variable

@Thulini_Dissanayake " Please check out this post below. This post answers your question:
Capturing data from email"

Hi @Thulini_Dissanayake, Can you share the body content if possible? and what details you want to extract from this to update to the system?

@Ankit074
Here is a sample body

And some emails have just a normal text content.

I need the whole body to be extracted and later upload them one by one to a seperate system. I have being able to extract data inside for each loop but the issue im facing is when i use that string variable outside loop it stores only last emai body as its a string value.

If i could store in a excel or a string array i could use i assume, then again i used excel to store then the data got overwritten. If you could help me to solve would be great!

Thanks

Hi @Thulini_Dissanayake, As you have all body content in one variable. So now you can split all content based on the system requirement.

Please try this follow steps.

  1. Use next line parameter so that all content will be in a single line.
    Ex:- str-variable = System.Text.RegularExpressions.Regex.Replace(,"[\n]",""). This will make all the content in the single line.

  2. Like above you can remove extra spaces if required by giving [\s] instead of [\n].

  3. Now you can use split function based on the reuiqrement or regular expression to split the content.
    Suppose content is EducationAmea UniversityRecommendations so you can fetch Amea university by giving regular expression is (?<=Education)(.*?)(?=Recommendations)

Please try these steps and let me know how it goes.

@Thulini_Dissanayake Can you make some clarifications as to what actually you need to do ?
Do you want the Whole body of the email to be stored and then Upload that later, or do you want only some parts of the Email body to be stored and then upload them ?

If you want some part of the email body to be uploaded, then first we’ll need to extract only those parts. To extract only those parts we can use regex or String manipulation methods.

Also can you use a Message Box and use the value mail.Body in it where mail is your MailMessage variable.

In this way we can get to know how the body appears in the workflow for extraction and then use the needed operations.

@supermanPunch & @Ankit074 my exact requirement to be specific is to read the whole mail body not some content and update a field later in a system

i have being able to exact the body to a variable inside for each loop

Issue im facing is when updating the field later with body, these are the steps i need to follow

go to a system
add a new candidate
click upload resume & upload the downloaded attachments frm outlook ( this has already being implemented & working)
then in a field called notes i need to add the whole body of email for 1st candidate
save the candidate
and do the same steps for all other downloaded attachments

i have use a for each loop to save attachments and extract emailbody,
and another for each loop outside to go through attachments and upload them. where should i do the updating field if i do it inside 2nd for each it takes only the last body and update all with that

Hope you got my issue. i can post my workflow if that helps

Thanks

Hi @Thulini_Dissanayake, if you want to update entire body of the email then use this in the first for each loop along with the other extraction. This will work.

If you will use outside of the for each then you will get only last email’s content as per the iteration. So use this in the first for each loop will resolve your problem.

@Ankit074 but the issue is i cant use in first loop, as i need to update the body in system later when iterating through attachments and uploading in the attachments one by one.

@Ankit074 and @supermanPunch
Here is my workflow for your reference. It would be a great help if you can solve. Here what happen is always writing the last email body which is stored in emailBody variable.

I understand its because out side for each, but i don’t get clearly where to put that in my scenario.

Main.xaml (29.4 KB)

H @Thulini_Dissanayake, I have made some changes in your workflow and only used single for each loop. Please check and let me know how it goes.

EmailContent.xaml (11.5 KB)

@Ankit074 Thanks alot!

in your body where should i add the navigating to website, uploading file & updating email body activities?

To explain you my workflow,
i need to add a candidate with uploading attachment from fileList and then update the corresponding email body in a field. then save the candidate, move to add candidate and repeat the same steps for all the emails i received.

(all email has a body & an attachment)

If i keep the adding emailbody - typeinto activity inside second for each loop still it loops around inside loop finishes and move to outer loop right? then also it takes only last value of emailBody variable beacuse it already finishes uploading and adding content to all files in fileList from inner loop.

correct me if im wrong

@Thulini_Dissanayake Can you tell us what is the Attachment type ? Is it an Excel file or an Image ? It doesn’t concern it, but what happens when we save the Attachments is all the other Images present in it also gets saved as an attachment, Hence you should consider to use a Filter in Save Attachments to save only the types of file you need. Also check the total mails and the total Attachments downloaded in the Folder. In your case, Since you have Set to Top 3, the attachments downloaded should also be 3. Then if the Attachment count is the same, then we can Implement the operation you need using a Dictionary as a Key Value Pair.

But for that the Attachment Count and the Mail Count should be the same.

I have added the dictionary into the workflow, and modified the workflow accordingly. Just Check if it works for you in the way that you want. Also I have noticed that the Selectors in the Type Into and Click Activities are not accurate enough to identify the right element. Correct the Selectors accordingly, although you may have not faced any problems with that now, you may get it later.

Main.xaml (34.2 KB)

@Ankit074 @supermanPunch Thanks for your solutions!

the solution that @Ankit074 provided worked for me. I modified a bit to work into my case.

Thanks again you guys saved me. :blush:

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