Mailing via LotusScript

How do I mail a message including a link via Scripting in Lotus Notes? The script should be assigned to a Form Action.(R4.5.5)
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ashik1Author Commented:
Adjusted points to 260
Hi ashik1,

see this great resource for your info:

And here my implementation of the above:
In your form define in PostSave event this call:
Sub Postsave(Source As Notesuidocument)
 Dim doc As NotesDocument
 Set doc = Source.Document
 flag% = SendMailMemo(doc.SendTo(0), doc.CopyTo(0), doc.BlindCopyTo(0), doc.Subject(0), "Body Text", doc)
End Sub

Paste after this the called function from URL above:
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
 Print "Send Mail Memo...."
 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
 Print "Error " & Str$(Err) & ": " & Error$
 Resume TheEnd
 SendMailMemo = False
End Function

And it works...

Question: why do you not use @MailSend?


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
You can increase the recipient number if you change the paramter definition of the function SendMailMemo:
Function SendMailMemo(sendTo As Variant, _
cc As Variant, _
bcc As Variant, _
subject As String, _
body As String, _
linkTo As NotesDocument) As Integer

With Variant type you can call as many recipiants as you have:
flag% = SendMailMemo(doc.PersonsInvolved, doc.CopyTo, doc.BlindCopyTo, doc.ChangeSubject(0), "Body Text", doc)

Simply omit the zeros.

Try it.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Lotus IBM

From novice to tech pro — start learning today.