melindaj
asked on
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??
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??
Ranjeet event All Documents internally refered as ($All) ?
melindaj, it is worth trying what Ranjeet proposed..
~Hemanth
melindaj, it is worth trying what Ranjeet proposed..
~Hemanth
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.
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.
There is only one difference All Documents is a view and Inbox is a folder !
ASKER
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.Not esSession' )
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->GetNthDocum ent($Index );
printf "$Index. %s\n", $Document->GetFirstItem('S ubject')-> {Text};
my $Values = $Document->GetItemValue('I ndex_Entri es');
foreach my $Value (@$Values) {
print " Index: $Value\n";
}
last unless $Index < 5;
}
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.Not
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->GetNthDocum
printf "$Index. %s\n", $Document->GetFirstItem('S
my $Values = $Document->GetItemValue('I
foreach my $Value (@$Values) {
print " Index: $Value\n";
}
last unless $Index < 5;
}
Try this:
use strict;
use Win32::OLE;
my $Notes = Win32::OLE->new('Notes.Not esSession' )
or die "Cannot start Lotus Notes Session object.\n";
my $Database = $Notes->GetDatabase('', 'data.nsf');
my $Inbox = $Database->GetView('($Inbo x)');
Now $Inbox is ready for use.
use strict;
use Win32::OLE;
my $Notes = Win32::OLE->new('Notes.Not
or die "Cannot start Lotus Notes Session object.\n";
my $Database = $Notes->GetDatabase('', 'data.nsf');
my $Inbox = $Database->GetView('($Inbo
Now $Inbox is ready for use.
Mind you, ($Inbox) is a folder, so the processing may be a little different.
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($viewNa me)
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->GetIt emValue('I ndex_Entri es');
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/GetENextEntr y and GetFirstDocument/GetNextDO cument
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($viewNa
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->GetIt
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/GetENextEntr
ASKER
What ever you say that is gun beyond me
I need help In coding
I need help In coding
ASKER
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.Not esSession' )
or die "Cannot start Lotus Notes Session object.\n";
my $Database = $Notes->GetDatabase('', 'jgolany.nsf');
my $viewName = '($All)';
my $view = $Database->GetView($viewNa me);
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->GetNthDocum ent($Index );
printf "$Index. %s\n", $Document->GetFirstItem('S ubject')-> {Text};
my $Values = $Document->Document->GetIt emValue('I ndex_Entri es');
foreach my $Value (@$Values) {
print " Index: $Value\n";
}
last unless $Index < 5;
}
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.Not
or die "Cannot start Lotus Notes Session object.\n";
my $Database = $Notes->GetDatabase('', 'jgolany.nsf');
my $viewName = '($All)';
my $view = $Database->GetView($viewNa
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->GetNthDocum
printf "$Index. %s\n", $Document->GetFirstItem('S
my $Values = $Document->Document->GetIt
foreach my $Value (@$Values) {
print " Index: $Value\n";
}
last unless $Index < 5;
}
ASKER
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.Not esSession' )
or die "Cannot start Lotus Notes Session object.\n";
my $Database = $Notes->GetDatabase('', 'data.nsf');
my $viewName = '($All)';
my $view = $Database->GetView($viewNa me);
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->GetFIrstEnt ry($Index) ;
printf "$Index. %s\n", $Document->GetNthDocument( 'Subject') ->{Text};
my $Values = $Document->Document->GetIt emValue('I ndex_Entri es');
foreach my $Value (@$Values) {
print " Index: $Value\n";
}
last unless $Index < 5;
}
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.Not
or die "Cannot start Lotus Notes Session object.\n";
my $Database = $Notes->GetDatabase('', 'data.nsf');
my $viewName = '($All)';
my $view = $Database->GetView($viewNa
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->GetFIrstEnt
printf "$Index. %s\n", $Document->GetNthDocument(
my $Values = $Document->Document->GetIt
foreach my $Value (@$Values) {
print " Index: $Value\n";
}
last unless $Index < 5;
}
ASKER
Any one can Help
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.Not esSession' )
or die "Cannot start Lotus Notes Session object.\n";
my $Database = $Notes->GetDatabase('', 'data.nsf');
my $viewName = '($All)';
my $view = $Database->GetView($viewNa me);
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('S ubject')-> {Text};
my $Values = $Document->GetItemValue('I ndex_Entri es');
foreach my $Value (@$Values) {
print " Index: $Value\n";
}
last unless $Index < 5;
}
Try this code
use strict;
use Win32::OLE;
my $Notes = Win32::OLE->new('Notes.Not
or die "Cannot start Lotus Notes Session object.\n";
my $Database = $Notes->GetDatabase('', 'data.nsf');
my $viewName = '($All)';
my $view = $Database->GetView($viewNa
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
printf "$Index. %s\n", $Document->GetFirstItem('S
my $Values = $Document->GetItemValue('I
foreach my $Value (@$Values) {
print " Index: $Value\n";
}
last unless $Index < 5;
}
ASKER
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.
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.
ASKER
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.
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.
Replace this line
my $viewName = '($All)';
With
my $viewName = '($InBox)';
This will access inbox contents..
my $viewName = '($All)';
With
my $viewName = '($InBox)';
This will access inbox contents..
ASKER
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" ?
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" ?
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
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
ASKER
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
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
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.
$viewName = "tony"
Inbox and AllDocuments view are mail system folders that is why they carry $ infront of them.
ASKER
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??
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??
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('B ody');
my $rtText = $rtitem->GetFormattedText( 0,0);
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('B
my $rtText = $rtitem->GetFormattedText(
ASKER
I have increased the points to 250
ASKER
Thank you for this entire question, was answered very well,
Thank you again
Thank you again
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Try accessing ($Inbox) folder.