How to pass URL to sendmail?

May 9, 2013
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?!!!
 
Jan 19, 2011
604
14
Norman, OK
Try doubling the % characters. The BTM might be trying to turn what follows into a variable. %% would escape into %.
 
Jan 19, 2011
604
14
Norman, OK
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>
 
May 9, 2013
40
0
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?
 
Jan 19, 2011
604
14
Norman, OK
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" ...
 
May 9, 2013
40
0
ah - perl - d'oh - never considered going out to another scripting language. Yeah, ... that makes sense!
 
Jan 19, 2011
604
14
Norman, OK
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]
%%
 
Jan 19, 2011
604
14
Norman, OK
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 abc@xyz.com 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@address.com "Test subject" @test.txt
 
Last edited:
Jan 19, 2011
604
14
Norman, OK
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@address.com "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@address.com "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
Thread starter Title Forum Replies Date
D Can alias pass parameters to for command? Support 3
vefatica PSHELL: How pass arguments to script? Support 15
M Backquoted parameters used in GoSub don't pass string as a single parameter Support 2
D How to? Pass OpenHere Folder to CMD? Support 6
A Unable to pass batch file arguments unaltered Support 18
samintz How to? Pass a structure to @WINAPI Support 1
A How to? Pass output from ffind to another command in a BTM file Support 5
J How to pass a character like " " to a function Support 3
Emilio III Control characters pass through? Support 6
vefatica START /PGM "name with spaces.URL" fails Support 2
S Feedback URL Support 6
P ISFILE with url Support 7
noahcoad How to? Prevent web url from opening after silent install Support 0
Phileosophos The @urlencode function doesn't seem to URL encode Support 16
vefatica URL into alias? Support 4
Jay Sage How to? SENDMAIL with G-Suite Mail Account Support 6
vefatica SENDMAIL via smtp.gmail.com? Support 3
C How to? inline IMG with sendmail? Support 7
R TCC-RT sendmail Support 8
R Fixed Sendmail parameter /USER= does not work Support 4
C sendmail in v20.00.25 x64 Support 7
J Sendmail, SSL and MS Servers Support 11
C SendMail and yahoo.com Support 1
C Sendmail w/GMail - problem Support 6
C Google Sendmail ? Support 15
Joe Caverly How to? SendMail and SSL Support 2
Dan Glynhampton Fixed v15 sendmail : password encryption problem Support 18
Jay Sage SENDMAIL Apparently Not Setting Priority Support 2
S @CON: does not work with sendmail for pipe Support 2
vefatica SENDMAIL, command line override SMTP server? Support 2
Joe Caverly SENDMAIL under v14 Support 3
dcantor SENDMAIL /= missing field Support 4
C Using dif. sending addresses with sendmail Support 11
C sendmail TO name? Support 9
A Using SENDMAIL with Exchange Server Support 1
H Minor bug in v12 SENDMAIL Support 0
Jay Sage SENDMAIL Problem in TCC12 Support 10
dcantor Problem with SENDMAIL /H Support 4
Jay Sage How Can SENDMAIL Create Messages with Plain Text and HTML Support 2
C sendmail question Support 1
dcantor Feature request for SENDMAIL Support 0
S SENDMAIL attachment size limit Support 1
S SENDMAIL vs. RFC 2822 Support 0
S SENDMAIL vs. RFC 2822 Support 0
J Configure SendMail to go through GMAIL as SMTP server Support 10

Similar threads