You need to sign in to do that
Don't have an account?
LoneStar69
How to extract the href markup from the htmlbody
Hi Guys,
I have a requirement to show the markup of the href only and to exclude the rest.
For Instance:
<html><body>
<p>This is Paragraph One</p>
<a href="http://www.google.com">This is Google:</a>
<p>This is Paragraph Two</p>
<a href="http://www.yahoo.com">This is Yahoo:</a>
<p>This is Paragraph Three</p>
<a href="http://www.youtube.com">This is YouTube:</a>
</body></html>
Desired output -
<a href="http://www.google.com">This is Google:</a>
<a href="http://www.yahoo.com">This is Yahoo:</a>
<a href="http://www.youtube.com">This is YouTube:</a>
My Code so far -
trigger HtmlBody on EmailMessage (after insert) {
Set<ID> sid = new Set<ID>();
List<EmailMessage> LEm = new List<EmailMessage>([Select ParentId, HtmlBody from EmailMessage WHERE ParentId = 'SPECIFIC CASE ID' ]);
for(EmailMessage em :LEm ){
if(em.HtmlBody.contains('href')){
sid.add(em.ParentId);
}
}
List<Case> cs =[select id, hrefinfo__c from Case where id IN :sid];
for(Case c: cs){
c.HrefInfo__c = ---------------------------------
}
}
I want to capture the end result into a text field hrefinfo__c.
I am not sure of which string methods to use here in order the achieve the above:
Appreciate your help!
I have a requirement to show the markup of the href only and to exclude the rest.
For Instance:
<html><body>
<p>This is Paragraph One</p>
<a href="http://www.google.com">This is Google:</a>
<p>This is Paragraph Two</p>
<a href="http://www.yahoo.com">This is Yahoo:</a>
<p>This is Paragraph Three</p>
<a href="http://www.youtube.com">This is YouTube:</a>
</body></html>
Desired output -
<a href="http://www.google.com">This is Google:</a>
<a href="http://www.yahoo.com">This is Yahoo:</a>
<a href="http://www.youtube.com">This is YouTube:</a>
My Code so far -
trigger HtmlBody on EmailMessage (after insert) {
Set<ID> sid = new Set<ID>();
List<EmailMessage> LEm = new List<EmailMessage>([Select ParentId, HtmlBody from EmailMessage WHERE ParentId = 'SPECIFIC CASE ID' ]);
for(EmailMessage em :LEm ){
if(em.HtmlBody.contains('href')){
sid.add(em.ParentId);
}
}
List<Case> cs =[select id, hrefinfo__c from Case where id IN :sid];
for(Case c: cs){
c.HrefInfo__c = ---------------------------------
}
}
I want to capture the end result into a text field hrefinfo__c.
I am not sure of which string methods to use here in order the achieve the above:
Appreciate your help!
[1] https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_pattern_and_matcher_pattern_methods.htm
[2] https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_pattern_and_matcher_matcher_methods.htm
[3] https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_pattern_and_matcher_using.htm