in reply to Send Outlook 2007 email

...i don't use win32, but it would be helpful if you described the problem you are having with ->Add()...... like what did it do before, and what does it do now, and/or the exact the error messages you get

Migration from Outlook to any other mail program might interest you


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

Replies are listed 'Best First'.
Re^2: Send Outlook 2007 email
by meredib (Acolyte) on Nov 11, 2009 at 16:53 UTC
    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.
      ...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?