Accessing Outlook mail via Mail::Outlook

PERL

    Next

  • 1. How do i call a module !
    Hi there ! I'm very new to perl and i'm asked to call a particular perl module using a function ! how do i go about ??? Should use MODULES::Filename ..? The problem is i'm not sure what are the values to be passed on to that ! This module basically parses the html file and pushes all the links in to a database ! Please help Thanks Joe
  • 2. Need help with output to file...
    Greetings! I'm new to this perl stuff and I need a little help =) I know that to open a text file and add a line of text to the END of it I would add something like this to my script: open (JUNKFILE, ">>junk.txt"); print JUNKFILE ("${junk1}::${junk2}\n"); close (JUNKFILE) What I really want to be able to do is add the line of text to the BEGINNING of the file. How would I go about doing this? Thanks! =Carnage=
  • 3. Perl 6 and oop
    I have been on a C++ project for about a thousand years and had to drop out of my PerlTK intensive learning for the duration. I didn't realise how much I liked it until I went back to a language where you have to have an active suicide watch on a team that is in their seventh day of trying to find a loose pointer. Anyway, as I started again looking at the news on perl.com, I saw all the stuff about Perl 6 OOP. Can it really be?? Obviously not yet, since there is no download option but anybody know about when? There didn't seem to be a time line for release. This would make a major difference in some large projects we have coming up. Thanks all Konan
  • 4. Web based admin using PERL and CGI
    Hey all, I am thinking I'd like to "browserize" a number of simple functions, please correct me if I understand what I'd need to do. Lets say I want to run a pkginfo command on my web server, and return teh results to a browser, I'd need to call a ksh script from a CGI module? So I'd make a form in perl, where I could button select which packages I wanted to see, then pass those package names so in effect on the back end I could do a pkginfo |grep <FROM_WEB_FORM> So I can write the ksh easy, my question is how to call it and return the results I guess. I am sure this is all documented, and I know there's been a lot of talk of calling seperate programs from perl, does this fit? Can someone point me in the right direction for documentation on how to do this. Basically I need to be able to call ksh scripts and pass them operands, and parse the results into a list/form for a browser. Thanks, Jason

Accessing Outlook mail via Mail::Outlook

Postby jason_normandin » Fri, 27 May 2005 03:34:26 GMT

reeting.

I am trying to create a script that will search a user's outlook email and move any messages that mtahc a certain subject to a new folder. To accomplish this I found the Mail::Outlook module on CPAN that allows me to easily access the OLE Outlook calls via Win32::Ole.

My problem is this, the Mail::Outlook module does not have a specific method to move an email from one mailbox to another. I can display the email when my match occurs, but I cannot figure out how to move it.

Here is an example of my code that works just find to pop-up an display any messages in my mailbox that match :

use Mail::Outlook;
use strict;

# Open filehandle to Remedy report file
open (_TICKETS,'C:\TicketCounts\MyOpen.rep') or die "Cannot open C:\TicketCounts\MyOpen.rep : $!";
# Iterate through each line of the file
print "Obtaining list of open tickets from $remedyReportFile .... ";
while (<_TICKETS>){
# Add ticket number to array in csv format
push @myTickets, "$1" if m/CallT0000(\d+)/;
}
print " Ok.\n";
# Open an Outlook OLE connection
print "Opening connection to Outlook .... ";
my $outlook = new Mail::Outlook('') or die "Cannot create mail object\n";
# Change to the Support mail folder
my $folder = $outlook->folder('Inbox/Support') or die "Cannot create folder object\n";
# Read the 1st message
print " Ok.\n";
print "Searching messages for call ticket match .... " unless defined $bodyMatchString;
print "Searching messages for subject containing: call ticket matches and body containing: $bodyMatchString ... " if defined $bodyMatchString;
my $message = $folder->first();

# Iternate all messages in the folder
while ($message) {
# Strip the call ticket number out of the subject
my $callTicketNumber=$1 if $message->Subject() =~ m/CallT0000(\d+) /;
# If a call ticket number was found, compare against the user's open call tickets
if (defined $callTicketNumber) {
if ( (grep /$callTicketNumber/, @myTickets) ) {
$emailMatches++;
$message->Display;
}
}
}

Now, I want to change the $message->Display to a move operation. Searching the available OLE/COM Objects for Outlook via Microsoft's OLE/COM Viewer, I see that there is a move method for the mailItem CO class:

