Domino Connection
There are two steps involved in building a fully functional mail
application:
The AbtNotesDemoMail45 samples is part one
of a two step example that shows you how to create a fully functional mail
front-end. The second part of the mail application is the sample named
Using a view part to list mails in a mail database. In general it is
simple to create a document that is routed by the Domino mail system:
you just have to add an item named recipients containing the intended
recipients for that document as a text list and save the document in the
mailbox file. (If you are not permanently connected to the network, the
mail box file may be on your local system. Otherwise, the mail box file
will be on your mail server). Your personal mail database uses more
complicated concepts, because it offers additional features like: views
that show the documents you sent, other views containing only documents you
received and a view for drafts, not to speak of the calendar functions.
When you use the simple mail approach described earlier, your documents will
not be found in all the views of your mail DB. The following sample
adds the required fields and functions to the standard mail part to make your
mail/memo documents compatible with the Domino mail template
(V.4.5/4.6). The mail form developed here will
allow you to perform the following functions: create and send a mail
memo from a sample mail database, send the document without storing it, send
and store the document, and/ or save the document as draft without sending
it. (You should check the different states of the memo using your Notes
client). The form also provides means to select recipients from the
name & address book as well as a separate dialog to configure the delivery
options of the memo. Note that the most of the application can be
created using the visual programming paradigm.
Make sure you have performed the initial steps to rebuild the samples
before you proceed (Preparation for Version 4.5
Samples).
- Create a new visual part. Add a Domino Mail part from the parts
palette to the free form surface. If you have not already done so,
create a connection specification named MySampleMail for the local
\vasample\va45mail.nsf database. If you have not already done
so, create a connection specification named MyMailBox for the local
\vasample\mailbox.nsf database. Double click on the mail part to
configure it using the settings pages. On the first setting page select
the MySampleMail alias to connect the mail part to the sample mail
database. From the Available Forms drop down list box select
Memo. Click on the Mail Settings notebook page to open the
second settings page. In the Mail Box Settings section select
MyMailBox.
- This setting lets you store all documents that would be sent in an
productive system to local database that represents a mail box. You can
open this database (it comes with the sample databases and is named
mailbox.nsf) and view the contents. That mail box will however
not deliver your mail, because the mail router is not aware of this
database. If you want your sample mail to really be delivered, create a
connection specification for your mail server's mail box and set up your
mail part using this connection spec.
- Add the following items to the Field names that specify valid recipients
list: SendTo, CopyTo, BlindCopyTo. The content of all of these
field will be copied to the recipients field automatically prior to
delivery. Click on the User Defined Items tag of the third notebook
page and add the following extra items to the memo form: Returnreceipt
(data type: Text), Deliveryreport (data type: Text),
Deliverypriority (data type: Text), Importance (data type: Text),
Postdate (data type: Time and Date). Apply the changes.
- Connect the aboutToOpenWidget event of the main window to the
open action of the mail part. Connect the
aboutToCloseWidget event of the main window to the close
action of the mail part. Also connect the openedWidget event
of the main window to the newNote action of the mail part.
You will always have a new document available when you open the
application. Tear off the currentNote attribute of the mail
part and drop it to the free from surface. Add entry fields for the
following items: From (Text), SendTo (Text), CopyTo (Text), BlindCopyTo
(Text), Subject (Text), Body (Multi Line Edit). Open the settings for
each entry field and select the appropriate converters (text list for SendTo,
CopyTo, BlindCopyTo, then text for From and Subject, and finally Composite for
the Body). Connect the object attribute of each of the entry
fields to the corresponding attribute of the currentNote part.
- Add three buttons to the main window labeled: Send, Send and Save,
Save as Draft. After that, connect the clicked event of the
Save as Draft button to the storeNote action of the mail
part. That action will store the new document in the mail database
without copying it to the mail box. Add another connection:
Select the clicked event of the Save as Draft button to the
newNote action of the mail part, so a new mail is created after you
decided to store the previous document. It is important to have the
current date and time available for mail processing, because usually the mail
documents based on a Domino 4.5/4.6 mail template contain an
item named Postdate.
- You have already added the appropriate item during setup of the mail
part. Now you have to write a script to get the current time and date
from the system. To do that, switch to the Public Interface Editor and
add an attribute named currentTime. Select Add with
Defaults, but delete the Set Selector because the current time is read
only. Use the File menu option Generate default
scripts, and select Generate all. Switch to the Script
editor and write the following code to the currentTime
method:
currentTime
"Return the value of currentTime."
^AbtLnEnvironment currentTimeDate contents
- You are now ready to program the Send and Save and the Send
buttons. Connect the clicked event of the Send and Save
button to the Postdate attribute of the currentNote part.
Provide the necessary parameter by connecting the currentTime
attribute of the main windows with the value attribute of the
connection between Send button and Postdate. Connect the
clicked event of the button to the sendMail action of
the mail part and connect the clicked event of the button to the
storeNote action of the mail part. Also connect the
newNote action of the mail part to create a new document whenever
the preceding document was sent. Be aware that the order of the
connections is important to the functionality of the sample
application. If you change or reverse the order, the sample will not
function properly.
- Proceed with the Send button. Build all connection like with the
Send and Save button, but leave out the storeNote action of the mail
part. Finally you need to provide some sender information. The
current user's name can be retrieved from a database part. Tear
off the database attribute of the mail part and connect the
currentUserName attribute from the tear off to the object attribute
of the field that is also connected to the From attribute of the
current note. The mail form is now functional, but we will add some
more features:
- Add a second window named Recipients to the free form surface. You
will use this window select from the list of available recipients. Also
add an Domino Address Book to the free form surface. Double click on
the address book part and configure the following settings: Select
ConTo45PersAdrBook as connection specification (this a sample
database that comes with the Domino Connection product) and select the
$VIMPeopleAndGroups view as a source for displaying the list of
valid recipients. Select the second notebook page named Address Book
and $1 as Name Column. This selection chooses the appropriate column
from the view that contains names and group names. $1 might seem to be
a strange name for a column, but it is the way Domino labels columns that
display calculated values. Have a look at the address book database and
check out which column you selected. To open address book part when it
is needed, do the following: Add a push-button named Address to the main
window. Connect the clicked event of the button to the
openApplicationModalWidget action of the Recipients windows.
Add a Button named Cancel to the Recipients window and connect the
clicked event to the closeWidget action of the
Recipients window. Also connect the opened event of the
Recipients window with the open action of the address book part and finally
connect the AboutToCloseWidget event of the Recipients window with
the close action of the address book part.
- To make sure the address book view is always up to date connect the
OpenedWidget event of the Recipients window with the
update action of the address book part. Add a simple list
and three more buttons to the Recipients window. Label the buttons
SendTo, CopyTo and BlindCopyTo. The buttons will be used to transfer
selected recipients to the current mail document. Now connect the
items attribute of the list with the names attributes of
the address book part to display the list of available recipients in the
list. To copy selected recipients for the Recipients windows list do
the following: Connect the clicked event of the SendTo button
with the object attribute of the SendTo entry field in the main
window. You have to supply a parameter for the event-to-attribute
connection: select the selectedItems attribute of the list in
the Recipients window to the value attribute of the
connection. Proceed with the other buttons and connect them to their
respective entry fields.
- As the last step, add another window to the free form surface called
DeliveryOptions. This window will be used to set the delivery options
for the current mail document. To open that window, add another button
to the main windows and label it: DeliveryOptions. Connect the
clicked event to the openApplicationModalWidget action
of the DeliveryOptions window. Add four drop down listboxes to the
DeliveryOptions window. Label them Return receipt, Delivery Report,
Delivery Priority and Importance. You now have to supply the possible
values of each of the delivery options. To do that, open the settings
for each drop down list and supply the following values for the items
attribute: List Name Values Return receipt ReturnReceipt, Delivery
report Only on failure, Confirm delivery, Trace entire path Delivery priority
High, Normal, Low Importance High, Normal, Low.
- Now connect each of the lists selectedItem attributes to the
appropriate item in the currentNote part. You have now built a part
that works much like a Memo form in the Lotus Notes client. Continue
with the next sample to create an appropriate view for the mail sample:
If anything does not work as expected, compare your work with the sample code
in AbtNotesDemoApp45
The AbtNotesDemoMailView45 sample is supplied to
build a fully functional mail client. It consists of a list that
displays the ($All) view of the sample mail database and lets you create and
edit mail documents with the AbtLnotesDemoMail45 part. Be
aware that the ($All) shows all the documents in the mail database, including
draft documents and the calendar entries. The mail part supplied for
this sample however is built to edit documents of the Memo type only.
If you edit for example a Calendar Entry with the mail part, you may not see
all items in the respective note. To avoid this problem, you can supply
alternative mail parts (which model other forms) and connect them to the
appropriate events of the ViewTable part (see detailed sample
description). The view part itself is fairly simple and works much like
the other view sample (Using a view part). You
will need the AbtNotesDemoMail45 part to build this sample. If you have
not built that sample, perform the steps described in Using a form part to create and edit mail
documents before you proceed.
Make sure you have performed the initial steps to rebuild the samples
before you proceed (Preparations for Version 4.5
samples). Create a new Visual Part .
- Select Domino Parts from the parts palette and add a Domino View part to
the free form surface. Double-click the view part to open the settings
page. From the Alias Name dropdown listbox select the
ConTo45SampleMail connection alias. The view part is now
reading structural information about the sample database. From the View
Name dropdown list select ($All). Select the Error Reporter Creation
Automatic check box to make the part ready for automatic error
handling. Select OK to close the settings page. You
have now configured the view part to represent the ($All) view of the mail
sample database.
- Connect the aboutToOpenWidget event of the main window to the
open action of the view part to initialize the part during runtime.
Connect the aboutToCloseWidget event of the main window to the
close action of the view part to free resources when the program
ends.
- Tear off the database attribute of the view part and place it on the free
form surface. From the view parts' pop-up menu use Quick
Form and select ViewTable to create a listbox (actually a
tree view) to display the views contents in the window. Place the tree
view in the main window. Delete the first and the fourth column from
the list, because they are used for programming purposes in Domino and need
not be displayed.
- Add three buttons labeled Update, New and Cancel. Connect the
clicked event of the Update button to the update action
of the view part. Clicking this button will refresh the view index and
collapse the view visually. Connect the clicked event of the
Cancel button to the closeWidget action of the main window.
Before you can connect the New button, we have to add the mail part for
editing the mail documents. From the Options menu select the
Add part option. Supply the name of the part you created
during this sample (or select AbtNotesDemoMail45). As Part type select
View wrapper. If you selected your own mail part, you have to promote a
feature to make an action available for the use with the mail view.
- Select Edit part on the view wrapper's context menu. Select
the Public interface editor and click on the Promote tag.
Add the action named editNote: from the mail part and name it
MailPartEditNote:. Save the part and close the window.
- Now connect the clicked event of the New button to the
openWidget event of the view wrapper. Finally, you have to
take care that double-clicking a document in the view opens the mail part for
editing. Connect the NOTE_Any event of the viewTable to the
openWidget action of the view wrapper. Also connect the
NOTE_Any event to the promoted feature named
MailPartEditNote: of the view wrapper. If you want to
make sure that you only edit documents of the Memo type, do not connect the
NOTE_Any event but the NOTE_Memo event of the viewTable
to the MailPartEditNote: action. You are now ready to
test the part. If anything does not work as expected, compare your work
with the sample code in AbtNotesDemoApp45.
[ Top of Page | Previous Page | Next Page | Table of Contents ]