e-mail programming in Lotus notes (ii)

Source: Internet
Author: User

When you program a message with a variety of similar notifications, you often need the sender to appear as a specific account, such as the name of a department or the name of an administrator. Another requirement is that when a user receives a message, the address of the reply message differs from the one displayed in the sender bar. Under normal circumstances, if the script that sends the message is running on the client, the sender is the current user, and if it is running on the server, the sender is the signer of the Code, and the message is replied to the sender address that is displayed. If the same message is sent by a timed agent on the server, we can sign the agent with the ID of the sender we want to display, or even create an ID for this purpose first. Alternatively, the Security Options page of the agent's properties can be set to run as a different user (run on behalf of), which has some permission requirements, detailed in the Notes Help documentation.

However, the most convenient way to see it is to specify the sender in the code, "forge" the signature. This is only for the convenience of display, and does not destroy the strict identity security of notes, received messages in the recipient column or there will be "a-B send" such remarks, but has met our notification email sender's request.

I can't remember in a previous version of notes, just add a From field to the mail document that you want to send, and you can modify the sender. In the latest version, this is not working, but the following method is always possible.

This mail custom class, implements the functionality and 46. In Lotus Notes, the code in the program to send a message (a) is to send a regular message, except that you can specify the sender to display or a different reply address. By specifying the principal or ReplyTo field separately, you must also include the user's Domino domain for that address, in addition to the generic mail address. Because in most cases, these users and the current user are in the same domino domain, for simplicity, the GetDomain () method takes the current user's Domino domain. The last CopyItem () method is just for the convenience of adding some content to the message.

Public Class Mail Private s as notessession private maildoc as notesdocument private domain as String ' Notes domain Pu  Blic SendTo as Variant public Subject as String public Body as String public linkdoc as NotesDocument public CopyTo as Variant public Blindcopyto As Variant public ReplyTo as String public Principal as String Sub New (SendTo as Variant , subject as String, body as String) me.sendto=sendto me.subject=subject me.body=body me.copyto= "" Me.blindco Pyto= "" Set me.linkdoc=nothing set s=new notessession Dim db as NotesDatabase set db=s.currentdatabase set MA 
		IlDoc = New notesdocument (db) End Sub Private Function getdomain () If me.domain>< "then Exit Function End If Dim nd As Notesdirectory Set nd=s.getdirectory (s.currentdatabase.server) Dim info as Variant info=nd. Getmailinfo (S.effectiveusername) me.domain=info (5) End function Public Function Send () 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.appendt Ext (body) If not Linkdoc are nothing Then call Rtitem.appenddoclink (Linkdoc, "click the link") End If ' Format s Hould equal: "From User" <fromuser@xyz.com@DOMAIN> If me.replyto>< "then call Me.getdomain () Maildoc. Replyto=me.replyto & @ & Me.domain End If if me.principal>< "then call Me.getdomain () Maildo C.principal =me.principal & @ & Me.domain End if call Maildoc.send (False) Dim msg as String If Isarra  Y (sendto) then Msg=join (sendto) Else msg=sendto End If Print ' sent mail to ' & msg End Function Public function CopyItem (item as Notesitem, ItemName as String) call Maildoc.copyitem (item, itemname) End Function End Class 

The call is simple:

Dim mail As New Mail (sendTo, subject, body)
Dim replyTo As String
replyto= "John Henry"
Mail. Principal=replyto
Mail. Replyto=replyto Call
Mail. Send ()

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.