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

Sorry forgot. Before it would just send all the emails that were in a txt file, and since updating I still want to send from the same txt file but am getting the following error:
Can't call method "Messages" on an undefined value at P:\bin\SendEmail +FromFileViaMAPIOutlook_v2.pl line 35, <IN> line 49. A thread exited w +hile 2 threads were running, <IN> line 49.

Replies are listed 'Best First'.
Re^3: Send Outlook 2007 email
by zentara (Cardinal) on Nov 12, 2009 at 12:27 UTC
    ...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

      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?