Lotus Notes FAQ Visit Our Sponsor!

How do you do @MailSend in Lotuscript?

Use the function below as follows:
  flag% = SendMailMemo("SendTo", "cc", "bcc", "Subject", "Body Text", NotesDocument)

If you pass a valid NotesDocument in as the last parameter, the mail memo is sent with a doclink to it. If you don't want to send a doclink, just pass the Nothing constant as the last parameter.

If the function encountered problems, it returns False, otherwise it returns True.

Function SendMailMemo(sendTo As String, _
                      cc As String, _
                      bcc As String, _
                      subject As String, _
                      body As String, _
                      linkTo As NotesDocument) As Integer
  On Error Goto ErrorHandler

  Dim mailDb As New NotesDatabase("", "")
  Dim mailDoc As NotesDocument
  Dim rtItem As NotesRichTextItem

  Call mailDb.OpenMail
  If (mailDb.IsOpen = False) Then Call mailDb.Open("", "")
  Set mailDoc = mailDb.CreateDocument
  mailDoc.Form = "Memo"
  mailDoc.SendTo = sendTo
  mailDoc.CC = cc
  mailDoc.BCC = bcc
  mailDoc.Subject = subject
  Set rtItem = mailDoc.CreateRichTextItem("Body")
  Call rtItem.AppendText(body)
  If Not(linkTo Is Nothing) Then
    Call rtItem.AddNewLine(2)
    Call rtItem.AppendDocLink(linkTo, "Double-click to open document")
  End If
  Call mailDoc.Send(False)
  SendMailMemo = True
  Exit Function

 ErrorHandler:
  Print "Error " & Str$(Err) & ": " & Error$
  Resume TheEnd

 TheEnd:
  SendMailMemo = False
End Function


Applies to Notes Versions: 4, 4.5, 4.6, 5
Last Modified: January 23, 1997