How to take and Replace text from mail Body?

Hi Guys ,
I have another problems.Please Help me…

Dear MR,
(We are sending at BCC)
Thank you very much for your support in recruitment activities.
We have received a seminar just before, so we will contact you again.
Please check the following and attached summary, and we would appreciate your favor.
=======================================================
【Name】Gradulation
【Date Time】March 19 (Mon) 12:30~14:15
【place】1st floor North Lobby
【note】1.Introductory names, affiliations, current duties etc. in front of all students
2.Round-table discussion (20 minutes × 4 sets) with 2 employees 1 person vs. about 6 students
※ Please check the attached for details.
※ Students choose an interesting booth from among the 15 booths.
I will come to listen to you. What has been your hardship in your career,
Please tell us about the best part of your work in a form that responds to questions from students.
【Meeting time】 12:15 (I will explain in advance.)
[Meeting place] Tokyo head office 1st floor north side lobby
If you would like to participate in this year’s Seminar List 02 for the second time,
Please come to the venue directly at 12:30.
[Clothing] tie, jacket wear

According this passage,I want to replace another date with robot.For Example,

【Date Time】March 19(Mon) 12:30~14:15 ==>【Date Time】July 1(Tue) 5:30~6:15
【place】1st floor North Lobby ==>【place】2st floor East Lobby

Could you help me please.
Best regards,
Lwin Moe Aung

@LwinMoeAUNG

If you are using outlook then follow below steps:

  1. use Get Outlook MailMessage Activity to read mails from outlook and will give you output as List of mail messages.

  2. Then use For Each loop to itreate that list of mail Messages.

           ForEach item in mailMessages
           If 
         item.subject.Tostring.Contains("subjec of the mail")
         Then:
    
         String bodyOfMail =Item.body.Tostring
         bodyOfMail.replace("[Date 
         Time]","requried")
    

Like this replace all things and then send mail using Send Outlook MailMessage Activity

Else:
Skip mails

1 Like

@lakshman
Thank you for your kindly reply.I will try it.

1 Like


Could you help me bro?I’m facing that error.

Kind Regards,
LwinMoeAung

1 Like

@LwinMoeAUNG

In For Each loop, why are converting it to string.

Just pass genMailBody and go to properties of For Each loop and select type of Arguments as System.Net.Mail.Message

3 Likes

Hi @LwinMoeAUNG

In the for each activity you have mentioned
GenMailBody.ToString in the IN property

Remove the .ToString part from there and try… it will work

1 Like

Oops sorry bro @lakshman… we both posted the same lol

1 Like

I assign data not From outlook mail.I took from excel.
My process is

Taking mail data from excel and fixed that mail data.After all,I will assign that mail data into Send OutlookMail Message.

That is why genMailBody is not from outlook mail.That is from read cell that read data from excel.

1 Like

@LwinMoeAUNG

If you are taking data from Excel using Read Cell Activity then it will give output as String. Here, remove For Each loop Activity and just pass genMailBody.Tostring into the log message.

1 Like

I see bro :sweat_smile:
But ,I have another question for replace.

In this data how can I replcae because 【Date Time】and 【place】 are only fix data.So,how can I replace their behind data(March 19 (Mon) 12:30~14:15,1st floor North Lobby) from them .
【Date Time】March 19 (Mon) 12:30~14:15
【place】1st floor North Lobby

Kind Regards,
LwinMoeAung

2 Likes

@LwinMoeAUNG

Now your output is stored in a string variable genMailBody right. Then try below expression.

Syntax: String.replace(“oldString”,“newString”)

String newBodyOfMail = genMailBody.Tostring.Replace("【Date Time】", “March 19 (Mon) 12:30~14:15”). replace ("【place】",1st floor North Lobby")

2 Likes

Thank you for your fast reply sir.I will try it.

2 Likes

I got it to replace text but I cann’t for behind text.I mean March 19(Mon) 12:30~14:15 is not stable.It is only sample data. I want to replace anything behind the 【Date Time】 .For example.

【Date Time】Apirl 20 (Tue) 11:30~13:15 something like that.

1 Like