AOCE Mailer
Volume Number: 10
Issue Number: 2
Column Tag: AOCE
Using The AOCE Standard Mailer 
Adding Standard Mailer support to MacWrite Pro
By Lee Richardson, Claris Corporation
Note: Source code files accompanying article are located on MacTech CD-ROM orsource code disks.
About the author
Lee Richardson is the MacWrite Pro Project Manager at Claris, has been doing
software in various forms for over ten years, and has been working for Claris way
longer than he ever thought he’d work for any company. He’s available on AppleLink
(RICHARDSON7) or CompuServe (74155,435).
MacWrite Pro 1.0, from Claris Corporation, is the latest in a long line of
products that started with the original MacWrite in 1984. MacWrite has gone through
several revisions since then, with the current release offering a variety of high-end
word processing and page layout features. MacWrite has always been known for its ease
of use; MacWrite Pro continues that philosophy.
As part of the 1.5 release of MacWrite Pro, we’ve included support for Apple’s
Open Collaboration Environment (AOCE) by adding Standard Mailer functionality. The
Standard Mailer provides a high-level interface to AOCE, and includes automatic
mailer drawing, mail addressing, catalog management, and support for enclosed files.
By using the Standard Mailer, MacWrite Pro users can more easily share documents
with others, and can stay in the same environment for both word processing and email
tasks.
In this article, I’m going to describe the steps we went through to add Standard
Mailer support to MacWrite Pro. I’ve also included sample code that shows how to read
and write the different letter formats, and how to handle letters in both the mailbox
and on disk.
Note: in the sample code, you’ll see the TRY/CATCH exception mechanism in use.
This is an exception handler originally used in MacApp that simplifies error trapping
(a similar scheme is used in C++). If an error occurs in the TRY block, execution is
transferred to the first instruction in the CATCH block, then optionally back to the
CATCH block in the caller. It’s a handy way to handle errors, but doesn’t otherwise
affect the Standard Mailer examples.
Document Format
When we started working out the details of adding Standard Mailer support to
MacWrite Pro, the first decision we ran into concerned how letters were to be
represented in memory. It initially appeared that letters might be very different
document types, and would need their own document format and saving code. But it
eventually turned out that there were mostly similarities, and that our existing
document structure, with a couple of additions, would suffice. Those additions consisted
of flags for whether the document had a mailer, if the mailer was expanded or
contracted, whether the mailer or the document was the current target, and the
current height of the mailer, in pixels. We also added a LetterDescriptor (described
later) giving the current location of the letter.
Adding a Mailer
Let’s start with a definition: a mailer is the addressing block that appears at the
top of mail capable documents. It includes information about who the letter is from,
who to send it to, the subject of the letter, and a list of enclosed files. Apple
recommends that the mailer appear at the top of the document, just under the title bar,
which is where we put it (we also considered a separate floating window, but decided
the mailer information would be more clearly associated with the document if it was
part of the document window).
The Mailer in a MacWrite Pro Document