Sending mail through Mail::Outlook

P

paddyxmurphy

Hi,

I am using Mail::Outlook to send email through Outlook. I've set out
the code below. Everything works fine but I have two items on my wish
list.

1. To be able to send attachments. I have tried
'$message->Attachments('c:\file.txt');' and
'$message->Attachments.Add('c:\file.txt');' but neither work.
2. To be able to send the email in html format but
'$message->HTMLBody($body);' doesn't work.

Are either of these possible using Mail::Outlook or do I need to go
back to scratch and use another module?

Thanks

Paddy

#################################################################################
# CODE

#!/usr/bin/perl

use strict;
use warnings;

use Mail::Outlook;
use Win32::OLE::Const 'Microsoft Outlook';
my $outlook = new Mail::Outlook();

my $to = "my_mom\@moms_mail.com";
my $body = "Hi Mom!\n\n etc.";
my $message = $outlook->create();

$message->To($to);
$message->Cc();
$message->Bcc();
$message->Subject('Happy Mothers Day, Mom!);
$message->Body($body);
#$message->HTMLBody($body);
#$message->Attachments('c:\Card.pdf');
$message->send;
 
B

Brian Wakem

Hi,

I am using Mail::Outlook to send email through Outlook.


Why on Earth would you want to do that?

I've set out
the code below. Everything works fine but I have two items on my wish
list.

1. To be able to send attachments. I have tried
'$message->Attachments('c:\file.txt');' and
'$message->Attachments.Add('c:\file.txt');' but neither work.
2. To be able to send the email in html format but
'$message->HTMLBody($body);' doesn't work.



The module's documentation does not mention either $message->Attachments or
$message->HTMLBody. Have you just made these up in the hope it might work?


Are either of these possible using Mail::Outlook or do I need to go
back to scratch and use another module?



Try MIME::Lite.
 
A

A. Sinan Unur

I am using Mail::Outlook to send email through Outlook. I've set out
the code below. Everything works fine but I have two items on my wish
list.

1. To be able to send attachments. I have tried
'$message->Attachments('c:\file.txt');' and
'$message->Attachments.Add('c:\file.txt');' but neither work.
2. To be able to send the email in html format but
'$message->HTMLBody($body);' doesn't work.

Are either of these possible using Mail::Outlook or do I need to go
back to scratch and use another module?

Unless the only way you can send email is through Outlook, I would
recommend looking at other modules.

perldoc -q "How do I send mail"

If you *must* use Outlook to send email, looking at Mail::Outlook and
Mail::Outlook::Message, my instinct is to ditch the module.

Note that an excellent source of information for Microsoft Office
applications is the Object Browser. You can access it via Tools -> Macro
-> Visual Basic Editor. Once you are in the editor, hit F2 to browse the
interfaces, methods, and properties provided by Microsoft Office
applications.

An example of dealing with Outlook via OLE:

http://www.unur.com/comp/ppp/perl-win32-ole-outlook-ex1.html

Sinan
--
A. Sinan Unur <[email protected]>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top