I have an agent running on After New Mail Arrives, the basic idea is to take the name of the sender, which is provided by a calculated field ‘MaxFrom’ which is based on a formula similar to that in the ‘Who’ column in the Inbox. Once I have this name I will carry out searches on another database to find related information, e.g. Telephone Number.
I am stuck at the first hurdle though. The MaxFrom field does show the correct data when I open the email, however, I do not appear to be able to access that data by the agent when mail arrives.
As a test I have written the script to change the MaxPhoneScript field to the MaxFrom value (this will eventually display a searched telephone number). The agent does run, but instead of changing the MaxPhoneScript field from its default value “Test” it removes the data, suggesting I am not accessing the value.
When a mail is generated internally within the Notes domain, there is no problem as my MaxFrom field displays the sender before the email is sent. In other words the problem occurs with inbound mail arriving from The Internet, I assume therefore the MaxFrom field value does not exist until I open the document or something of that order. I have tried Editable, Computed When Composed and Computed Fields.
I assume there is something wrong with my script, but have spent many, many hours trying to resolve the problem, so any help would be appreciated.
Thanks Mark
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim collection As NotesDocumentCollection
Dim doc As NotesDocument
Dim MaxName As Variant
Set db = session.CurrentDatabase
Set collection = db.UnprocessedDocuments
Set doc = collection.GetFirstDocument()
While Not(doc Is Nothing)
If doc.Form(0)="Memo" Then
MaxName =doc.GetItemValue("MaxFrom")
doc.MaxPhoneScript = MaxName(0)
Call doc.Save( True, True )
End If
Call session.UpdateProcessedDoc( doc )
Set doc = collection.GetNextDocument(doc)
Wend
End Sub