I think there might be a problem with your CreateItem() method failing to return an object. Since you don't have
strict turned on (shame on you!) you didn't find out that $mailitem is not
defined. Then you use it as a hash ref, which Perl is happy to do for you. And then you try to call send on a hash ref, not an olMailItem (or whatever).
So the simple answer is, use strict; and check your Ole calls with or die. Be sure to read up on Ole mechanisms and the COM Interface to Outlook. The better answer is open Outlook and figure out where the mail server is. Then use Net::SMTP or MIME::Lite or the like. Doing it this way cuts out the overhead of loading Outlook and eliminates your dependence on both MS and Outlook being installed.
Update:
dws caught the source of your Ole error, the constant, but he didn't give you the right answer for what to do about it. You should import the constants via Ole:
use Win32::OLE::Const;
my %olConst = %{ Win32::OLE::Const->Load( "Microsoft Outlook" ) };
Then you can just get them out of that hash table.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.