Solved

how to access INBOX using perl

Posted on 2004-03-28
26
740 Views
Last Modified: 2013-12-18
Is there any way That I can access INBOX or any other folder Example testfolder using PERL
to list subject and date and sender name, I have been able to access AllDocuments folder but not be able to access INBOX or testfolder, could you please guide how can I do this I have open question in PERL forum but I did not have any solution yet??
0
Comment
Question by:melindaj
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 12
  • 8
  • 4
  • +1
26 Comments
 
LVL 19

Expert Comment

by:RanjeetRain
ID: 10701945
I think you are trying to refer to Inbox folder as 'Inbox'. In fact, DOmino implements it as '($Inbox)'.

Try accessing ($Inbox) folder.
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 10704558
Ranjeet event All Documents internally refered as ($All) ?

melindaj, it is worth trying what Ranjeet proposed..

~Hemanth
0
 
LVL 31

Expert Comment

by:qwaletee
ID: 10704720
What are you using to access Domino?  The PERL-to-COM library?  Or the PERL Domino library?  Please post a link to which library you downloaded for this, and teh code you were using that does work for All Documents, and the code you are using that fails for others.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 19

Expert Comment

by:RanjeetRain
ID: 10705754
Hemantha, I thought may be he used some demo code or something. In that case he could only be needed to know the correct name. Otherwise, we can always analyze, like Qwaletee said.
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 10706007
There is only one difference All Documents is a view and Inbox is a folder !
0
 

Author Comment

by:melindaj
ID: 10710135
Hi,
Thanx for reply,
I am accessing my data.nsf file from dos prompt using PERL script as bellow, it is working fine aslong as I am using $AllDocuments, but If I change $AllDocument to $Inbox or any other folder having problem the first problem I get
Can't call method "Count" on an undefined value at j5a.pl line 10.

use strict;
use Win32::OLE;
my $Notes = Win32::OLE->new('Notes.NotesSession')
    or die "Cannot start Lotus Notes Session object.\n";
my $Database = $Notes->GetDatabase('', 'data.nsf');
my $AllDocuments = $Database->AllDocuments;
my $Count = $AllDocuments->Count;
print "There are $Count documents in the database.\n";
for (my $Index = 1 ; $Index <= $Count ; ++$Index) {
    my $Document = $AllDocuments->GetNthDocument($Index);
      
    printf "$Index. %s\n", $Document->GetFirstItem('Subject')->{Text};
    my $Values = $Document->GetItemValue('Index_Entries');
    foreach my $Value (@$Values) {
        print " Index: $Value\n";
    }
    last unless $Index < 5;
}
0
 
LVL 19

Expert Comment

by:RanjeetRain
ID: 10711751
Try this:

use strict;
use Win32::OLE;
my $Notes = Win32::OLE->new('Notes.NotesSession')
   or die "Cannot start Lotus Notes Session object.\n";
my $Database = $Notes->GetDatabase('', 'data.nsf');
my $Inbox = $Database->GetView('($Inbox)');


Now $Inbox is ready for use.
0
 
LVL 19

Expert Comment

by:RanjeetRain
ID: 10711760
Mind you, ($Inbox) is a folder, so the processing may be a little different.
0
 
LVL 31

Expert Comment

by:qwaletee
ID: 10716101
my $AllDocuments = $Database->AllDocuments;

OK, fundamental misunderstanding of the Notes object model here.  $Database->AllDocuments means "take the OLD object represented by $Database, and retrieve its property named AllDocuments."  You thought AlDocuments represented the All Documents view, but it doesn't.  It is an unsorted NotesDocumentCollection that references every document in the database.

What you want is:

my $viewName = '($All)'
my $view = $Database->GetView($viewName)
my $AllDocuments = $view->AllEntries

Now, AllEntries is a NotesViewEntryCOllection (i.e., it contains the rows of the view, which REPRESENT documents but are not documnets themselves).  You were using AllDocuments before, which is a NotesDocumentCOllection.

So, where you have GetNthDocument, you need GetFIrstEntry and GetNthEntry

Also, since these return entries instead of documents, you can't use GetItemValue directly.  the easist change would be:

my $Values = $Document->Document->GetItemValue('Index_Entries');

Because a view netry -> DOcument returns the NotesDocument object that the view row represents.

Also, you use Lotus.NotesSession, which using the client UI to retrieve the objects.  You shoudl consider using Notes.NotesSession instead.  peration wll be identical but more efficient, except that you may have to initialize the session (password info).

Finally, GetNthENtry and GetNthDocument are very inefficient.  You shoudl use GetFirstEntry/GetENextEntry and GetFirstDocument/GetNextDOcument
0
 

Author Comment

by:melindaj
ID: 10738588
What ever you say that is gun beyond me
I need help In coding
0
 

Author Comment

by:melindaj
ID: 10739056
Thanx for explanation
here is the code that I have changed what is wrong with it now !! I want to list all my mail in INBOX !

use strict;
use Win32::OLE;
my $Notes = Win32::OLE->new('Notes.NotesSession')
or die "Cannot start Lotus Notes Session object.\n";
my $Database = $Notes->GetDatabase('', 'jgolany.nsf');
my $viewName = '($All)';
my $view = $Database->GetView($viewName);
my $AllDocuments = $view->AllEntries;
my $Count = $AllDocuments->Count;
print "There are $Count documents in the database.\n";
for (my $Index = 1 ; $Index <= $Count ; ++$Index) {
    my $Document = $AllDocuments->GetNthDocument($Index);

    printf "$Index. %s\n", $Document->GetFirstItem('Subject')->{Text};
my $Values = $Document->Document->GetItemValue('Index_Entries');

    foreach my $Value (@$Values) {
        print " Index: $Value\n";
    }
    last unless $Index < 5;
}
0
 

