Search

Tuesday, March 27, 2007

Auto reply email script - LotusScript

Today I had to write a script to run in a Lotus Notes database that generates an auto reply email when a form is submitted. The email is sent to the email address specified in the "Email" field on the form. This script is relatively simple, written in LotusScript and works a treat. One tricky thing that I had to work out was to be able to send the email from a specific email address, as setting "From" field did not work. When the email hit the Domino server its value was set Anonymous. This causes problems as allot of spam filters reject the email, including Google's, which was what I was originally testing with. I have commented out the "ReplyTo" as even without this set, when you click reply in your Inbox the email still replies to info@munchtechnologies.com.au. If someone out there knows why this is I would be interested.

Sub Initialize

Dim Session As New NotesSession
Dim DocWeb As NotesDocument
Dim DBCur As NotesDatabase
Dim tmpEmail As String
Dim EmailTo As String
Dim rtitem As NotesRichTextItem

Set DBCur = Session.CurrentDatabase
Set DocWeb = Session.DocumentContext

tmpEmail = DocWeb.GetFirstItem("Email").Text

Set WorkApps = New NotesDocument(DBCur)
Set rtitem = New NotesRichTextItem( WorkApps , "Body")

WorkApps.SendTo = tmpEmail
WorkApps.Principal = "info@munchtechnologies.com.au"
WorkApps.INetFrom = "info@munchtechnologies.com.au"
WorkApps.DisplaySent = "info@munchtechnologies.com.au"
'WorkApps.ReplyTo = "info@munchtechnologies.com.au"
'WorkApps.From = "info@munchtechnologies.com.au"
WorkApps.Form = "Memo"
WorkApps.Subject = "Job Application Received - Munch Technologies"

Call rtitem.appendtext("This email is to let you know that we have received your job application.")
Call rtitem.AddNewline(2)
Call rtitem.appendtext("If you are required for an interview, a member of the Munch Technologies Management Team will contact you directly.")
Call rtitem.AddNewline(2)
Call rtitem.appendtext("Thank you for taking the time to complete the application form. Your application will be kept on file for 3 months.")
Call rtitem.AddNewline(2)
Call rtitem.appendtext("For any further information please contact us directly through the contact us section at http://www.munchtechnologies.com.au")
Call rtitem.AddNewline(2)

WorkApps.send True

End Sub


Hope you Lotus Notes heads out there find this useful.


10 comments:

  1. Anonymous6:03 pm

    Hi there,

    I was wondering if you ever cam right with the script?? I need something like this asap..

    please let me know @ riaan.louw@pttransformers.co.za

    ReplyDelete
  2. Anonymous5:43 am

    Hi Not sure you check this still, but principal is the value used to calculate the reply from address.

    Dan...

    ReplyDelete
  3. can any of u please help me how to use a mail stationary for sending mails in lotus notes by writing a vbscript? i am automating mail sending via lotus notes ans I just need the piece of code to use a specefic stationary.

    pls mail me the solution at nabo_sarkar@yahoo.co.in

    Thanks a lot

    ReplyDelete
  4. Anonymous3:57 am

    ehh. really like this thread ))

    ReplyDelete
  5. Anonymous8:17 pm

    please tell me, how to make an notify at a specified time (step to setup, souce code, example...), such as send mail or alarm message box with lotus script. Thanks a lot.

    ReplyDelete
  6. That's very convenient. The auto reply email script can definitely help in a lot of ways. Thanks for sharing.

    web design Perth

    ReplyDelete
  7. reply to Anonymous - just make the agent a scheduled agent so that it runs at that time? Did i answer your question or do you mean something else?

    ReplyDelete
  8. Anonymous11:09 pm

    This comment has been removed by a blog administrator.

    ReplyDelete
  9. Anonymous10:13 am

    This comment has been removed by a blog administrator.

    ReplyDelete

Thank you for taking time to comment.. Please show your support by "like" or "tweeting" this post.. Thank you..