Program to send mail in Lotus Notes (i) __ programming

Source: Internet
Author: User

Mail is the core and basic function of the Lotus Notes system so that send () is a notesdocument method, any document can be sent out, notes in a message is just a special field of documents. In program development, the function of sending mail is also widely and highly used. The ability to send messages in notes can be developed to a level of sophistication and sophistication that adapts to almost any requirement. I am prepared to discuss these features in several articles.

The first is the simplest to send messages in LotusScript, including traditional client and HTML messages. Give the user, subject and content, send mail, this is the most typical requirements, nature should also be written as a function.

The following parameters for this function are the recipient, the copied, the blind, the subject, the body, and the attached link document (if nothing is passed in). The data type of each recipient parameter is the same as that of a text field, that is, a string or an array of strings.

Public Sub CC (sendto as variant,copyto as variant,blindcopyto as variant,subject as string,body as string,linkdoc as NT
	Dim s As New Notessession
	Dim db As NotesDatabase
	Set db=s.currentdatabase
	Dim maildoc As New Notesdoc Ument (db) with
	Maildoc call
		. Replaceitemvalue ("Form", "Memo") call
		. Replaceitemvalue ("SendTo", SendTo) call
		. Replaceitemvalue ("CopyTo", CopyTo) call
		. Replaceitemvalue ("Blindcopyto", Blindcopyto) call
		. Replaceitemvalue ("Subject", Subject) End with
	Dim Rtitem as New notesrichtextitem (Maildoc, "body")
	Call Rtitem.appendtext (body)
	If not Linkdoc are nothing Then call
		Rtitem.appenddoclink (Linkdoc, "click the link ") End
	If call
	maildoc.send (False)
	Dim msg as String
	If IsArray (sendto) Then
		msg=join (sendto
		msg=sendto end
	Print ' sent mail to ' & msg end

Because the LotusScript function does not support overloading, the following function takes a more common recipient, subject, body, and attached document as a parameter, and it is easier to invoke it to save two parameters.

Public Sub SendMail (sendto as variant,subject as string,body as string,linkdoc as variants) call
	CC (SendTo, "", "", Sub Ject, body, linkdoc) end

The following function sends an HTML message, which is the text of the recipient, copy, blind, subject, and HTML.

Public Function Cchtmlmail (SendTo As Variant, CopyTo as Variant, Blindcopyto as Variant, subject as String, HTML as String
	Dim s As New notessession
	Dim db As NotesDatabase
	Set db=s.currentdatabase
	Dim Memo as NotesDocument
	Set memo=db. CreateDocument () Call
	memo.appenditemvalue ("Form", "Memo") Call
	memo.replaceitemvalue ("SendTo", SendTo) Call
	Memo. Replaceitemvalue ("CopyTo", CopyTo) call
	Memo. Replaceitemvalue ("Blindcopyto", Blindcopyto) call
	memo.replaceitemvalue ("Subject", Subject)
	Dim Stream as Notesstream
	Set stream=s.createstream () call
	stream.writetext (HTML)
	Dim entity as notesmimeentity 
	Set entity=memo.createmimeentity ("Body")		
	Call Entity.setcontentfromtext (Stream, "Text/html;charset=utf-8", 1725) called
	stream.close () call
	memo. Send (False)
	s.convertmime=true end

Finally, this function also eliminates the copying and blinding of two parameters, sending an HTML message.

Public Function Sendhtmlmail (SendTo as Variant, subject as String, HTML as String) call
	Cchtmlmail (SendTo, "", "", Sub ject, HTML) end

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.