Using a LotusScript agent to reply to mail from the Internet
2016-08-24 20:45
1836 查看
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 senderwith 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
'set the subject of the email to go out
Subject = "Re: " + doc.GetItemValue("Subject")(0)
'loop through the document collection
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)
Elseif doc.HasItem("From") Then
OriginalFromAddress = doc.GetItemValue("From")(0)
Else
Goto nextdoc
End If
'if an @ sign is found, send a reply
If Instr(OriginalFromAddress,"@") <> 0 Then
'create a new mail document
Set MailDoc = db.CreateDocument
'set the subject and from fields
Call MailDoc.ReplaceItemValue("Subject", Subject)
'set the body and append the body from the original email
Set OldBody = doc.GetFirstItem("body")
Set body = MailDoc.CreateRichTextItem("body")
Call body.AppendText(bodyText)
Call body.AddNewline(2)
Call body.AppendRTItem(oldBody)
'send the document
Call MailDoc.Send(False,OriginalFromAddress)
End If
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)
Wend
相关文章推荐
- Setting the Reply-To Header in an Email using CDONTS.NewMail Object and CDO Message
- How to download streaming audio or video media from the internet using the MMS protocol?
- Using the string repalce action in SharePoint workflow designer to send mail from mail template
- The Internet of Things: From RFID to the Next-Generation Pervasive Networked Systems
- Using MingW to build VLC from the source
- How to get the Values of Selected Row from a Gridview using ASP.NET
- Introduction to Using the XML DOM from Visual C++
- 让国外邮件服务商不再拒收你的邮件,The IP you're using to send mail is not authorized
- How to get the password text in a text with password property from another process using C++ - 用C++如何从不同进程获取密码框文本
- [转]让国外邮件服务商不再拒收你的邮件,The IP you're using to send mail is not authorized
- Script do the data transfer from target server to local
- Using a Custom Script Library for Common Tasks(refer to MS The Office InfoPath 2003 SDK)
- LotusScript Class to do client or server side FTP on Win32 platform. FTP using script and wininet.dll.
- Using Timer to get history values from EDNA database, an error is prompted in the page : "Sys.WebForms.PageRequestManagerTimeout
- ssh免密码登陆问题Agent admitted failure to sign using the key
- Siebel Tools: How To Invoke Script from a Siebel Button At the Business Component and Applet Levels
- How to add icon for the item of ListCtrl using C++ (Mail Attachment ListCtrl) - 如何用C++为ListCtrl的Item添加图标(邮件附件ListCtrl)
- How to check the MS SQL Server job run status by using Script
- Sample Script for Detecting the .NET Framework 3.0 Using Internet Explorer
- Introduction to Using the XML DOM from Visual C++