I wanted to make a program to scan a particular folder in my outlook 2003 that holds messages placed there by a rule. However, due to outlook security, a pop up appears to confirm access to outlook when you try to access the emails. This is a major roadblock to automating email access on windows xp. I could not find a clear example on the web that used another pst file so I created this example. I hope this helps someone out down the line.

There is a solution called Outlook Redemption that solved the pop-up problem for me. You can install a copy on windows from the site http://www.dimastr.com/redemption/ .

Once you have this installed, make sure you have a copy of strawberry perl http://strawberryperl.com/ . I happen to use version 5.8 but I will switch to 5.10 soon. With this installed, you will also need the module Win32 installed, but this is easy since you can install perl modules with CPAN on windows when you have strawberry perl setup.

Here is the code that scans a different pst file called otherpst and a folder within that pst file called scanme

#!perl # windows notation

use strict;
use Win32::OLE;
use Win32::OLE::Const;
use Win32::OLE::Const ‘Microsoft Outlook’;
my $outlook;
eval {
$outlook = Win32::OLE->GetActiveObject(’Outlook.Application’)
};
if ($@ || !defined($outlook)) {
$outlook = Win32::OLE->new(’Outlook.Application’, sub {$_[0]->Quit;})
or die(”Cannot create outlook\n”);
}

my $namespace = $outlook->GetNamespace(’MAPI’);

# get the proper pst file
my $folder = $namespace->{’Folders’}{’otherpst’};

# now get the folder within the pst file
my $folder2 = $folder->{’Folders’}{”scanme”};

# get all the messages
my $msgs = $folder2->{Items};

# a count of the number of messages in the folder

my $ncon = $msgs->{Count};

# a redemption object that stops the annoying popup

my $tysonmaly = new Win32::OLE(’Redemption.SafeMailItem’);

my $con;

# for each message in the scanme folder print the body out to STDOUT

foreach my $ii (1 .. $ncon) {
$con = $msgs->Item($ii);
$tysonmaly->{’Item’} = $con;

# you can access other things like the subject or sent time or sender but this just shows body access

print $tysonmaly->{Body} . “\n”;

}

I have been meaning to starting updating my site, and I have always wanted to list the restaurants I have come across in my travels. Today I was driving up north street to check out an Indian restaurant that I saw one day. It just happened that they were closed till 5 pm. So I headed back down towards main street. On the way I saw a sign for pho vietnam restaurant and decided to give it a shot. I usually am able to find good places using zagat, but this time, zagat was not up to date. They last rated the place in 2004-2005. The place was small, but the food smelled great. I started out with two orders of spring roles. They were huge and quite filling. For the main course I ordered this chicken dish with pineapple in a sauce with rice. My partner ordered a pork dish with a red curry and coconut milk. Both dishes were excellent, and the place was very reasonably priced. The final bill with tip was $36, but it would have been $10 cheaper without the spring rolls. I left there with a full stomach and half a dish left for a midnight snack. If you are interested in checking this place out, you can get directions off of their website www.phovietnamrestaurant.com

This article shows how to automate the creation of PDF reports using perl. The module PDF::API2 provides raw access to creating pdf files.
The PDF::API2 module gives you the ability to automate the creation of beautiful PDF reports without the need to purchase expensive software. Using the PDF::Table module, one can generate complex tables in your report. One can abstract out many of the common features of a report and create an entire framework for generating reports. Here is some sample code that creates a landscape page with a title and a line.

use strict;

use PDF::API2

# create a pdf object giving it the name of the file to save the pdf to

my $pdf = PDF::API2->new(-file => “report1.pdf”);

my $font = $pdf->corefont(’Helvetica-Bold’);

my $page = $pdf->page;

$page->mediabox(792,612);

# create a text label

my $txt = $page->text;

$txt->textlabel(72,540,$font,20,”Title of report1″);

# create a line

my $gfx = $page->gfx;

$gfx->strokecolor(’#000000′);

$gfx->move(72,360);

$gfx->linewidth(1);

$gfx->line(720,360);

$gfx->stroke;

$pdf->save;

« Previous Page