Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Deleting Exchange Email

by martydavis (Initiate)
on Jan 20, 2014 at 21:03 UTC ( #1071380=perlquestion: print w/replies, xml ) Need Help??
martydavis has asked for the wisdom of the Perl Monks concerning the following question:

I have hade some success readung folders and email with the library module Email::Folder::Exchange::EWS. What's missing from the module is the ability to delete a message -- although Exchange 2010 EWS has a web service 'DeleteItems'

I am good until I attempt to DeleteItems. Getting 'Can't locate object method "proxy" via package "Email::Simple" at c:/PerlNew/site/lib/SOAP/ line 3774. ' Any help will result in a profusion of thanks <\p>

#!/usr/local/perl5/bin/perl -w use strict; use Email::Folder::Exchange::EWS; SOAP::Lite->import( +trace => 'all' ); my $folder = Email::Folder::Exchange::EWS->new('https://webmailNY.XX', 'domain\gsa_spectrum_mb_read', 'pass +word'); for my $message ($folder->messages) { print "subject: " . $message->header('Subject'); my $from_header = $message->header("From"); my @header_names = $message->header_names; my $header = $message->header_obj; my $message_id = $message->header('Message-ID'); my $method = SOAP::Data->name('DeleteItems') ->attr({xmlns => ''}); my @params = ( SOAP::Data->name('Message-ID' => $message_id)); print $message-> SOAP::Lite::call($method => @params)->result; print 'end'; }

Replies are listed 'Best First'.
Re: Deleting Exchange Email
by Anonymous Monk on Jan 21, 2014 at 04:04 UTC

      Wow, thanks. I got past the validation portion and now in authentication hell {checked Dante -- no help!}. I am getting

      Client-Warning: Unsupported authentication scheme 'negotiate' Set-Cookie: exchangecookie=ea8a495701ec4aebbe718c3fd0c908ba; expires=W +ed, 21-Jan-2015 13:00:21 GMT; path=/; HttpOnly X-Powered-By: ASP.NET 401 Unauthorized at C:\Perl Scripts\ line 44.

      I checked user's privileges to delete email-- ok. Here is what I modified. {lifted some from EWS - I'm clearly an amature }

      my $soap = $folder->soap; $soap->on_action( sub { MESSAGES_NS . "/$_[1]" }); # setup the schemas $soap->ns(TYPES_NS, 't'); $soap->default_ns(MESSAGES_NS); $soap->uri(MESSAGES_NS); # EWS does not like the encodingStyle attribute $soap->encodingStyle(""); my $method = SOAP::Data->name('DeleteItems') ->attr({xmlns => ''}); my @params = ( SOAP::Data->name('Message-ID' => $message_id)); $soap = SOAP::Lite->proxy(' +x'); sub SOAP::Transport::HTTP::Client::get_basic_credentials { return ('XX +XX\gsa_spectrum_mb_read' => 'XXXX') }; print $soap-> SOAP::Lite::call($method => @params)->result; print 'end';

        ... now in authentication hell ...

        well, study the source code ... all that on stuff only happens in ->new

        it doesn't happen anywhere place else

        you should not duplicate that , refresh_messages, neither does any other method

        Did I mention I hate SOAP?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1071380]
Approved by boftx
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2017-05-28 04:58 GMT
Find Nodes?
    Voting Booth?