Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

--force Outlook to allow perl script access to my mail

by silent11 (Vicar)
on Feb 20, 2003 at 23:29 UTC ( #237271=perlquestion: print w/ replies, xml ) Need Help??
silent11 has asked for the wisdom of the Perl Monks concerning the following question:

I am using Win32::OLE to access my MS Outlook(XP) mail via command line. However, when I do, I get a warning prompt from Outlook ("Another program is trying to access email addresses you have stored in Outlook. Do you want to Allow this?"). I am trying to get around having to *allow* this process acces every time it runs. Any body know of a way to get around this? Is there a "--force" option I can use somewhere?

Furthermore, I would also like to display this information to a webpage (IIS Web service running as me w/ Admin rights). For some reason whilist browsing this script via browser (with added 'Content-type' etc, etc..) The script Just hangs and I don't get the warning prompt as I do when running the script from the command line. Any thoughts?

I know I shouldn't be serving anything over the web running as myself, I'm just playing around, testing, and wondering why this won't work ;)

Here is the code:

#!/usr/bin/perl # simplified version use strict; use Win32::OLE qw(in with); use Win32::OLE::Const 'Microsoft Outlook'; my $mailbox = "Mailbox - Silent11"; $Win32::OLE::Warn = 3; my $outlook = Win32::OLE->new('OutLook.Application','Quit') or die "Could not created outlook object."; my $ol = Win32::OLE::Const->Load($outlook); my $inbox = $outlook->GetNameSpace("MAPI")->Folders($mailbox)->Folders +("Inbox"); for (in $inbox->{Items}) { print "Subject : $_->{Subject}\n"; print "Sender : $_->{SenderName}\n"; print "Attachments : $_->{Attachments}{Count}\n"; print "\n\n"; }


-Silent11

Comment on --force Outlook to allow perl script access to my mail
Download Code
Re: --force Outlook to allow perl script access to my mail
by jacques (Priest) on Feb 21, 2003 at 01:17 UTC
    I get a warning prompt from Outlook

    If the prompt is an OLE object, perhaps you can have Perl signal "OK" to the prompt. (You might also be able to remove this security restriction, but I doubt it.)

    Furthermore, I would also like to display this information to a webpage (IIS Web service running as me w/ Admin rights). For some reason whilist browsing this script via browser (with added 'Content-type' etc, etc..) The script Just hangs and I don't get the warning prompt as I do when running the script from the command line. Any thoughts?

    Could the problem be that the script running through the Web server cannot open the outlook application (thus, no warning prompt)? Are you working with an Exchange server? If you are, you probably have Outlook Webmail installed. You could have Perl login to Webmail, grab the contents of your inbox, and spit it out for you as a webpage. Or you perhaps could tell Exchange to publish your inbox as a webpage. I often see this done for calendars, but I am not sure if you could also do this for inboxes as well.

Re: --force Outlook to allow perl script access to my mail
by Anonymous Monk on Feb 21, 2003 at 03:20 UTC
    Not a Perl solution, but ... http://www.express-soft.com/mailmate/clickyes.html
Re: --force Outlook to allow perl script access to my mail
by blackstarr (Pilgrim) on Feb 21, 2003 at 10:16 UTC
    In addition to the comments above, if your Outlook client accesses an Exchange server, then the security settings for programmatic access to the mailbox and addresslist can be controlled by your Exchange Administrator.

    For further information about WHAT is happending, refer to OL2002: Add-in or Custom Solution Causes a Warning to Appear.

    For what an Exchange admin can do about it, refer to OL2002: Administrator Information About E-Mail Security Features.

    I have a number of automated reporting systems that generate output in various formats, one of which is attachments in Outlook e-mail messages, and the simplest solution, from my point of view (programming), was to implement the custom security settings referenced in the above articles. I have used this solution for months and have found them to work perfectly.

    So Long
    blackstarr

Re: --force Outlook to allow perl script access to my mail
by pantonini (Initiate) on Feb 21, 2003 at 13:57 UTC
    Win32::OLE Microsoft Outlook E-mail security update The Outlook E-mail Security Update provides additional levels of protection against malicious e-mail messages. The update changes the way that Outlook can be controlled programmatically (Microsoft knowledgebase Q262701). Sending mail and accessing the Adress book display a dialog box asking you to confirm the action Dmitry Streblechenko at http://www.dimastr.com has released Redemption (http://www.dimastr.com/redemption/), an OLE object that works around limitations imposed by the Outlook Security Patch. Here is an example of using Redemption with Perl :
    #!c:/perl/bin/perl use locale; use warnings; use Win32::OLE; use Win32::OLE::Const; use Win32::OLE::Const 'Microsoft Outlook'; $MailProps{'to'} = "sendto\@myserver.com"; $MailProps{'cc'} = "sendcc\@myserver.com"; $MailProps{'bcc'} = "sendbcc\@myserver.com"; $MailProps{'importance'} = 2; # 2=high, 1=normal, 0=low $MailProps{'subject'} = "Message subject"; $MailProps{'body'} = "Message body"; @Attachement = ("d:\\test.doc"); $MailProps{'attachments'} = \@Attachement; $Error = &OUT_SendMail (\%MailProps); print "Return error : ".$Error."\n"; exit; sub OUTLOOK_SendMail { my ($rMailProps) = @_; my $Application = new Win32::OLE('Outlook.Application'); my $MailItem = $Application->CreateItem(0); # 0 = mail item. unless (defined $MailItem) { print "Outlook is not running, cannot send mail.\n" if $Debug; return 1; } # Create a Redemption object my $SafeMailItem = new Win32::OLE('Redemption.SafeMailItem'); unless (defined $SafeMailItem) { print "Redemption is not running, cannot send mail.\n" if $Debug +; return 1; } # Set Item property of the Redemption object $SafeMailItem->{'Item'} = $MailItem; $SafeMailItem->{'To'} = join(";", split(/[ ,;]+/, $rMailProps->{'to +'})); $SafeMailItem->{'Cc'} = $rMailProps->{'cc'} if (exists $rMailProps- +>{'cc'}); $SafeMailItem->{'Bcc'} = $rMailProps->{'bcc'} if (exists $rMailProp +s->{'bcc'}); $SafeMailItem->{'Subject'} = $rMailProps->{'subject'} || '[No Subje +ct]'; $SafeMailItem->{'Body'} = $rMailProps->{'body'} || "\r\n"; $SafeMailItem->{'Importance'} = (exists $rMailProps->{'importance'} +)? $rMailProps->{'importance'} : 1; if (exists $rMailProps->{'attachments'}) { my $attach = $SafeMailItem->{'Attachments'}; foreach my $attach_file (@{ $rMailProps->{'attachments'} }) { if ($attach_file and -f $attach_file) { $attach->add($attach_file); } } } $SafeMailItem->Send(); return 0; }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://237271]
Approved by Enlil
Front-paged by TStanley
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (19)
As of 2014-07-11 15:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (230 votes), past polls