Solved

how to access INBOX using perl

Posted on 2004-03-28
26
714 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
  • 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
 
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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

IBM Notes offer Encryption feature using which the user can secure its NSF emails or entire database easily. In this section we will discuss about the process to Encrypt Incoming and Outgoing Mails in depth.
This article covers general Notes 8.5 troubleshooting information including recreating the Notes\Data folder.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

708 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now