• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 344
  • Last Modified:

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)
0
ashik1
Asked:
ashik1
  • 2
1 Solution
 
ashik1Author Commented:
Adjusted points to 260
0
 
stampCommented:
Hi ashik1,

see this great resource for your info:
http://www.keysolutions.com/NotesFAQ/howmailsend.html

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
 
ErrorHandler:
 Print "Error " & Str$(Err) & ": " & Error$
 Resume TheEnd
 
TheEnd:
 SendMailMemo = False
End Function


And it works...

Question: why do you not use @MailSend?

Regards,
stamp
0
 
stampCommented:
P.S.:
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.

Regards,
stamp
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now