tags:

views:

147

answers:

1

Hi,

I am accessing From value of each mail from nsf file. As:

NotesView sent = _NotesDatabase.GetView("($Sent)");

if (sent != null)

{

NotesDocument docSent = sent.GetFirstDocument();

if (docSent != null)

{

   while (docSent != null)

   {

    String Subject = ( (object[]) DocSent.GetItemValue("Subject"))[0] as String;

    Message.Show(Subject);

    docSent = sent.GetNextDocument(docSent);    

   }//while

}

}

But there are some mails for which i am getting "null" value (it contains SendTo,Subject e.t.c values: viewed in lotus notes).

So i can't access Subject of it. Why it is happening? i checked Form value it is "Memo"

A: 

If you're getting a null value from GetItemValue, then the field is probably not on the document. You can check for this condition using the HasItem method of the NotesDocument class, as in:

if (docSent.hasItem("Subject")) {
    ...
}
Ed Schembor
i tried this code.But as docSent is null we can't perform any operation on it.It shows "Object referece null" exception.
Preeti Singh
If docSent is null, this would imply you have reached the end of the view. If you are making any changes to a document which causes the document to fall out of the view or change its position in the view, this could cause the getNextDocument method to return null prematurely. Your code above does not seem to do this.
Ed Schembor