Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

MS Outlook & Win32::OLE

by SageMusings (Beadle)
on Apr 10, 2001 at 01:29 UTC ( #71169=perlquestion: print w/replies, xml ) Need Help??

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

Mighty Buddha, Annoint me with knowledge, shine your benevolent intellect upon my unworthy brain. Do you have a skeleton bit of code to excercise MS Outlook's objects to compose a simple message and then send it? I desperately need to do this on a system where the only option is Outlook, with no SMTP I can directly access. I tried some MAPI examples I have found, but none work. My humble apologies for interrupting your meditations...

Replies are listed 'Best First'.
Re: MS Outlook & Win32::OLE
by MeowChow (Vicar) on Apr 10, 2001 at 03:03 UTC
    Perhaps this will help - I found it gathering dust on my hard drive:
    use strict; use Win32::OLE; use Win32::OLE::Const; my $text = "Test message text"; my $m_ses = Win32::OLE->new('MSMAPI.MAPISession'); my $m_msgs = Win32::OLE->new('MSMAPI.MAPIMessages'); $m_ses->SignOn; $m_msgs->{SessionID} = $m_ses->{SessionID}; $m_msgs->Compose; $m_msgs->{MsgSubject} = "blargh"; $m_msgs->{MsgNoteText} = $text; $m_msgs->{AttachmentName} = 'bolbus flowerius'; $m_msgs->{AttachmentPathName} = 'C:\boot.ini'; $m_msgs->Send(1);
       MeowChow                                   
                   s aamecha.s a..a\u$&owag.print
Re: MS Outlook & Win32::OLE
by chromatic (Archbishop) on Apr 10, 2001 at 01:59 UTC
    The Perl for System Administration book (available here) has some examples in chapter 8. You might download the example code.

    The author also suggests the Win32::MAPI module to make things easier, if you can't use Win32::OLE.

    If I were in your situation, I'd try PSA example code first. It doesn't look too tough.

Re: MS Outlook & Win32::OLE
by SageMusings (Beadle) on Apr 10, 2001 at 03:20 UTC
    Bodhisatvas,

    Thank you for your wisdom. I found a VB script and translated it. Here it is, without any error checking:

    use Win32::OLE; $mail = new Win32::OLE('Outlook.Application'); $mail->{'Visible'} = 1; $item = $mail->CreateItem(0); $item->{'Subject'} = "This is a test"; $item->{'To'} = "mccoyga\@1fssg.usmc.mil"; $item->{'Body'} = "Here is the meat of the message"; $item->Send(); $mail->Quit();
    Again, your time and effort is most appreciated. May I reincarnate to your level, some day.
      Can someone lend me some advice on how to get the meat from an array into the Body ? $item->{'Body'} = "Here is the meat of the message"; I can't seem to get the syntax to work on : $item->('Body') = @BODY; or $item->('Body') = print @BODY; Thanks!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://71169]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2022-08-18 20:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?