Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Hyperlinks in Mail::Outlook Module

by BJ_Covert_Action (Beadle)
on Jan 19, 2012 at 18:41 UTC ( #948834=perlquestion: print w/replies, xml ) Need Help??

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


I ended up finding my own solution to this one. Instead of using Mail::Outlook, I decided to use Win32::OLE and configure it to a new outlook application object. I don't know a lot about OLE, but the info. I found about interfacing it with Outlook was very useful: found here.

Basically, that allowed me to set two new message behaviors (objects? parameters?) via the following:

use Win32::OLE; use Win32::OLE::Const 'Microsoft Outlook'; my $outlook = new Win32::OLE('Outlook.Application') or die "Could not +open Outlook Application!\n"; my $msg = $outlook -> CreateItem(0); unless ($msg){ die "Outlook is not running, cannot send mail.\n"; } $msg -> {'To'} = ''; $msg -> {'Subject'} = 'Important Subject Matter'; $msg -> {'BodyFormat'} = 'olFormatHTML'; $msg -> {'HTMLBody'} = 'Some text I want to display <a href=http://goo>With Links in HTML</a> embedded in that text\n' $msg -> Send();

So setting the 'BodyFormat' and 'HTMLBody' did the trick.

Original Problem

Howdy All,

So, I'm writing an automatic e-mail notification system for my office. We run Windows 7 and Outlook is the only e-mail program that I am aware of existing on our systems. I've been trying to use the Mail::Outlook module to send my e-mails. The problem is that I can't seem to find a way to insert hyperlinks into the e-mail, that display text other than the url. So if I want to insert a link to Google, I can just post:

$msg -> Body('')

However, if I want to link to Google and make it read as, "Search Engine," I'm not sure there's a way to do that. Other mailer modules seem to get around this by formatting the links in HTML. But I don't see a way to format the message as HTML using this module. Does anyone know if there is a way to do that?

If not, does anyone have any suggestions on better e-mail modules for use with a Windows 7 system? (Most of the modules I've found send e-mails using the sendmail folder on Linux boxes. I don't know how to mimic that functionality on Windows boxes).

Brady C. Jackson

Replies are listed 'Best First'.
Re: Hyperlinks in Mail::Outlook Module
by Anonymous Monk on Jan 20, 2012 at 02:37 UTC


    I don't know if this will help with the link problem, but you can set the mail server using MIME::Lite -

    my $msg = MIME::Lite->new( To =>'', Subject =>$xls, Type =>'TEXT', Data => $text); MIME::Lite->send('smtp', ', Timeout=>60 ); $msg->send;

    You can find the Outlook server by going to Account Settings and double-clicking on the account name.
    Perhap MIME::Lite will let you do the links as you want to.


      I actually have a somewhat separate question related to that. Initially, I tried to use MIME:Lite. However, I couldn't get the mail server to configure correctly. My current mail server, according to my Outlook account settings is listed as:outlook.mycompany.corp ... I took that to mean that the mail server is a Microsoft Exchange server. Does SMTP work with an exchange server?

        That's how I've done it in the past.

        But I like your Win32::OLE solution, I may do some messing with that myself.


        It's not such easy to find out a right Exchange server nowerdays. Starting with Exchange 2007 you clients connects to a CAS or Mailbox Server which may or may not be colocated with a HUB server which has an SMTP instance running. In addition the HUB server may reject SMTP mail due to security. The best way would be to ask your Exchange admin what is the best way to send Emails from your application.

        I would also prefer not to use Outlook if don't have to. Using a usual SMTP mail module allows you to run the application without Outlook installed and maybe even move to another operating system without rewriting the application. And there is one error source less in the process.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://948834]
Approved by ww
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2020-09-28 12:06 GMT
Find Nodes?
    Voting Booth?
    If at first I donít succeed, I Ö

    Results (143 votes). Check out past polls.