Possible to set "Run on behalf of" using a field?

I have a Notes client form that has a button (with LotusScript) which is used to send internet email to clients. The from / reply to address for the email comes from a field on that form since the email is sent by an assistant.

Is there anyway to get rid of “on behalf of” in the From address? I can’t use an agent and the “Run on behalf of” setting since the from address comes from a field on the form and is not static. I tried using replyto or principal fields but no luck.

Thanks in advance.

-Patrick

Subject: Possible to set “Run on behalf of” using a field?

“On behalf” field in agent is not used on the client, it is only used for the server based agents. If you used it on the server based agent and the person who signed the agent has very high priviledges, you will not see “sent by”. Principle field includes “sent by”, but you can customize the mail template and remove it if you decide that in your organization it is not important to know when the message is sent by someone who has been delegated. Another way to change the sender name is to resign the agent.

If you would like additional information Agent FAQ goes over each of the options.

Subject: Here is more info about the issue

Thanks Julie. Please let me try a different approach to explain the issue.

I want to code a button on a custom Notes application form that allows an assistant to send an internet email from “someone else”. The “someone else” can be any one of about 10 people. The “someone else” name is available from a field on the form but changes depending on who the assistant is.

I know I can use an agent and runonserver and set the “Run on behalf of” property so that the email will look like it really came from someone else. But, “Run on behalf of” can only be set by manually typing the value in the agent property; it can’t read a value from a field or a variable (right?) Plus the OnBehalfOf notesagent property is read-only so I can’t set it using code.

I would have to create 10 separate agents, each with a different address specified in “Run on behalf of” and then call the appropriate agent from the button (depending on who the email should come from).

Since the “someone else” (who the email should come from) is in a field on the form, it would be great if the email could come from that person using a single agent. If the “Run on behalf of” value could come from a variable or a document field, I could compute this value rather than create separate agents. Or maybe there is a better way to do this that I am missing?

Thanks!

Subject: RE: Here is more info about the issue

RunOnBehalf can be set programatically but only to the name of the mail file owner. There are all sort of security ramifications to this feature, which imposes the restrictions on how (and who) can set this value. I think “Principle” field fits your scenario best (but the original sender is preserved for audit trail).

“Troubleshooting agents in R6” article has a long section on all the options for setting the sender. If you have not read it, you might find it useful.

Subject: RunOnBehalf can be set programatically?

How is this done? Please keep in mind the db sending the email is not an email db. I’ve had to create separate agents and set the “On behalf of” value manually in order to get around the issue.

Thanks in advance!

Subject: RE: RunOnBehalf can be set programatically?

There is a mention of it the Agent FAQ. I think it was in the article that introduced all new Domino 6 features. I saw an example in Out of Office agent code, it uses an AdminP method.

Subject: Thanks!

I’ll check it out

Subject: Julie - I have the same issue… can we set on-behalf of dynamically with CAPI?

We are running a scheduled agent to generate a newsletter. The source documents are protected by reader fields. It would be very nice if we could dynamically change the On Behalf Of to have the agent “see” different sets of documents.

Can the On Behalf Of property be set through the C API? If yes, we could dynamically set it an resolve our issue.

The goal would be to have the agent running the newsletter to a)change the property of the agent to run on behalf of a certain user and b)invoke the agent to get that users’ set of documents and so on.

We tried to update the $OnBehalfOf item in the agent programmatically, but that seems to corrupt the agent and result in a Notes Item not found error. If we can pull this off, it would be such a time saver.

Thanks,

Jordan

Subject: and the solution is to set OnBehalfOf programmatically on any agent…

Even in LS, and without the adminp process :slight_smile:

  1. open the agent as a notesdoc using the unid

  2. set the $OnBehalfOf field - works with a Notes user or Web user

  3. SIGN the document… or the agent won’t run

Clearly all the right security needs to be setup in the server doc re who can sign an agent to run on behalf of etc, etc.i

Cheers,

Jordan

Here is some sample code

Dim s As New notessession

Dim db As notesdatabase

Dim agentdoc As NotesDocument

Set db = s.CurrentDatabase

Set agentdoc = db.GetDocumentByUNID(“30AFDC5AF9F0A26085256F25002FC031”)

If agentdoc Is Nothing Then

Print "agent not found"

Else

usrname = "Test User2"

agentdoc.~$OnBehalfOf = usrname 

Call agentdoc.Sign

Call agentdoc.Save(1,0)

End If