I had this one posted on R5 but got no response. I tested this one on R6 and it also behaved like R5 . Please help !***************************************
Hi,
I designed a “share” agent that run “After new mails arrive” . The purpose is to check the SendTo field for an old domain name . If found then, automatically reply to the sender to inform about the new domain . That agent is on a mail template . I do have my name of the group that have “Allow to run unrestriced agent” . I “Replace Design” of my mail database with that new template, and test the agent (sent e-mail with ABC.com as domain). It runs as designed, i.e. I received the auto-reply . But when I asked another user to “Replace Design” to have that agent runs on her mail database , that agent won’t work . I went into her mail, in design mode and “ran” it manually then it worked . By the way the “Allow run restricted agent” and “Personal Agent” is authorized to all users of the domain.
Here is the code :
Sub Initialize
Dim s As New NotesSession
Dim db As NotesDatabase
Dim doc1 As NotesDocument 'incoming mail
Dim reply As NotesDocument
Dim dc As NotesDocumentCollection
Dim view As NotesView
Dim entry As NotesViewEntry
Dim nav As NotesViewNavigator
Dim rtitem As NotesRichTextItem
Dim richStyle As NotesRichTextStyle
'Search for mail with old domain name in the field: INetSendTo
Dim INetSendTo As String, SearchforString As String
Dim positionOfChar As Long
Dim positionOfCharCase As Long
Dim found As Variant
Set db = s.CurrentDatabase
Set dc = db.UnprocessedDocuments
Set reply = New NotesDocument(db)
If dc.Count >0 Then
For i = 1 To dc.Count
Set doc1 = dc.GetNthDocument(i)
INetSendTo =doc1.SendTo(0)
SearchforString = “ABC” 'search for old domain name
positionOfChar& = Instr(INetSendTo$ , SearchforString$ )
'If found occurence of word “ABC” in the domain name
If positionOfChar& <> 0 Then
reply.Form = “Memo” 'Send notification about new domain name
reply.SendTo = doc1.From
reply.Subject = “ABC company domain changed to 123”
'Body of the auto notification
Set richStyle = s.CreateRichTextStyle
Dim richText As NotesRichTextItem
Set richText = New NotesRichTextItem( reply, “Body” ) 'Set body as richtext
richStyle.FontSize = 10
Call richText.AppendStyle(richStyle)
Call richText.AppendText(“Hi,”) 'Hi
reply.Send(True)
End If
Next
Call dc.UpdateAll
End If
End Sub
The problem is not the code since it works fine when I tested it by sending e-mail address with ABC.com as domain. I believe it’s an authority problem but have looked at agent (share), my authority on the server , etc… and could not find anything wrong.
Please help. My appreciation to all suggestions, pointers .
Many thanks in advance.