in reply to Re^2: Send Outlook 2007 email
in thread Send Outlook 2007 email

...just hazarding a guess, based on the fact that the you are using threads, and the error message....

it seems line35 is Can't call method "Messages" on an undefined value... and what might that value be?..... i can't be sure it's line 35, but it looks like

# Create a new message $msg = $session->Outbox->Messages->Add();
...so it seems that either $session is not shared (i.e. available in the thread )...or...$session->Outbox is not returning what you think with the new Outlook version try:
print "$session, $session->Outbox\n"; $msg = $session->Outbox->Messages->Add();
.... some possible things to watch for?..... $session->Outbox is now returning an array or something different from the earlier version..... or the new Outlook isn't thread safe, or something ..... by the way, the code looks like complete crap as far as thread variable management goes.....you seem to rely on being able to make $session a global object, and hoping the global nature extends into the thread..... the fact it even worked earlier is surprising..... but i don't do win32....so i just observe

I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku

Replies are listed 'Best First'.
Re^4: Send Outlook 2007 email
by meredib (Acolyte) on Nov 12, 2009 at 17:18 UTC

    Correction I did comment out some fields before I pasted them in to the code because I was trying to fix the code. To create the session I was using the following in Outlook 2003.

    my $session = Win32::OLE->new("MAPI.Session") or die "Failed to create + a MAPI Session: $!";

    When I add the script you stated it prints out the following "Win32::OLE=HASH(0x225378), Win32::OLE=HASH(0x225378)->Outbox"

    What would you recommend using besides Win32?