Encoding a sendto message

Get help with installation and running here.

Moderators: DataMystic Support, Moderators

David-en8
Posts: 1
Joined: Sun Nov 22, 2009 3:03 am

Encoding a sendto message

Postby David-en8 » Sun Nov 22, 2009 3:23 am

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

User avatar
DataMystic Support
Site Admin
Posts: 2136
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Re: Encoding a sendto message

Postby DataMystic Support » Mon Nov 23, 2009 6:40 am

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.
Regards,

Simon Carter, http://DataMystic.com/forums/index.php
http://PredictBGL.com - Insulin dose calculator for Type 1 diabetes
http://DownloadPipe.com - 250,000 free software downloads
http://DetachPipe.com - send huge email attachments


Return to “TextPipe Tips and Tricks, Questions and Support”

Who is online

Users browsing this forum: No registered users and 1 guest