Detailed E-Mail Agent

Have you ever wanted to send a mail message to notify users when a document has been created or modified? Of course

you can use the Send Mail basic action or the @MailSend function, however both are limited in what you can do with the message. One limitation is the ability to change text attributes (like color, font size, etc.). The example below will do the following: 1. Look for unprocessed documents 2. Read in several fields from the unprocessed documents. 3. Create an e-mail message with field labels and data as listed on the documents using different colors. 4. If special conditions exist with the requested and/or servers field, a new paragraph is added. 5. A doc-link is attached and the document is e-mailed. Note - this process was created for use with an online request form for catering services. Enjoy! jv REM Establish Elements Dim db As NotesDatabase Dim session As New NotesSession Dim collection As NotesDocumentCollection Dim doc As NotesDocument Dim maildoc As NotesDocument Dim rtitem As NotesRichTextItem Dim richstyle As NotesRichTextStyle REM Set Environment Set db = session.CurrentDatabase Set collection = db.UnprocessedDocuments REM Established Loop For Mail Agent For i=1 To Collection.Count Set doc = Collection.GetNthDocument(i) REM Set variable values DateofFunction$=doc.DateofFunction(0) NumberofGuests$=doc.NumberofGuests(0) Location$=doc.Location(0) FunctionTime$=doc.Time(0) ChargeToName$=doc.ChargeToName(0) ChargeToAcct$=doc.ChargeToAcct(0) Requested$=doc.Requested(0) Servers$=doc.Servers(0) REM Set Environment for e-mail messsage. Set maildoc = New NotesDocument(db) Set richstyle = session.CreateRichTextStyle Set rtitem = New NotesRichTextItem(maildoc,"Body") REM Create message, as described below: REM Write original line in black text: Call rtitem.AppendText("The following request has been submitted online:") REM Skip two lines and tab indent. Call rtitem.AddNewLine( 2 ) Call rtitem.AddTab( 1 ) REM Write labels in black, the data in dark magenta. Call rtitem.AppendText("Date of Function: ") richstyle.NotesColor = COLOR_DARK_BLUE Call rtitem.AppendStyle(richstyle) Call rtitem.AppendText(Cstr(DateofFunction$)) REM Skip one line, tab indent and change color to black. Call rtitem.AddNewLine( 1 ) Call rtitem.AddTab( 1 ) richstyle.NotesColor = COLOR_BLACK Call rtitem.AppendStyle(richstyle) Call rtitem.AppendText("Number of Guests: ") richstyle.NotesColor = COLOR_DARK_BLUE Call rtitem.AppendStyle(richstyle) Call rtitem.AppendText(Cstr(NumberofGuests$)) REM Skip one line, tab indent and change color to black. Call rtitem.AddNewLine( 1 ) Call rtitem.AddTab( 1 ) richstyle.NotesColor = COLOR_BLACK Call rtitem.AppendStyle(richstyle) Call rtitem.AppendText("Location: ") richstyle.NotesColor = COLOR_DARK_BLUE Call rtitem.AppendStyle(richstyle) Call rtitem.AppendText(Cstr(Location$)) REM Skip one line, tab indent and change color to black. Call rtitem.AddNewLine( 1 ) Call rtitem.AddTab( 1 ) richstyle.NotesColor = COLOR_BLACK Call rtitem.AppendStyle(richstyle) Call rtitem.AppendText("Function Time: ") richstyle.NotesColor = COLOR_DARK_BLUE Call rtitem.AppendStyle(richstyle) Call rtitem.AppendText(Cstr(FunctionTime$)) REM Skip one line, tab indent and change color to black. Call rtitem.AddNewLine( 1 ) Call rtitem.AddTab( 1 ) richstyle.NotesColor = COLOR_BLACK Call rtitem.AppendStyle(richstyle) Call rtitem.AppendText("Charge To (Name/Account): ") richstyle.NotesColor = COLOR_DARK_BLUE Call rtitem.AppendStyle(richstyle) Call rtitem.AppendText(Cstr(ChargeToName$)+"/") Call rtitem.AppendText(Cstr(ChargeToAcct$)) REM Change color to black. richstyle.NotesColor = COLOR_BLACK Call rtitem.AppendStyle(richstyle) Call rtitem.AddNewLine( 2 ) REM Check for special conditions in the request. If Requested$="Yes" Or Servers$="Yes" Then Call rtitem.AppendText(

This was first published in November 2000

Dig deeper on Domino Resources - Part 3

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

SearchWinIT

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchEnterpriseLinux

SearchVirtualDataCentre.co.uk

Close