How to Use the lotus script proxy to send HTML-format emails

Source: Internet
Author: User

Product: Lotus Domino
Platform: Aix, HP-UX, I5/OS, Linux, Solaris, windows, Z/OS
Software Version: 6.0, 6.5

Problem description:

How can I use LotusScript to send HTML-format mail messages?

Before expanding the notesmimeentity class in Lotus Notes and Lotus Domino desitner 6.x, it is unlikely to use a scheduling proxy to send HTML-format emails. When you set htmlCodeWhen added to the email subject, even if the passthruhtml notesrichtextstyle attribute is set, notes still sends the email as the original HTML code.

Answer:

The new methods and attributes in the notesmimeentity class, as well as the notesstream class, make it possible to send HTML-format emails using scheduling agents in the Notes/Domino 6. x version. This function is useful for sending HTML messages or sending replies to users who submit information to the email database. You can create a proxyProgram, Send HTML stored in the local file system or dynamically create HTML. The proxy below illustrates the above functions.

Important Note: The following is an example script, which only provides a way to handle this problem. For this example to be normal, the script must be consistent with the example. IBM technical support cannot customize this script for customers

Use a local HTML file

The following proxy sends HTML files from the local file system (the server's hard drive:

Dim s as new notessession
Dim dB as notesdatabase
Dim doc as notesdocument
Dim body as notesmimeentity
Dim header as notesmimeheader
Dim stream as notesstream
Set DB = S. currentdatabase
Set stream = S. createstream
S. convertmime = false 'do not convert mime to Rich Text
Set Doc = dB. createdocument
Doc. form = "memo"
Set body = Doc. createmimeentity
Set header = body. createheader ("subject ")
Call header. setheaderval ("HTML message") 'This is the subject
Set header = body. createheader ("")
Call header. setheaderval ("user@us.ibm.com") 'this can be a list of users separated by commas
'The file named below is located on the Domino server because the scheduled Agent runs on the Domino server
Call stream. Open ("C: \ newsletter.html ")
Call body. setcontentfromtext (stream, "text/html; charsets = UTF-8", enc_identity_7bit)
Call Doc. Send (false)
S. convertmime = true 'Restore Conversion

Use Dynamic HTML content

The following proxy dynamically generates HTML files. You can add dynamic content to HTML files.

Note that the stream. writetext method uses the pipe (|) character as the separator rather than quotation marks. In this usage, quotation marks can be placed directly before the string. At the same time, the writetext line is separated and easy to read. However, they can also be connected together if needed.

The sample code includes the eol_crlf character to make the messageSource codeProperly formatted. This is important because many junk filters filter out mime information in incorrect formats.

Dim s as new notessession
Dim dB as notesdatabase
Dim doc as notesdocument
Dim body as notesmimeentity
Dim header as notesmimeheader
Dim stream as notesstream
Set DB = S. currentdatabase
Set stream = S. createstream
S. convertmime = false 'do not convert mime to Rich Text
Set Doc = dB. createdocument
Doc. form = "memo"
Set body = Doc. createmimeentity
Set header = body. createheader ("subject ")
Call header. setheaderval ("HTML message ")
Set header = body. createheader ("")
Call header. setheaderval ("user@us.ibm.com ")
Call stream. writetext (| <HTML> |)
Call stream. writetext (| <body bgcolor = "blue" text = "white"> |)
Call stream. writetext (| <Table border = "2"> |)
Call stream. writetext (| <tr> |)
Call stream. writetext (| <TD> Hello world! </TD> |)
Call stream. writetext (| </tr> |)
Call stream. writetext (| </table> |)
User $ = S. commonusername 'If scheduled agent this returns the name of the server
'Below uses the Ampersand (&) to concatenate user $
Call stream. writetext (| <br> <font size = "+ 5" color = "red" >|& user $ & | </font> |)
Call stream. writetext (| </body> |)
Call stream. writetext (| Call body. setcontentfromtext (stream, "text/html; charsets = UTF-8", enc_identity_7bit)
Call Doc. Send (false)
S. convertmime = true 'Restore conversion-very important

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: info-contact@alibabacloud.com 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.