2011-05-28

Auto Response Email, A Lotus Notes Agent

The company's Lotus Notes' auto-reply was not up to par from what I wanted. Unlike GMail's auto-reply settings, which only displays the Subject and message Body that I specified, Lotus Notes went a step ahead. It appends the received email's Subject on my replying email and added an out-of-office status as well as returning date, which I would want it to be indefinite. Conclusion, crap.

Contacted the Domino support team and the Domino head suggested to use Lotus Notes Agent instead. She managed to do a test and demonstrated it. It seems to worked as per what I wanted. Unfortunately, the teaching-one-to-fish-instead-of-feeding-one-with-fish philosophy was used on myself this time. Hence I had to spend extra miles to do research on this to perfecting this auto-reply to make it seems legit.

What I would want to achieve is something like this.

fromMail Delivery Subsystem mailer-daemon@googlemail.com
tomyemail@gmail.com
date28 May 2011 11:18
subjectDelivery Status Notification (Failure)


Delivery to the following recipient failed permanently:

    fake_email@abc.com

Technical details of permanent failure:
Google tried to deliver your message, but it was rejected by the recipient domain. We recommend contacting the other email provider for further information about the cause of this error. The error that the other server returned was: 550 550 5.1.1 <fake_email@abc.com>... User unknown (state 14).

----- Original message -----

MIME-Version: 1.0
Received: by 10.216.91.17 with SMTP id g17mr1347436wef.1.1306552727107; Fri,
 27 May 2011 20:18:47 -0700 (PDT)
Received: by 10.216.55.145 with HTTP; Fri, 27 May 2011 20:18:47 -0700 (PDT)
Date: Sat, 28 May 2011 11:18:47 +0800
Message-ID: <BANLkTimrR3ZgANSc76ZFEL1z8x4-OpnDwA@mail.gmail.com>
Subject: Test email bounce
From: =?UTF-8?B?Q8+JIFRoYW0=?= <myemail@gmail.com>
To: fake_email@abc.com
Content-Type: multipart/alternative; boundary=0016e6d7df742df8bd04a44d83f1

This is a test for email rebounce.


And this was what I have achieved

fromdaemon@testemail.com
tomyemail@gmail.com>
date27 May 2011 16:38
subjectDelivery Status Notification (Failure)
mailed-bytestemail.com


Delivery to the following recipient failed permanently:

    valid_email@testemail.com

Technical details of permanent failure:
We tried to deliver your message, but it was rejected by the recipient
domain. We recommend contacting the other email provider for further
information about the cause of this error. The error that the other
server returned was: 550 550 5.1.1 <valid_email@testemail.com>...
User unknown (state 14).

I think this is quite acceptable, although it wasn't exactly as per a legit bounced email like. As long as the recipient could understood that their email went into an invalid mailbox.

The working code for this in Lotus Script
Sub Initialize
 Dim session As New NotesSession
 Dim db As NotesDatabase
 Set session = New NotesSession
 Set db = session.CurrentDatabase
 Set docs = db.UnprocessedDocuments
 Count = docs.Count
REM if we have new mail start processing
 If docs.Count > 0 Then
  For n = 1 To docs.Count
   Set memo = docs.GetNthDocument(n)
   If Not( memo.SentByAgent ) Then
REM if attachemetns were stripped, send a reply
    Set reply = memo.CreateReplyMessage( False )
    reply.From = "Mail Delivery Subsystem"
    reply.Principal = "daemon@testemail.com"
    reply.Subject = "Delivery Status Notification (Failure)"
    reply.Body = "Delivery to the following recipient failed permanently:" & Chr(13) & Chr(10)
    reply.Body = reply.Body & "" & Chr(13) & Chr(10)
    reply.Body = reply.Body & "     valid_email@testemail.com" & Chr(13) & Chr(10)
    reply.Body = reply.Body & "" & Chr(13) & Chr(10)
    reply.Body = reply.Body & "Technical details of permanent failure:" & Chr(13) & Chr(10)
    reply.Body = reply.Body & "We tried to deliver your message, but it was rejected by the recipient" & Chr(13) & Chr(10)
    reply.Body = reply.Body & "domain. We recommend contacting the other email provider for further" & Chr(13) & Chr(10)
    reply.Body = reply.Body & "information about the cause of this error. The error that the other" & Chr(13) & Chr(10)
    reply.Body = reply.Body & "server returned was: 550 550 5.1.1 <valid_email@testemail.com>..." & Chr(13) & Chr(10)
    reply.Body = reply.Body & "User unknown (state 14)."
    Call reply.Send( False )
   End If
   Call session.UpdateProcessedDoc(memo) 
  Next
 End If
End Sub

No comments:

Post a Comment