📄 ch10.htm
字号:
<html>
<head>
<title>Chapter 10 -- Building a MAPI-Enabled Fourm Tool</title>
<meta NAME="GENERATOR" CONTENT="Microsoft FrontPage 3.0">
</head>
<body TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000EE" VLINK="#551A8B" ALINK="#CE2910">
<!-- Spidersoft WebZIP Ad Banner Insert -->
<!-- End of Spidersoft WebZIP Ad Banner Insert-->
<h1><font COLOR="#FF0000">Chapter 10</font></h1>
<h1><b><font SIZE="5" COLOR="#FF0000">Building a MAPI-Enabled Fourm Tool</font></b> </h1>
<hr WIDTH="100%">
<h3 ALIGN="CENTER"><font SIZE="+2" COLOR="#000000">CONTENTS<a NAME="CONTENTS"></a> </font></h3>
<ul>
<li><a HREF="#DiscussionGroupsversusEMail">Discussion Groups versus E-Mail</a> <ul>
<li><a HREF="#FoldersasDestinations">Folders as Destinations</a> </li>
<li><a HREF="#UsingtheConversationTopicandConversa">Using the ConversationTopic and
ConversationIndex Properties</a> </li>
<li><a HREF="#UpdateversusSend">Update versus Send</a> </li>
</ul>
</li>
<li><a HREF="#TheDiscussProject">The Discuss Project</a> </li>
<li><a HREF="#TheMAPIPostCodeLibrary">The MAPIPost Code Library</a> </li>
<li><a HREF="#TheDiscussandMsgsForms">The Discuss and Msgs Forms</a> <ul>
<li><a HREF="#LayingOuttheDiscussForm">Laying Out the Discuss Form</a> </li>
<li><a HREF="#CodingtheDiscussForm">Coding the Discuss Form</a> </li>
<li><a HREF="#LayingOutandCodingtheMsgsForm">Laying Out and Coding the Msgs Form</a> </li>
</ul>
</li>
<li><a HREF="#BuildingtheOtherForms">Building the Other Forms</a> <ul>
<li><a HREF="#TheNoteForm">The Note Form</a> </li>
<li><a HREF="#TheOptionsForm">The Options Form</a> </li>
<li><a HREF="#TheAboutDialogBox">The About Dialog Box</a> </li>
</ul>
</li>
<li><a HREF="#TestingtheDiscussForumTool">Testing the Discuss Forum Tool </a></li>
<li><a HREF="#Summary">Summary</a> </li>
</ul>
<hr>
<p>In this chapter you'll learn how to use MAPI services to create a threaded discussion
client. Threaded discussions clients are used quite frequently in groupware settings and
on the Internet. The biggest difference between a discussion tool and an e-mail client is
that the e-mail client is designed primarily for conducting one-to-one conversations. The
discussion tool, however, is designed to support multiple parties, all participating in
the same discussion. Even though MAPI services were originally deployed as only an e-mail
solution, Microsoft has added several features to MAPI that now make it an excellent
platform for building discussion applications. </p>
<p>Before getting into the details of building the tool, you'll learn a bit more about the
differences between e-mail and discussion communications. You'll also learn how to take
advantage of little-known MAPI properties and new features of the OLE Messaging library
that make it easy to put together a standalone discussion tool that can be deployed from
within a Local Area Network, over a Wide Area Network, or even across the Internet. You'll
learn
<ul>
<li><font COLOR="#000000">The difference between the MAPI </font><tt><font FACE="Courier">Send</font></tt>
and <tt><font FACE="Courier">Update</font></tt> methods. </li>
<li><font COLOR="#000000">How to use the </font><tt><font FACE="Courier">ConversationTopic</font></tt>
and <tt><font FACE="Courier">ConversationIndex</font></tt> properties to create threaded
discussions in MAPI messages. </li>
<li><font COLOR="#000000">How to create messages that are posted to a MAPI folder instead of
sent to a single individual.</font> </li>
</ul>
<p>As an added bonus, after you've completed the programming example in this chapter,
you'll have a set of library functions that allow you to easily add threaded discussion
capabilities to new or existing Visual Basic applications. </p>
<h2><a NAME="DiscussionGroupsversusEMail"><b><font SIZE="5" COLOR="#FF0000">Discussion
Groups versus E-Mail</font></b></a></h2>
<p>By now, most of us have used electronic discussion forums at least once in our lives.
And there are many who use them every single day. The advantage of a discussion forum over
direct person-to-person e-mail is that you can communicate with a large number of people
without generating a large number of messages. In fact, reduced traffic is one of the
biggest reasons to consider employing discussion groups as part of your electronic message
system. </p>
<p>There are a number of other advantages to using discussion groups instead of e-mail.
Often, it is easier to find answers to technical problems if you can go to a place where
all the "techies" hang out. Discussion forums can work the same way. Instead of
trying to e-mail several people in attempts to solve your problem, you can often find a
discussion forum where you can send a single request that will reach hundreds (possibly
thousands) of people who may be able to help you. So discussion forums can increase your
ability to get your problems solved sooner. </p>
<p>Another good way to highlight the differences between e-mail and discussion groups is
by comparing several face-to-face meetings (e-mail messages) with a single staff meeting
where everyone shows up at the same place at the same time (the discussion forum). Using
forum communications can reduce the amount of time you need to spend communicating. You
can say it once and reach lots of people instead of having to repeat your message in lots
of single e-mail messages. </p>
<p>Companies use forums as a way to communicate information of general interest as well as
a way to take advantage of specialized expertise within an organization. Where corporate
e-mail can lead to isolated individuals communicating in a vacuum, discussion groups can
foster increased interaction with others and a sense of belonging to a special group-even
if one or more of the team members is half-way around the world. </p>
<p>Now that you have a general idea of what discussion groups are and how you can use them
in your organization, you're ready to review the three key concepts that make discussion
systems different from e-mail systems. </p>
<h3><a NAME="FoldersasDestinations"><b>Folders as Destinations</b></a> </h3>
<p>First, and most important, users participating in an online discussion forum do not
send messages to individuals. Instead they send their messaging to a single location where
all messages are stored. In the MAPI model, the storage location is called a folder. When
you create MAPI-based forum tools, you'll select a folder (or folders) to hold all the
correspondence from others participating in the forum. </p>
<div align="center"><center>
<table BORDERCOLOR="#000000" BORDER="1" WIDTH="80%">
<tr>
<td><b>Note</b></td>
</tr>
<tr>
<td><blockquote>
<p>There are times when forum participants will initiate private e-mail correspondence in
order to cover a topic in more depth or to delve deeper into an aspect of the discussion
that would not be interesting to most of the other members.</p>
</blockquote>
</td>
</tr>
</table>
</center></div>
<p>Then, after each message has been composed, you just <i>post</i> the message to the
discussion folder for others to see. They, if appropriate, respond to your message with
their own comments. The key point to remember is that messages are addressed to locations,
not people. </p>
<h3><b><a NAME="UsingtheConversationTopicandConversa">Using the <tt><font SIZE="4"
FACE="Courier">ConversationTopic</font></tt><font SIZE="4"> and </font><tt><font SIZE="4"
FACE="Courier">ConversationIndex</font></tt><font SIZE="4"> Properties</font></a></b></h3>
<p>Another key aspect of discussion groups is the ability to track topics in a <i>thread</i>
that leads from the beginning of the discussion to the end. As each participant replies to
an existing message, a relationship is established between the source message and the
reply. Of course, it is perfectly correct (and quite common) to generate a "reply to
a reply." This can continue on indefinitely. And in the process an intricate web of
ideas and comments all collect in the storage folder that houses the discussion group. </p>
<p>Some discussion tools simply list the messages in the chronological order in which they
were received. These are referred to as <i>non-threaded</i> or <i>flat-table</i>
discussion tools (see Figure 10.1). </p>
<p><a HREF="f10-1.gif"><b>Figure 10.1 : </b><i>Viewing messages in flat format,
chronological order.</i></a> </p>
<p>Non-threaded tools (often called <i>readers</i>) can be handy, but most people prefer
the discussion tools that provide threaded discussion tracking. With threaded tools, each
conversation that is initiated is a <i>branch</i>. Each branch can have its own subsequent
conversation thread. And those threads can be combined with others, too. Viewing
discussion messages as related threads is really handy (see Figure 10.2). </p>
<p><a HREF="f10-2.gif"><b>Figure 10.2 : </b><i>Viewing messages in threaded order.</i></a>
</p>
<p>MAPI uses two special properties of the <tt><font FACE="Courier">Message</font></tt>
object to keep track of each branch and sub-branch of a threaded discussion. These two
properties are the <tt><font FACE="Courier">ConversationTopic</font></tt> and the <tt><font
FACE="Courier">ConversationIndex</font></tt> properties. The <tt><font FACE="Courier">ConversationTopic</font></tt>
is usually a readable string. This is much like the subject line of a mail message.
Conversation topics for a discussion forum for a typical computer firm might be
<ul>
<li><font COLOR="#000000">General questions</font> </li>
<li><font COLOR="#000000">Sales</font> </li>
<li><font COLOR="#000000">Technical support</font> </li>
<li><font COLOR="#000000">Press releases</font> </li>
</ul>
<div align="center"><center>
<table BORDERCOLOR="#000000" BORDER="1" WIDTH="80%">
<tr>
<td><b>Note</b></td>
</tr>
<tr>
<td><blockquote>
<p>Some forums have fixed topics and only allow users to select from a predetermined list
when posting messages. Other forums allow users to enter free-form text into the topic
field.</p>
</blockquote>
</td>
</tr>
</table>
</center></div>
<p>MAPI uses the <tt><font FACE="Courier">ConversationIndex</font></tt> property to keep
track of conversation threads within the topic group. This is usually done using some type
of numbering scheme. Microsoft recommends that programmers use the same method that is
employed by Microsoft Exchange when populating the <tt><font FACE="Courier">ConversationIndex</font></tt>
field. Microsoft Exchange uses the <tt><font FACE="Courier">CoCreateGuid</font></tt> API
call to generate a unique number to place in the <tt><font FACE="Courier">ConversationIndex</font></tt>
field. New messages that respond to an existing message should inherit the <tt><font
FACE="Courier">ConversationIndex</font></tt> of the previous message and append their own
index value to the right. This way, each new branch of the conversation has a longer <tt><font
FACE="Courier">ConversationIndex</font></tt>. You'll get a better look at this technique
when you build the sample Visual Basic project later in this chapter. </p>
<div align="center"><center>
<table BORDERCOLOR="#000000" BORDER="1" WIDTH="80%">
<tr>
<td><b>Note</b></td>
</tr>
<tr>
<td><blockquote>
<p>The <tt><font FACE="Courier">CoCreateGuid</font></tt> API generates a unique value
based on the system date (among other things). You can use any method you wish to keep
track of conversation threads, but it is highly recommended that you use the method
described here. It is quick, effective, and requires very few computing resources. </p>
</blockquote>
</td>
</tr>
</table>
</center></div>
<h3><b><a NAME="UpdateversusSend"><tt><font SIZE="4" FACE="Courier">Update</font></tt><font
SIZE="4"> versus </font><tt><font SIZE="4" FACE="Courier">Send</font></tt></a></b> </h3>
<p>The last major concept to deal with when building discussion tools is the use of the
MAPI <tt><font FACE="Courier">Update</font></tt> method instead of the <tt><font
FACE="Courier">Send</font></tt> method. In all the examples covered in the book so far,
when you complete a new message and want to place it into the MAPI message pool, you use
the <tt><font FACE="Courier">Send</font></tt> method (or some type of <tt><font
FACE="Courier">Send</font></tt> API call) to release the message to MAPI for delivery.
This works when you have a person to whom you are addressing the message. However, because
discussion messages are not addressed to persons but to folders instead, you cannot
"send" new messages. Instead you use the <tt><font FACE="Courier">Update</font></tt>
method to update the contents of a MAPI folder. In fact, attempting to use the <tt><font
FACE="Courier">Send</font></tt> method to deliver forum messages will result in a MAPI
error. </p>
<div align="center"><center>
<table BORDERCOLOR="#000000" BORDER="1" WIDTH="80%">
<tr>
<td><b>Tip</b></td>
</tr>
<tr>
<td><blockquote>
<p>The key idea here is to think of updating the contents of a MAPI folder as opposed to
sending a message to a person.</p>
</blockquote>
</td>
</tr>
</table>
</center></div>
<p>The actual process of placing a message in a MAPI folder includes adding a blank
message to the target folder, setting that message's subject and text body (just like any
mail message) and then setting several other message properties, too. Each of the
properties shown in Table 10.1 must be set properly before you invoke the <tt><font
FACE="Courier">Update</font></tt> method to place a message in a MAPI folder. </p>
<div align="center"><center>
<table BORDERCOLOR="#000000" BORDER="1" WIDTH="80%">
<tr>
<td><b>Note</b></td>
</tr>
<tr>
<td WIDTH="581"><blockquote>
<p>You'll get to see the details of creating a forum message when you build the forum tool
later in this chapter. The main thing to keep in mind now is that you do <i>not</i> use
the <tt><font FACE="Courier">Send</font></tt> method to place messages in folders. </p>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -