Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^3: How to read only unread mail from Outlook Inbox

by GotToBTru (Prior)
on Nov 26, 2014 at 15:11 UTC ( [id://1108461]=note: print w/replies, xml ) Need Help??


in reply to Re^2: How to read only unread mail from Outlook Inbox
in thread How to read only unread mail from Outlook Inbox

Your code is unreadable. Please put <c> ... </c> tags around your code. See also Markup in the Monastery.

1 Peter 4:10
  • Comment on Re^3: How to read only unread mail from Outlook Inbox

Replies are listed 'Best First'.
Re^4: How to read only unread mail from Outlook Inbox
by karthik.raju (Acolyte) on Nov 28, 2014 at 11:24 UTC

    Hi Satish, what is the bug/error in the below code, actually this is the same code that you have sent, i've done slight modification. This is working fine, and also i'm getting the value for the "To()" (mailid) but i'm not getting the mail id for "From()". Please help on this. Here is the code:-

    use strict; use warnings; use Win32::OLE; use Win32::OLE::Const 'Microsoft Outlook'; my $outlook; $outlook = Win32::OLE->new('Outlook.Application'); die unless $outlook; my $namespace = $outlook->GetNamespace("MAPI"); my $folder = $namespace->GetDefaultFolder(6); my $items = $folder->Items; my $cnt=$items->Count; for my $itemIndex (1..$items->Count) { my $message = $items->item($itemIndex); next if not defined $message; if ($message->{'Unread'}) { my $text = $message->Subject(); my $from_user = $message->From(); my $to_user = $message->To(); print "Unread Email from $from_user and to $to_user\n"; } }

    I'm getting error message as shown below:-

    "Use of uninitialized value $from_user in concatenation (.) or string at Perl_ABC.pl line 19. Unread Email from and to SurName (ABC), MiddleName

    why we are not getting the value for "From()" ? is there any mistake in my script ?

    Thanks, Karthik

      Seems there is currently none of the monks involved with Outlook deeply enough. And then Outlook seems a bit diffident about senders' addresses. Google found this, which may be of help to you although it's not Perl...

      Update: tried it out myself, you get more or less sensible results if you replace $message->From() with $message->SenderName(). If you really want the address, $message->Sender()->Address() worked for me, and SenderName() seems to be an alias for Sender()->Name().

        Hi Soonix,

        Thanks for your update, its working fine for me.

        Regards, Karthik

Re^4: How to read only unread mail from Outlook Inbox
by karthik.raju (Acolyte) on Dec 01, 2014 at 09:19 UTC
    Hi Satish, i've posted again with a readable format. Please help on this bug. Thanks, Karthik

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1108461]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-04-19 23:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found