http://www-01.ibm.com/support/docview.wss?uid=swg21230700
Technote (FAQ)
Question
In your Lotus Notes® mail file, you want to automatically reply to mail messages that are received from Internet addresses. For example, you want to send a "Thank you for your inquiry" message to all who send you mail from the Internet. How can you do this?
Answer
You can use a LotusScript agent to test for Internet addresses and limit the replies to those senders. For example, the agent below would use the trigger of "After new mail arrives." The agent tests for an Internet address and then sends a reply to the sender with a "Thank you for your inquiry" response.
NOTE: The code below is a sample script provided to illustrate one way to approach this issue. In order for this example to perform as intended, the script must be laid out exactly as indicated below. IBM Support cannot customize this script for a customer's own configuration.
In the script, you can customize the BodyText variable as desired. The code can be placed in the Initialize event.
-
Dim session As New NotesSession
Dim db As NotesDatabase
Dim col As NotesDocumentCollection
Dim doc As NotesDocument
Dim MailDoc As NotesDocument
Dim Body As NotesRichTextItem
Dim OldBody As NotesRichTextItem
Dim OriginalFromAddress As String
Dim Subject As String
Dim BodyText As String
'This is the body of the email, Chr(10) indicates a new line
'you can change the body to whatever you want following this format
BodyText = "Thank you for your inquiry." + Chr(10) +_
"This is an automatically generated response. Please do not reply." + Chr(10) +_
"We will contact you shortly regarding your inquiry." + Chr(10) +_
"Regards," + Chr(10)+_
"John Doe" 'SET THIS TO DESIRED NAME
'set objects-
Set db = session.CurrentDatabase
Set col = db.UnprocessedDocuments
Set doc = col.GetFirstDocument
-
Subject = "Re: " + doc.GetItemValue("Subject")(0)
-
While Not doc Is Nothing
-
'check the address to see if it contains an @ sign
-
If doc.HasItem("SMTPOriginator") Then
- OriginalFromAddress = doc.GetItemValue("SMTPOriginator")(0)
- OriginalFromAddress = doc.GetItemValue("From")(0)
- Goto nextdoc
-
If doc.HasItem("SMTPOriginator") Then
-
'check the address to see if it contains an @ sign
'if an @ sign is found, send a reply-
If Instr(OriginalFromAddress,"@") <> 0 Then
-
'create a new mail document
-
Set MailDoc = db.CreateDocument
-
Call MailDoc.ReplaceItemValue("Subject", Subject)
-
Set OldBody = doc.GetFirstItem("body")
Set body = MailDoc.CreateRichTextItem("body")
Call body.AppendText(bodyText)
Call body.AddNewline(2)
Call body.AppendRTItem(oldBody)
- Call MailDoc.Send(False,OriginalFromAddress)
-
Set MailDoc = db.CreateDocument
-
'create a new mail document
-
Nextdoc:
-
'update the processedDoc flag so that this document isn't processed
'again on a subsequent run
Call session.UpdateProcessedDoc(doc)
'get the next document in the collection- Set doc = col.GetNextDocument(doc)
-
'update the processedDoc flag so that this document isn't processed
-
Set db = session.CurrentDatabase