hcl-bot
November 10, 2008, 11:18pm
1
I have this agent that runs just fine if set to run “before new mail arrives” but it does NOT when set to “after new mail arrives” why? both on event
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Set session = New NotesSession
Set db = session.CurrentDatabase
Set doc = session.DocumentContext
Select Case doc.SendTo(0)
Case “user1@domain1.com ” : doc.SendTo = “userA@domainA.com ”
Case “user2@domain1.com ” : doc.SendTo = “userB@domainA.com ”
End Select
doc.subject = “New Subject line goes here”
Call doc.Send(False)
End Sub
hcl-bot
November 11, 2008, 1:25am
2
Subject: Unprocessed Documents
With ‘After mail has arrived’ you need to use the NotesDatabase.UnProcessedDocuments method to get a handle to the list of mail messages to process.
Before new mail arrives is processed on a per document basis.
Alex
hcl-bot
November 11, 2008, 10:51am
3
Subject: agent modification
Alex, first of all thanks for responding tough I got this code from someone else and I’m not a developer can you help with modifying this agent to process doc after they arrived?
hcl-bot
November 12, 2008, 1:26am
4
Subject: Try this
Try this…might need some modifications though as I haven’t tested it…
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim DocCollection As NotesDocumentCollection
Set session = New NotesSession
Set db = session.CurrentDatabase
Set DocCollection = db.UnprocessedDocuments
If DocCollection.Count > 0 Then
Set doc = DocCollection.GetFirstDocument
While Not doc Is Nothing
Select Case doc.SendTo(0)
Case “user1@domain1.com ” : doc.SendTo = “userA@domainA.com ”
Case “user2@domain1.com ” : doc.SendTo = “userB@domainA.com ”
End Select
doc.subject = “New Subject line goes here”
Call doc.Send(False)
Set doc = DocCollection.GetNextDocument(doc)
Wend
End if
End Sub