nagarajsh has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I have script that will find the latest report file created (reports are generated everyday) and sends mail to recipients the link to that file. But the problem is the link is too long, file://systemip/folder1/folder2/folder3/abcdefghijklmnop.xls. i want to send mail with "LINK1" in place of this whole string. i tried , it did not work. please help me. here is part of my script,
use SendMail; $smtpserver = "120.12.145.41"; $smtpport = 25; $sender = "Naga<math\@yahoo.com>"; $recipient = "ABC<math1\@yahoo.com>"; $sm = new SendMail($smtpserver,$smtpport); $sm->setDebug($sm->ON); $sm->From($sender); $sm->Subject("Reports Link"); $sm->To($recipient); $sm->setMailBody("please click the following link to get the reports\n +\n <a href=""\\\\111.1.34.100\\ABC\\Reports\\BCD\\Details\\MNO\$lates +t_bb_xls">click here</a>"); if ($sm->sendMail() != 0) { print $sm->{'error'}. "\n"; exit -1; } print "Done\n"; exit 0;
When i run this, i get mail and the it displays "please click the following link to get the reports\n\n <a href=""\\\\111.1.34.100\\ABC\\Reports\\BCD\\Details\\MNO\$latest_bb_xls">click here"

thanks in advance,

Naga

Replies are listed 'Best First'.
Re: Clickable link to open file on remote system
by tilly (Archbishop) on Jul 31, 2009 at 22:16 UTC
    You could use MIME::Lite and to send an HTML document as an email. Then you could <a href="$long_link">link</a> to shorten your link.

      Most e-mail user agents (MUA) consider text in angle brackets as a hyperlink, even and especially in plain text e-mails. So for most cases, just wrap the URL in angle brackets (like this: "bla bla bla - klick this link: <http://www.example.com/once/upon/a/time/there/was/a/file/burried/deep/inside/the/filesystem.txt> bla bla bla") and everything else happens automatically. No need to generate HTML. A properly secured MUA does not use a fully-featured HTML renderer with CSS and JS support, anyway.

      Alexander

      --
      Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
        If you look at the OP, that is what they were trying to do, but there was an accidentally doubled " that kept it from working.

        On the other hand generating HTML will work with MUAs that don't automatically hyperlink. And that will work regardless of whether it has support for CSS and JS.