I have a function I wrote way back to generate mail notification out of my program. But in many cases it had to be modified for each use. Yesterday I decided to write simple class instead, and here is the result. I will post it at OpenNTF.org soon as well.
This is how you use the class:
Set mailnotification = New MailNotification()
mailnotification.SendTo="texasswede@gmail.com"
mailnotification.Subject = "Test email fron Notes"
mailnotification.Principal = "System X "
Call mailnotification.body.AppendText( "This is some text in the body field. " )
Call mailnotification.body.AppendText( "And some more." )
Call mailnotification.body.AddNewLine( 1 )
Call mailnotification.body.AppendText( "Docclink: " )
Call mailnotification.body.AppendDocLink( doc, "Click to open" )
Call mailnotification.body.AddNewLine( 2 )
Call mailnotification.Send()
Easy, huh?
And here is the class itself. I store it in a script library called Class.MailNotification… Enjoy!
Class MailNotification Public maildoc As NotesDocument Public body As NotesRichTextItem Public subject As String Public sendto As String Public copyto As String Public bccto As String Public principal As String Public Sub New() Dim session As New NotesSession Set maildoc = New NotesDocument(session.CurrentDatabase) Call maildoc.ReplaceItemValue("Form","Memo") Set body = New NotesRichTextItem(maildoc,"Body") subject = "" sendto = "" copyto = "" bccto = "" principal = "" End Sub Public Sub Send() If subject<>"" Then maildoc.Subject = subject End If If sendto<>"" Then maildoc.SendTo = sendto End If If copyto<>"" Then maildoc.CopyTo = copyto End If If bccto<>"" Then maildoc.BlindCopyTo= bccto End If If principal<>"" Then maildoc.Principal = principal End If Call maildoc.Send(True) End Sub End Class