[id(0x0000f034), helpcontext(0x004de8b9)]
IDispatch* Move([in] MAPIFolder* DestFldr);

I tried editing the Outlook::Mesage.pm file (that stores the message display call) to add a call to this OLE method.

The 1st thing I did was to see if I could simply add a new su b to the PM file called moveMessage that in actually would simply display the messag the same way the display sub did:

sub moveMessage {
my ($self,%hash) = @_;

# pre-populate the fields, if hash
foreach my $field (@autosubs) {
$self->{$field} = $hash{$field} if($hash{$field});
}

# we need a basic message fields
return 0 unless($self->{To} && $self->{Subject} && $self->{Body});

# Build the message
$self->{message}->{To} = $self->{To};
$self->{message}->{Cc} = $self->{Cc} if($self->{Cc});
$self->{message}->{Bcc} = $self->{Bcc} if($self->{Bcc});
$self->{message}->{Subject} = $self->{Subject};
$self->{message}->{Body} = $self->{Body};

# Send the email
$self->{message}->Display();

return 1;
}

I thought this would be an easy 1st step, but come to find out, I am getting teh following error when I run this:

retrying default

Similar Threads:

1.Accessing Outlook mails via Access

2.Sending mail through Mail::Outlook

Hi,

I am using Mail::Outlook to send email through Outlook. I've set out
the code below. Everything works fine but I have two items on my wish
list.

1. To be able to send attachments. I have tried
'$message->Attachments('c:\file.txt');' and
'$message->Attachments.Add('c:\file.txt');' but neither work.
2. To be able to send the email in html format but
'$message->HTMLBody($body);' doesn't work.

Are either of these possible using Mail::Outlook or do I need to go
back to scratch and use another module?

Thanks

Paddy

#################################################################################
# CODE

#!/usr/bin/perl

use strict;
use warnings;

use Mail::Outlook;
use Win32::OLE::Const 'Microsoft Outlook';
my $outlook = new Mail::Outlook();

my $to = "my_mom\@moms_mail.com";
my $body = "Hi Mom!\n\n etc.";
my $message = $outlook->create();

$message->To($to);
$message->Cc();
$message->Bcc();
$message->Subject('Happy Mothers Day, Mom!);
$message->Body($body);
#$message->HTMLBody($body);
#$message->Attachments('c:\Card.pdf');
$message->send;

3.Outlook 2007 sent mail now showing properly in other mail clients

Being a happy outlook 2003 user I just upgraded to outlook 2007. But I'm 
experiencing some strange problems which I was hoping someone could clarify...

E.g. I send following mail to a Gmail account :

Line1
Line2
Line3

When I view the mail via Gmail's web interface I get :

Line1

Line2

Line3

As you can see extra lines are inserted after each hard return. Outlook 2003 
does not have this problem. Everything looks fine when I view the sent mail 
from within O2007, but Gmail does not show it correctly anymore. Similarly, a 
O2007 sent mail containing a bulleted list viewed in Gmail shows no bullets 
anymore. Again, outlook 2003 did not have any problems with sending bulleted 
mails to Gmail.

I am aware of the issues surrounding Outlook 2007's HTML rendering 
capabilities, but this has nothing to do with it. This is all about 
compatibility with other mail clients (even my lotus notes account from work 
definitely shows O2007 mails differently then O2003 sent mails).

Much appreciated if someone can clarify this odd O2007 behaviour.

Thanks,

Kris

4.Can I use Outlook 98 to retrieve/send mail via Outlook Web Access

When my work vpn is down, I can access our server and retrieve emails via Web 
Access.  Is there a way to synch my outlook 98 with this outlook web access 
so that I can send and receive emails in Outlook 98?  I often have emails 
already written in Outlook but they won't send when I log onto the web access.

5.Configuring Outlook to pcik up mail via outlook web access

Is it possible to setup outlook 2003 so that it actually picks up email from 
an outlook web access server. If so how would i go about this?

Thanks

Jonathan Main

6. Sending Mail from Access 2000 via Outlook

7. Send Outlook Appointment via E-mail from Access 2007

8. MS Access and sending mail via MS Outlook



Return to PERL

 

Who is online

Users browsing this forum: No registered users and 57 guest