Need Help in executing a Workprocess

I wrote a code for Email Auto Reply . As a next step I need to copy data from subject line of Email and store in a file .
I’ll explain - the subject Line will be “1900 - Name - Topic” . So now I want 1900 , Name and Topic to be stored in separate variables .

The subject line syntax will be same , so this activity will read 100-200 emails with same subject line.

Can you tell how to proceed

1 Like

Hi,

Can you try the following?

strNumber = strSubject.Split({"-"c})(0).Trim
strName = strSubject.Split({"-"c})(1).Trim
strTopic = strSubject.Split({"-"c})(2).Trim

Regards,

This I must execute using “Assign” activity?

Hi,

Basically, yes.
We can directly input these expressions (like strSubject.Split({"-"c})(0).Trim) to property of activity, however if in trouble, it might be complicated to solve, sometimes.

Regards,

All credits to @Yoichi .
The solution has a bit modification
strNumber = item.Subject.Split({"-“c})(0).Trim
strName = item.Subject.Split({”-“c})(1).Trim
strTopic = item.Subject.Split({”-"c})(2).Trim

that’s it . @Yoichi if you can replace str with item as I mentioned , I’ll mark your reply as solution

Can you please exaplin @Yoichi How you got it , means how does this solution work , It will be useful to solve other problems like these for me

1 Like

Hi,

Thank you for your reply.
Yes, Get MailMessages activity returns List<MailMessage>. So if we iterate this list using For Each activity, the exprssion will be the following as you mentioned.

strNumber = item.Subject.Split({"-"c})(0).Trim
strName = item.Subject.Split({"-"c})(1).Trim
strTopic = item.Subject.Split({"-"c})(2).Trim

MailMessage.Subject returns subject of the mail.
Split method returns string array which is split by char array argument (in the above case it’s “-”)
So, "1900 - Name - Topic".Split({"-"c}) returns {"1900 “,” Name “,” Topic}
We can get each item of the array by index, such as item.Subject.Split({"-“c})(0)
Finally, remove extra spaces using Trim method, then we can get what we ant to get.

Regards,

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