Using a LotusScript agent to reply to mail from the Internet

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 
    '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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值