Fancy up Lotus Notes email with this enhanced SendMail function

This spiced up SendMail function from member Mohammed Misbahuddin will let you fancy up the formatting of your Lotus Notes document links.

This is an enhanced SendMail function for sending Notes/Domino document links with some extra features. In some instances, you might want to change the font or alignment of the body text; or if you want to make a Lotus Notes e-mail a bit fancier, this SendMail function will do it for you. It uses the bookmark form instead of the memo form. It's provided in the mailbox, specifically for workflow.

 Function fnSendMailMemoEx(vSendTo As Variant, 
vCcTo As Variant, vBccTo As Variant, szSubject As String, 
szBody As String, nBodyTextFont As Integer, 
nBodyTextFontSize As Integer, bBodyTextFontBold As Boolean, 
nBodyTextAlign As Integer,  docLink As NotesDocument) As Integer
 'Legal Values for nBodyTextFont are 
 'FONT_ROMAN (0), 
 'FONT_HELV (1), 
 'Legal Values for nBodyTextAlign are 
 'ALIGN_LEFT (0), 
 'ALIGN_FULL (2), 
 On Error Goto ErrorHandler
 Dim s As New NotesSession
 Dim ws As New NotesUIWorkspace
 Dim mailDb As NotesDatabase
 Dim mailDoc As NotesDocument
 Dim rtItem As NotesRichTextItem
 Dim richStyle As NotesRichTextStyle
 Dim rtpParagraphStyle As NotesrichTextParagraphStyle
 Set mailDb =s.CurrentDatabase
 Set mailDoc = mailDb.CreateDocument
 mailDoc.Form = "BookMark"
 mailDoc.SendTo = vSendTo
 mailDoc.CopyTo= vCcTo
 mailDoc.BlindCopyTo= vBccTo
 mailDoc.Subject = szSubject
 Set rtItem = mailDoc.CreateRichTextItem("Body")
 Set rtpParagraphStyle = s.CreateRichTextParagraphStyle
 rtpParagraphStyle.Alignment = nBodyTextAlign
 Call rtitem.AppendParagraphStyle(rtpParagraphStyle)
 Set richStyle = s.CreateRichTextStyle
 richStyle.NotesFont = nBodyTextFont
 richStyle.FontSize = nBodyTextFontSize
 richStyle.Bold = bBodyTextFontBold
 Call rtitem.AppendStyle(richStyle)
 Call rtItem.AppendText(szBody)
 If Not(docLink Is Nothing) Then
  Call rtItem.AddNewLine(2)
  Call rtItem.AppendDocLink
(docLink, "Double-click to open document")
 End If
 Call mailDoc.Send(False)
 fnSendMailMemoEx = True
 Exit Function
 Msgbox "SendMail: Error " & Str$(Err) & "
: " & Error$ & " : at line number " & Erl
 Resume TheEnd
 fnSendMailMemoEx = False
End Function

Do you have comments on this tip? Let us know.

This tip was submitted to the tip library by member Mohammed Misbahuddin. Please let others know how useful it is via the rating scale below. Do you have a useful Lotus Notes, Domino, Workplace or WebSphere tip or code snippet to share? Submit it to our monthly tip contest and you could win a prize.

Dig Deeper on LotusScript

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.




  • iSeries tutorials's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...