in reply to Mail & Win32

I believe you can use OLE on it's own - it should be self-sufficient. I assume that your problem is reading the mail as soon as it arrives. Have you had a look at the Inspector object in Outlook ? It could be very useful since it allows you to find different items, then what you could do is have a permanent scan (for example every minute) and check whether new items have come in the inbox (provided there are no rules sending mail to other folders). You can also check whether these items are emails with the following :
if ( my $outlook = Win32::OLE->GetActiveObject('Outlook.Application')) +# connect to outlook application { # next line for debug only # print "\nSuccessfully connected to existing outlook & email"; + if (defined ($outlook->ActiveInspector())) { my $activeEmail= $outlook->ActiveInspector()->{CurrentItem}; if ($activeEmail->{Class}==olMail) # if we're dealing with an + email item { print "ok it's a mail"; } } }

This code analyses the currently open item, but it's very easy to make it scan the entire inbox, make it build a hash and each time you scan the inbox you can check to see which mails are new (not unread only new). You can then append these new mails to your hash and use the hash to generate your webpage.
If you want to run your code at a specific time, why not check the system's time, and compare it to the desired time of execution ?
Heureux qui, comme Ulysse, a fait un beau voyage
Ou comme celui-là qui conquit la Toison,
Et puis est retourné plein d'usage et raison,
Vivre entre ses parents le reste de son âge!

J. du Bellay, poëte angevin

Replies are listed 'Best First'.
Re: Re: Mail & Win32
by Mitch (Sexton) on Jun 27, 2003 at 17:16 UTC
    The problem is with automating the job not with the code itself. If I run the job manually it is able to read the mail with no problems. If I run the job manually with a continuous scan there's no problem. However, if I schedule the job or run the code as a service it fails for the reasons described in the article.

    http://support.microsoft.com/default.aspx?scid=kb%3ben-us%3b237913

    I was hoping for another method like Win32::Mapi, but I'm not even sure if that works with Public Folders and I'm having trouble getting the module.

    Mitch
      Is there a cron is Cygwin or PPT? That may be a good idea for this. I'm currently unsure about those offerings.

      Your best option for now may be to have your script run at startup from a run key in the registry or from the startup program group. Then, in order to do what you want every so often, put the code that performs the action in a loop and include a sleep $seconds; statement at the beginning or end of the loop.

      If more accurately spacing the times (depending on various running times of your program) is a priority, you can start the loop like this:
      my $interval = 600; #for ten minutes, adjust as needed my $time_to_work = time() + $interval;
      And end it like this:
      sleep ($time_to_work - time());
      I should point out that this is not pretty even in my mind, but I've used similar code before when running time was variant on input or on network load. You can move the first part (excepting the declarations, of course) to the bottom of the loop and the last part to the top of the loop in order to make it wait before instead of after your main work.

      This means your code is always running, but it's usually taking up (at least very close to) no processor time.

      Christopher E. Stith
        Actually as a temporary solution that's how I have it running. But, I need to find another way, since it's running on a server and I can't stay logged on forever.

        So, the problem remains of finding another module or way of scheduling the job.