Trying to access From in incoming mail

Hi all,

Trying to access incoming mail and forward all mail from a certain email address (actually several ultimately, but I’d be happy with one at this point) to a log db. However, I’m having trouble accessing the From field. I may just be tired but can’t figure it out. Whatever I try, I get a type mismatch. Here’s the code fragment:

Dim s As New NotesSession

Dim db As NotesDatabase

Dim copydb As NotesDatabase

Dim copyItem As NotesItem

Set db = s.CurrentDatabase

Set copydb = s.GetDatabase(db.Server, "companylog.nsf")



Dim newmail As NotesDocumentCollection

Set newmail=db.UnprocessedDocuments



Dim eachDoc As notesdocument

Set eachDoc=newmail.GetFirstDocument

Do While Not eachDoc Is Nothing

	

	Set copyItem = eachDoc.From

***** If eachDoc.From={“MASTER app” automail@company.com} Then

		Set destinationDoc = eachDoc.CopyToDatabase(copydb) 

		destinationDoc.Form="Main Form"

		destinationDoc.Save True,False 

I tried accessing like this, I tried assigning eachDoc.From to a String, a variant, a NotesItem (in debugger it says eachDoc.From is a NOTESITEM) Nothing worked.

If someone out there could help I’d really appreciate it.

Thanks!!!

Subject: Trying to access From in incoming mail

All notes field values are actually arrays, even if there’s only one entry in the array. You need to reference the first entry in the array, entry number 0:

If eachDoc.From(0) = {“MASTER app” automail@company.com} Then …

Subject: RE: Trying to access From in incoming mail

Ah, gotcha. Everything works beautifully now. Thanks!!!