Fancy up Lotus Notes email with this enhanced SendMail function

This spiced up SendMail function from SearchDomino.com 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), 
 'FONT_COURIER (4), 
 'STYLE_NO_CHANGE (255)
 
 'Legal Values for nBodyTextAlign are 
 'ALIGN_LEFT (0), 
 'ALIGN_RIGHT (1), 
 'ALIGN_FULL (2), 
 'ALIGN_CENTER (3), 
 'ALIGN_NOWRAP (4)
 
 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
 
ErrorHandler:
 Msgbox "SendMail: Error " & Str$(Err) & "
: " & Error$ & " : at line number " & Erl
 Resume TheEnd
 
TheEnd:
 fnSendMailMemoEx = False
End Function

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

This tip was submitted to the SearchDomino.com 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.

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com'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 ...

SearchDataCenter

SearchContentManagement

Close