Author Comment

by:melindaj
ID: 10748022
I have modified the script as per your recomendation I get the follwoing message

There are 895 documents in the database.
Can't use an undefined value as a HASH reference at jj3.pl line 13

my codes are
use strict;
use Win32::OLE;
my $Notes = Win32::OLE->new('Notes.NotesSession')
or die "Cannot start Lotus Notes Session object.\n";
my $Database = $Notes->GetDatabase('', 'data.nsf');
my $viewName = '($All)';
my $view = $Database->GetView($viewName);
my $AllDocuments = $view->AllEntries;
my $Count = $AllDocuments->Count;
print "There are $Count documents in the database.\n";
for (my $Index = 1 ; $Index <= $Count ; ++$Index) {
my $Document = $AllDocuments->GetFIrstEntry($Index);
printf "$Index. %s\n", $Document->GetNthDocument('Subject')->{Text};
my $Values = $Document->Document->GetItemValue('Index_Entries');

foreach my $Value (@$Values) {
print " Index: $Value\n";
}
last unless $Index < 5;
}
0
 

Author Comment

by:melindaj
ID: 10779607
Any one can Help
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 10780496
There is a flaw on how you are accessing entry object..

Try this code


use strict;
use Win32::OLE;
my $Notes = Win32::OLE->new('Notes.NotesSession')
or die "Cannot start Lotus Notes Session object.\n";
my $Database = $Notes->GetDatabase('', 'data.nsf');
my $viewName = '($All)';
my $view = $Database->GetView($viewName);
my $AllDocuments = $view->AllEntries;
my $Count = $AllDocuments->Count;
print "There are $Count documents in the database.\n";

for (my $Index = 1 ; $Index <= $Count ; ++$Index) {
my $Document = $AllDocuments->GetNthEntry($Index)->Document;
printf "$Index. %s\n", $Document->GetFirstItem('Subject')->{Text};
my $Values = $Document->GetItemValue('Index_Entries');

foreach my $Value (@$Values) {
print " Index: $Value\n";
}
last unless $Index < 5;
}

0
 

Author Comment

by:melindaj
ID: 10856667
Hi Hamantha, qwaletee,
thanx for help but above code does as what my first code does,
I want to know how can I list of the mails in INBOX folder ??
at the beginning I miss understood the concept but thanks to qwaletee for explanation but still I do not know how can I access INBOX folder to list the mails. what do I need todo.
0
 

Author Comment

by:melindaj
ID: 10856669
Hi Hamantha, qwaletee,
thanx for help but above code does as what my first code does,
I want to know how can I list of the mails in INBOX folder ??
at the beginning I miss understood the concept but thanks to qwaletee for explanation but still I do not know how can I access INBOX folder to list the mails. what do I need todo.
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 10859382
Replace this line

my $viewName = '($All)';

With

my $viewName = '($InBox)';

This will access inbox contents..
0
 

Author Comment

by:melindaj
ID: 10865383
Yes this worked, using code above list the subject lines
1- I would like to include in my listing the Who column and Date line column correspond to subject line in from InBox what I need to do ?
2- How can I access other folders example I have Folder called "tony" ?


0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 10869024
To access all other folder do the same as above.. replace the variable viewname accordingly

The who column is a field called From and Date is PostedDate, you have to use this two fields similar to the subject field in your perl script
0
 

Author Comment

by:melindaj
ID: 10923929
Yes, thanks for Date and who filed tip that worked
But I am still unable to access other folders example "tony" I have replace from
my $viewName = '($InBox)'; TO my $viewName = '($tony)';
but I get error message " Can't call method "AllEntries" on an undefined value at jj6.pl line 9 "

Could you please help


0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 10928267
Now it is not $Tony... It will be simply this

$viewName = "tony"

Inbox and AllDocuments view are mail system folders that is why they carry $ infront of them.

0
 

Author Comment

by:melindaj
ID: 10957052
Yes thanks for all the help.
My last question is there any way I can open the body of the message if yes how
In the code provided we are opening 5 mail is there away to open the body of the message??
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 10959836
Will you atleast raise points now ??

To access body field.. use this

Body fields are different data type.. they are called RichText. So you will not get the exact format of the data, but only contents.

my $rtitem = $Document->GetFirstItem('Body');
my $rtText = $rtitem->GetFormattedText(0,0);

0
 

Author Comment

by:melindaj
ID: 10974255
I have increased the points to 250
0
 

Author Comment

by:melindaj
ID: 11027590
Thank you for this entire question, was answered very well,
Thank you again
0
 
LVL 24

Accepted Solution

by:
HemanthaKumar earned 250 total points
ID: 11030725
You are welcome.. Close this question by accepting it.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

  In today’s Arena we can’t imagine our lives without Internet as we are highly used to of it. If we consider our life style just for only 2 min we found that face to face communication is swapped by e-communication.  Every Where from Works place to…
Problem "Can you help me recover my changes?  I double-clicked the attachment, made changes, and then hit Save before closing it.  But when I try to re-open it, my changes are missing!"    Solution This solution opens the Outlook Secure Temp Fold…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question