We help IT Professionals succeed at work.

Appending signatures to email when sent via Lotus Notes api

jennyd asked
Medium Priority
Last Modified: 2013-12-18
We have a powerbuilder application that has its own mail window allowing users to compose an email.  The email is then sent through lotus notes through a notes api.  Unfortunately we are unable to get each users signature to be included on the bottom of the email.

We also have the same problem with outlook

We think it is due to having our own compose window.

Any suggestions on how to get around these issues?
Watch Question

did u add signature in Preferences in Lotus Notes
U need to add Signature in Lotus Notes to allow notes to add signature.

How ur generating notes memo? I think Notes will be opened when ever ur creating a new memo through API.

Add the signature in the users mail database (open mail db-> Tools->Preferences->Signature button and enable Auto insert...)

I did not tried the above , just an idea.

Is there any thing ur appending message to the body of email through API? If so, then why can't u capture the user name and append the name and etc., through code?

Else, create a field in memo form in the mail template and there u add @Name([CN];@userName). Make the field computed and may I know the structure of the sugnature u r looking?

Hope it helps.

Bozzie4IT Architect

You will have to get the Signature from the preferences Profile document for the user who is sending it.

That would involve some extra coding :

(I assume  maildb to be set to the current user's mailfile)

dim theSignature as string
dim calprofile as notesdocument
Set calprofile = maildb.GetProfileDocument("CalendarProfile")
TheSignature = calprofile.Signature(0)

(in the memo, append this to the Body field (BodyItem needs to be a notesrichtextitem))

Call bodyItem.appendtext( theSignature )



I don't know about Outlook. In Notes, depending on users options, signatures are either stored in the "CalendarProfile" in the mail database or in a text file. Your API needs to check the "CalendarProfiles" signature options and perform the appropriate action. The "CalendarProfile" contains the following fields related to signatures.

Fields Signature, Signature_1 and Signature_2 (see below).

EnableSignature = "" or not available :Dont append signature.
EnableSignature = "1" : Append signature.

SignatureOption = "1" : Signature is stored as text in fields Signature and Signature_1
SignatureOption = "2" : Signature is stored in a text file. Fields Signature and Signature_2 contain the path to the text file.


Sorry, typo: "CalendarProfile" not "CalendarProfiles".


Yes a signature has been added in the profile.

Is there anyway to do this without changing the application code as it is already rolled out at customer sites.  Is there a setting in the Notes.ini or something?
Stan ReeserTechnology Strategist

Add this sub to the script library emailProcessing in the template and update all the templates (after you test it)... then as the message is created this will execute (unless you bypassed the script libraries - not someting I would reccomend and I highly doubt that you did).  You may have to change the second line to whatever the singnature field is in your file and also note.form(0) = memo if you called it something else. )  this was designed for 4x.  It is nice because it handles 1400 characters of text and puts it in the UIDOC.

Sub SignatureAdd
      Dim notesSession As New NotesSession
      sigText = note.Signature(0)
      subString1$ = Left$(sigText, 200)
      subString2$ = Mid$(sigText, 201, 200)
      subString3$ = Mid$(sigText, 401, 200)
      subString4$ = Mid$(sigText, 601, 200)
      subString5$ = Mid$(sigText, 801, 200)
      subString6$ = Mid$(sigText, 1001, 200)
      subString7$ = Mid$(sigText, 1201, 200)
      Call uidoc.GotoField( "Body" )
      If Len(subString1$) >0 Then Call uidoc.InsertText( subString1$)
      If Len(subString2$) >0 Then Call uidoc.InsertText( subString2$)
      If Len(subString3$) >0 Then Call uidoc.InsertText( subString3$)
      If Len(subString4$) >0 Then Call uidoc.InsertText( subString4$)
      If Len(subString5$) >0 Then Call uidoc.InsertText( subString5$)
      If Len(subString6$) >0 Then Call uidoc.InsertText( subString6$)
      If Len(subString7$) >0 Then Call uidoc.InsertText( subString7$)
      If note.Form(0) = "Memo" Then
            Call uidoc.GotoField( "SendTo" )
            Call uidoc.GotoField( "Body" )
      End If
End Sub
Bozzie4IT Architect

You could add the signature to the notes.ini, but then a user would have 2 places to hold his signatures, and you would probably change the design of the mailtemplate (something I wouldn't do unless there is a very great need).

You should be able to add the snippets of code (mine, peter's) to your existing script, it's only 5-10 lines extra code...  

Other approaches would be to add code to the mail.box (change the design of the Memo form ) (not recommended), or to (try) to work with a server-based mailrule to automatically append it.  I don't think these approaches are good alternatives, so I would still advise you to change your application.....

Stan ReeserTechnology Strategist

Tom, be careful, in your solution the signature is set to a string and  has to be less than appx 250 characters (youd think it would be 256 but I think it is 253.  Thats why  I had to break it in to chunks (odd thing when my client was using during the migration to 6 it put some carrige returns when executed from a 6 client but not from the 46x still never figured that out.).
You could also do copyitem in the back end , but there is already something in the body.
IT Architect
Unlock this solution and get a sample of our free trial.
(No credit card required)
Bozzie4IT Architect

And if your application has a limit of 256 characters for String, you shouldn't use a String to hold the intermediate value ....


Stan ReeserTechnology Strategist

You are correct sir... it is the uidoc.inserttext that has the limit.  It is 3 AM :) I should go to bed

The reason I set it up in the ui is for the forward/reply... if you forward or reply with history and then append the message on send it puts it all the way at the bottom... not what my client wanted.   But Tom is right if you cant use the front end then what does it matter (and the users probably can't forward/reply anyway)

My comment about the CR was that when we migrated the "sigText" had these leading CRs that didnt appear when executed from 4x  Just something I ran across, didnt mean to say yours couldn't handle them.

g'nite <:^)
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.