von
http://www-10.lotus.com/ldd/today.nsf/0/ef1565a0b202808285256c94004fd0fb?OpenDocument (Julie Kadashevich, true intelectual):
How can I change the apparent sender of agent generated mail?
Sometimes you need to generate mail from an identity different from your own. For example, you may want to generate mail from the user Domino Administrator. There are three ways to do this:
* Create a special ID for user Domino Administrator and sign the agent with that ID.
* Use the Principal field in the agent code to override the From field.
* Use the Run on behalf of field (new in Notes/Domino 6).
The first method is the simplest because it requires no coding. It does, however, involve licensing and maintaining IDs. The second method is more flexible, but requires some coding. You don't need any special rights, but the information about the original sender is maintained for auditing purposes. By default, the mail template displays the original sender's name in the sent by field under the From field. There are three ways to specify the Principal field:
* doc.Principal="Joe User/Org@NotesDomain" where Joe User/Org has a Person record with an InternetAddress of your choosing. (Note that the string @NotesDomain must be present.)
* doc.Principal="CN=Joe User/O=Org" where Joe User/Org has a Person record with an InternetAddress of your choosing.
* doc.Principal=User@acme.org@NotesDomain <mailto:User@acem.org@NotesDomain>. (Note that the string @NotesDomain must be present.)
If you only care about the ReplyTo address, you can use it instead of the Principal, which changes both the From and ReplyTo:
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument
Dim item As NotesItem
Dim ToWho(40) As String
Dim FirstName(40) As String
Dim Msg As String
Set db = session.CurrentDatabase
Set doc = New notesdocument(db)
'*******************************************************************
Count = 30
ToWho(0)="joe@yahoo.com"
FirstName(0)="Joe"
ToWho(1) = "teresa@yahoo.com"
FirstName(1)="Teresa"
<more initialization code removed>
doc.Principal = "julie@yahoo.com@NotesDomain"
doc.Form = "Memo"
doc.Subject=" Happy Holidays!"
For i=0 To count
Greet = "Hi " +FirstName(i) +", Happy Holidays!"
Msg1 ="additional text"
doc.Body=Greet + Msg1
Print toWho(i)
Call doc.Send(True,toWho(i))
Next
As we show in the preceding code, @NotesDomain is a string that is expected in the syntax. Omitting this is often the problem when people report that the Principal field is not working.
The third method (Run on behalf of) is new to Notes/Domino 6. This field in Agent Properties allows one user to run an agent as though it were invoked by another user. You need special rights to run agents on behalf of other users. These rights are controlled through the "Sign agents to run on behalf of someone else" field in the Security tab of the Server document. If they have this permission, mail appears to come from the name specified in the Run on behalf of field. This is a very high level of rights and should only be granted carefully, as it allows one user to run agents on behalf of other users, including having their ACL rights when accessing databases.