Problem solve Get help with specific problems with your technologies, process and projects.

Customize the principal field of outgoing email messages

Learn about different options using LotusScript code and Formula language to customize the principal field of outgoing Lotus Notes email messages.

Dear Cregg: I am sending email messages from a Domino Web application, which features an @Mailsend command behind a button. The email messages are being sent properly, except when an anonymous user sends a message using this application. In such a case, the sender appears as: servername/[email protected] How can I customize this and set the sender field?

To accomplish what you want, you have to set the principal field of the outgoing email messages. This is easier to do in LotusScript than Formula language. In LotusScript, to send a minimal email, you could use something like this:

Dim Session As New NotesSession
Dim db As NotesDatabase
Set db = session.CurrentDatabase

Dim email As NotesDocument
Set email = db.CreateDocument
email.principal="My Favorite User"
email.body = "body"
Call email.Send(False,"Addressee or 
array of addressees")

In Formula language, it's a little trickier. You cannot set field contents directly. Instead, you pass them to @Mailsend as arguments. If @Mailsend does not have the argument you need, then you have to have the value set in the Lotus Notes document before you send it, and then use the @Mailsend parameter that causes certain fields to be included. Depending on your application, this may or may not be practical.

If your Domino Web application is creating a document, and that document is the one that contains the button and that is being sent out, then simply add a computed field called principal to the form. Give this field a formula to set its value to the readable value you would like. Be sure to note that in Lotus Notes, this value does not have to correspond to a real, addressable user. But if it doesn't, make sure you also add a "Replyto" field which does.

Now to your @mailsend command, add the "bodyfields" argument to tell it to include the principal and "Replyto" fields calculated when the document is created:

@MailSend( "sendTo" ; "" ; "" ; "subject" ; 
"remark" ; "principal":"replyto" )

Do you have comments on this Ask the Expert Q&A? Let us know.

Related information from

Dig Deeper on LotusScript

  • Favorite iSeries cheat sheets

    Here you'll find a collection of valuable cheat sheets gathered from across the iSeries/ community. These cheat ...