Agent cannot encrypt e-mail message
Here's the agent script:
REM Recipient is split from Subject field. REM Agent is set to run before new mail. REM Agent security is set to 2. Sub Initialize Dim session As NotesSession Set session = New NotesSession Dim db As notesdatabase Dim Maildoc As notesdocument Set db = session.CurrentDatabase Dim doc As NotesDocument Set doc = session.DocumentContext Dim ret As Variant Dim teststr As String Dim delim As String teststr = doc.Subject(0) delim = "&" ret = Split(teststr, delim) Print ret(0) Print ret(1) Set Maildoc = New NotesDocument( db ) Call doc.CopyAllItems( Maildoc, True ) Maildoc.From = doc.From(0) Maildoc.Form = "Memo" Receipient = ret(0) Maildoc.Subject = ret(1) Call Maildoc.Save( True, True ) Maildoc.EncryptOnSend = True Call Maildoc.Send (False, recipient) Call Maildoc.RemovePermanently(True) End Sub
If the agent works with a hardcoded name and fails with a calculated name in the same context, reason b is more likely. If the calculated recipient name is an Internet address rather than a Notes username, for instance, the Send method probably can't match it up with a Notes username. In that case, you will probably need to program a function yourself to find the corresponding Person record and use it to translate the address into a fully qualified Notes username.
Do you have comments on this Ask the Expert question and response? Let us know.