Extract text of email in html format

lbethel

New Member
Hello, the Mapiex VBO returns the email text in html format. Is there any way to extract the text from the html after it has been returned by the VBO? I assume this is a very common issue and a really big shortcoming with this VBO
 

VJR

Well-Known Member
Hi lbethel,

See if you are able to make use of Regex or Split text actions from any of the BP VBOs.
If you do not have sensitive information then you can make use of any of the online html to text converters.
Is the html result straight forward? Are you able to mask your data and show how the tags look like and which text you want to extract? If I am able to spend time on that I will take a look at it, until then you can try out the above suggestions.
 

lbethel

New Member
Thanks, I don't believe Regex or Split can help with this. I believe that this can only be accomplished with a code stage or maybe the beta of the new Mapiex that has not been released can do it. Attached is an example of the html of the email message
 

Attachments

  • sampe email html.txt
    682 bytes · Views: 365

VJR

Well-Known Member
Hi lbethel,

Regex does make use of a pattern to identify html tags.
Below is a code in Visual Basic for the Code stage to identify the text that matches the regex pattern and then replace them with a blank string. The code works fine for the html you shared and needs to be tested for other html tags.

Object Diagram with Code stage:
InputHTML contains the text that you shared in the above text file.

View attachment 1533879383248.png

Input parameters and Code stage:

View attachment 1533879664021.png


Namespace to be added: System.Text.RegularExpressions

View attachment 1533879511048.png

Output parameter:
View attachment 1533879581902.png


Source: https://www.dotnetperls.com/remove-html-tags-vbnet
 

Mwacuka

New Member
Hi VJR,

I have somewhat similar process, I would like to send an email with a HTML table, as the email body ( I have already coded this step and it works). However, I would like to include a drop down list in the HTML table and the email recipient can choose an item from the drop down list and send that as a reply. Thereafter, I would like to read the reply i.e. get the item selected from the drop down list. Do you think this is possible in Blue Prism?
Looking forward to your thoughts. Thank you
 

VJR

Well-Known Member
Hi Mwacuka,

Since you have posted on this thread I am assuming that you are using MapiEx and Outlook.
I doubt you would be able to do that in a straight forward way. You may be able to send the html tags for a dropdown list but how the recipient would receive it and respond to it and read it again would be something to be tried out.

You could also think of using the voting buttons to achieve the same purpose in a very easy way.

Code:
Dim OutApp As Object
Dim OutMail As Object
Dim HtmlMsg


OutApp = CreateObject("Outlook.Application")
OutMail = OutApp.createitem(0)


HtmlMsg = "Hi Team,<br><br><b><u>" & "Please respond your answer with the voting buttons" & "</b></u>"
HtmlMsg = HtmlMsg  & "<br><br>Warm Regards,<br>" & "Your Name & Signature Here"

With OutMail
    .To = "abcd@xyz.com"
    .cc = ""
    .BCC = ""
    .Subject = "Test message with voting options"
    .HTMLBody = HtmlMsg
    .VotingOptions = "Accepted;Rejected;On Hold"
    .display
End With


OutMail = Nothing
OutApp = Nothing

Above is a simple code stage with html that produces an email before sending as below -

View attachment 1533976606515.png

Here you can notice the options given to the recipient for choosing the ones that you have provided in the code (.VotingOptions = "Accepted;Rejected;On Hold") and can customise it as per your requirements.

One thing to be noted about this approach is that the response email made by the recipient will not contain any body but only the actual value of the response provided (Accepted, Rejected or On Hold). So you need to identify the email based on the sender and the subject line or so. Send and Receive a test email and check out if it satisfies your requirement.

The above code is without the VBO. The point I was trying to make is to see if there is the same capability of adding voting buttons in the code that use the MapiEx VBO. I do not have MapiEx capabilities on my machine so I cannot do that. Go to code of the action that sends the email and see if the object that adds the To, Subject, Body etc. can also accommodate the Voting Buttons. If so then you are good to go or else you might have to use a separate code something like the above. Post back with what you came up with.
 

Mwacuka

New Member
Hi VJR

Indeed I am using both MapiEx and Outlook. Thank you for your detailed and well explained answer.
I will test out the code in MapiEx later on and inform you of how things go.

However, I fear that the voting options may not work for me.

My use case requires me to send a table with variable number of rows from which the user can pick from. In the example attached, suppose I sent a list of possible appointments to a user, and the user has the possibility to select the following options per appointment sent (Accept, Reject, Provisional) and then send back the response.

I have already coded how to convert a collection to HTML, my data on appointments per email recipient is stored in a collection, and I want to append the options drop down to the collection, and then send the collection content to the recipient as shown in the ExampleEmailBody attachment.

Looking forward to your ideas.
 

Attachments

  • ExampleEmailBody.PNG
    11.6 KB · Views: 159

Mwacuka

New Member
Hi VJR

I tried to append the voting options to the MAPIEx send mail action code, but got an error, "VotingOptions" is not a member of Blue Prism.WindowsAutomation.MAPIEx"
 

VJR

Well-Known Member
Hi Mwacuka,

If you are looking for multiple voting buttons for each time slot then that is not available in Outlook and also you have found out that MapiEx isn't supporting it. Do a research on having custom Outlook forms (which does allow dropdowns) and if the forms can be used via Blue Prism to write as well as read responses.

Also you can think of creating and sending an Outlook Calendar appointment/meeting request based on the data you have. Something like this -> https://blogs.msdn.microsoft.com/br...cheduling-appointments-in-outlook-from-excel/
Although it may not allow customised options like "Provisional" but the ones that Outlook uses for a recipient to respond (Accept, Decline, Tentative, etc.) Then find a code that would read the calendar entries and their responses.

Another plain and simple option would be send the data in a tabular format and have the user to type in with the 3 options before replying back and then read the email body via blue Prism. Yes there are caveats with this approach with the recipient not typing the correct spelling and having to read the correct portion of the email body etc. I am just throwing you with some options and you can do a feasibility study of what is it that works best for you.
View attachment 1534224397224.png
 

sirichandana50

New Member
Hi,

I am using the above code to include voting options, but I get the following error.could someone please help me with this.
"Internal : Could not execute code stage because exception thrown by code stage: Operation aborted (Exception from HRESULT: 0x80004004 (E_ABORT))"

Thank you.
 

VJR

Well-Known Member
Hi,

I am using the above code to include voting options, but I get the following error.could someone please help me with this.
"Internal : Could not execute code stage because exception thrown by code stage: Operation aborted (Exception from HRESULT: 0x80004004 (E_ABORT))"

Thank you.
Operation aborted HRESULT: 0x80004004 (E_ABORT)
This error is not related to Blue Prism. You can do a web search and see that this error has been received in other programming languages too while sending an email. Once you look at the solutions and implement them it will automatically be resolved via Blue Prism.
 

Lalithkumar

New Member
Hi,
Thanks For the help. It worked fine for HTML to Plain Text.
But in my case i have both CSS and HTML's are there. How to remove CSS and HTML both?.
Thank You
 
Top