Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

How to pass URL to sendmail?

May
40
0
I desperately would like to pass a URL that contains spaces as part of the body of a sendmail from BTM files.

I have tried a bunch of solutions - including trying to convert the spaces to %20 sequences.

However, although I can get syntax to work on the command line, in a batch file it still ends up broken.

so in this:

%@replace[ ,^%@char[37 37]20,%OfficialMediaFolder]

Which works on the command line - and generates a replacement of ' ' -> %20 of the contents of %OfficialMediaFolder, when executed in my batch, instead I have all spaces replaced with nothing.

So "\\Media Server" becomes "\\MediaServer"

This is way wrong. :(

%@char[37] fails.
Escaping it as shown in my @replace function fails.

If I could output the url in a format that Outlook would consume from sendmail with spaces in it - that would be fine too!

But I cannot figure out how to encode the URL in plaintext for sendmail so that it comes into outlook as a URL (containing spaces)....

Help?!!!
 
Try doubling the % characters. The BTM might be trying to turn what follows into a variable. %% would escape into %.
 
If I could output the url in a format that Outlook would consume from sendmail with spaces in it - that would be fine too!

But I cannot figure out how to encode the URL in plaintext for sendmail so that it comes into outlook as a URL (containing spaces)....
Just read this part. Since you're trying to get it to show up in Outlook and if you are sending the message as "HTML format" from your sendmail, try wrapping your url like this (using html markup to force it).
Code:
 <a href="http://some.url.com/this is the url">http://some.url.com/this is the url</a>
 
Thanks - that's probably useful.
I was doubling up the % chars - that's what the @char[37 37] was intended to do - %% - but it still gets eliminated?!
your <a href... is exactly what I want - but do I need to include some sort of header in the sendmail body to indicate that the email is in HTML format?
 
I use a perl script for my sendmail called "sendEmail.pl". It is MUCH friendlier than sendmail. Let me look at sendmail and see what I can find out real quick.

Edit: From the TCMD manual...
Code:
sendmail /h"Content-Type: text/html" ...
 
that's what the @char[37 37] was intended to do
Just tried it. Looks like you'd need to do 4 of them.
Code:
13:18:19 $ echo %@char[37 37 37 37]
%%
 
also - how to avoid the < > being picked up as pipe / i/o symbols...
You could try stashing your message in an external file and then grabbing it like this, but I don't know if it would be parsed any differently...
Code:
sendmail [email protected] Party @c:\messages\invitation.txt

Edit: This worked and the url came thru using the "<a href..." inside the text file.
Code:
SENDMAIL /H"Content-Type: text/html" [email protected] "Test subject" @test.txt
 
Last edited:
You could also use here-document redirection. Took me a bit to figure out how to get it into sendmail (you can't redirect straight, you have to use the @CON:), but here it is.
Code:
sendmail /H"Content-Type: text/html" [email protected] "Test subject" @CON: << "MSGTXT"
<a href="http://some.url.com/this is a test">http://some.url.com/this is a test</a>
MSGTXT
Take the quotes off from around the MSGTXT at the end of the first line if you want to allow for variable expansion.
Code:
set theurl=http://some.url.com/this is a test
sendmail /H"Content-Type: text/html" [email protected] "Test subject" @CON: << MSGTXT
<a href="%theurl%">%theurl%</a>
MSGTXT
These are lines right out of a BTM file (with the email address obfuscated).
 

Similar threads

Back
Top