• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 755
  • Last Modified:

how to access INBOX using perl

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
melindaj
Asked:
melindaj
  • 12
  • 8
  • 4
  • +1
1 Solution
 
RanjeetRainCommented:
I think you are trying to refer to Inbox folder as 'Inbox'. In fact, DOmino implements it as '($Inbox)'.

Try accessing ($Inbox) folder.
0
 
HemanthaKumarCommented:
Ranjeet event All Documents internally refered as ($All) ?

melindaj, it is worth trying what Ranjeet proposed..

~Hemanth
0
 
qwaleteeCommented:
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!

 
RanjeetRainCommented:
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
 
HemanthaKumarCommented:
There is only one difference All Documents is a view and Inbox is a folder !
0
 
melindajAuthor Commented:
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
 
RanjeetRainCommented:
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
 
RanjeetRainCommented:
Mind you, ($Inbox) is a folder, so the processing may be a little different.
0
 
qwaleteeCommented:
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
 
melindajAuthor Commented:
What ever you say that is gun beyond me
I need help In coding
0
 
melindajAuthor Commented:
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
 
melindajAuthor Commented:
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
 
melindajAuthor Commented:
Any one can Help
0
 
HemanthaKumarCommented:
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
 
melindajAuthor Commented:
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
 
melindajAuthor Commented:
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
 
HemanthaKumarCommented:
Replace this line

my $viewName = '($All)';

With

my $viewName = '($InBox)';

This will access inbox contents..
0
 
melindajAuthor Commented:
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
 
HemanthaKumarCommented:
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
 
melindajAuthor Commented:
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
 
HemanthaKumarCommented:
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
 
melindajAuthor Commented:
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
 
HemanthaKumarCommented:
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
 
melindajAuthor Commented:
I have increased the points to 250
0
 
melindajAuthor Commented:
Thank you for this entire question, was answered very well,
Thank you again
0
 
HemanthaKumarCommented:
You are welcome.. Close this question by accepting it.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 12
  • 8
  • 4
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now