Page 1 of 1

Encoding a sendto message

Posted: Sun Nov 22, 2009 3:23 am
by David-en8
I'm trying to take some text and us it to generate a URL that will generate an e-mail.

The format for the URL is:
<a href="mailto:YourName@YourSite.com? cc=someone@YourSite.com&bcc=someoneElse@YourSite.com &subject=Shipping%20Information%20Request&body=Please%20tell%20me%20if%20my%20order%20has%20shipped!">Shipping Request</a>

As you can see the spaces need converting to %20 and if I want new lines in the body I have to replace the CRLF to %0D%0A

I can use the map filter to convert the spaces and line ends but how to I ensure that the filter only get applied to part of the original text?

The text below is generated by a mail merge and can be changed if required.

The original text is:
Name:First Last
Subject:The subject of the e-mail
Body:The body with a new line
and one more
and another with an e-mail address david@abc.com
Link:Click here to send
END

What I need output is:

Code: Select all

<a href="mailto:First.Last@YourSite.com? subject=The%20subject%20of%20the%20e-mail&body=The%20body%20with%20a%20new%20line%0D%0Aand%20one%20more%0D%0Aand%20onother%20with%20an%20e-mail%20address%20david@abc.com">Click here to send</a><p>
Any help would be appreciated, David

Re: Encoding a sendto message

Posted: Mon Nov 23, 2009 6:40 am
by DataMystic Support
Just use a perl search/replace pattern to create a restriction -

match

Code: Select all

mailto:[^"<>']*?
Replace with

Code: Select all

$1
and add your map filter as a subfilter.