📄 ch7.htm
字号:
<td WIDTH="127"> </td>
<td WIDTH="232"><tt><font FACE="Courier">MsgID</font></tt> </td>
<td WIDTH="232">Internally generated unique ID value.</td>
</tr>
<tr>
<td WIDTH="127"> </td>
<td WIDTH="232"><tt><font FACE="Courier">MsgIndex</font></tt> </td>
<td WIDTH="232">Pointer to the current message in the message collection. </td>
</tr>
<tr>
<td WIDTH="127"> </td>
<td WIDTH="232"><tt><font FACE="Courier">MsgNoteText</font></tt> </td>
<td WIDTH="232">This is the actual body of the message (less any attachments). </td>
</tr>
<tr>
<td WIDTH="127"> </td>
<td WIDTH="232"><tt><font FACE="Courier">MsgOrigAddress</font></tt> </td>
<td WIDTH="232">Address of the originator (sender) of the current message. </td>
</tr>
<tr>
<td WIDTH="127"> </td>
<td WIDTH="232"><tt><font FACE="Courier">MsgOrigDisplayName</font></tt> </td>
<td WIDTH="232">Contains the display name associated with the <tt><font FACE="Courier">MsgOrigAddress</font></tt>
property. </td>
</tr>
<tr>
<td WIDTH="127"> </td>
<td WIDTH="232"><tt><font FACE="Courier">MsgRead</font></tt> </td>
<td WIDTH="232">Flag to indicate that the message has been read by the user to whom it was
addressed. When set to <tt><font FACE="Courier">True</font></tt>, the user has read the
message. </td>
</tr>
<tr>
<td WIDTH="127"> </td>
<td WIDTH="232"><tt><font FACE="Courier">MsgReceiptRequested</font></tt> </td>
<td WIDTH="232">Flag to indicate that a return receipt has been requested by the sender.
When set to <tt><font FACE="Courier">True</font></tt>, the sender wants a confirmation
that the message has been successfully delivered. </td>
</tr>
<tr>
<td WIDTH="127"> </td>
<td WIDTH="232"><tt><font FACE="Courier">MsgSent</font></tt> </td>
<td WIDTH="232">Flag to show that the message has been sent to the mail server for
delivery. This flag is updated by the server, not the client. </td>
</tr>
<tr>
<td WIDTH="127"> </td>
<td WIDTH="232"><tt><font FACE="Courier">MsgSubject</font></tt> </td>
<td WIDTH="232">The text line that identifies the subject of the message. </td>
</tr>
<tr>
<td WIDTH="127"> </td>
<td WIDTH="232"><tt><font FACE="Courier">MsgType</font></tt> </td>
<td WIDTH="232">Contains the message type code. Currently, all <tt><font FACE="Courier">MsgType</font></tt>
codes are left null or empty to indicate an Interpersonal Message (IPM). </td>
</tr>
<tr>
<td WIDTH="127">Recipient</td>
<td WIDTH="232"><tt><font FACE="Courier">RecipAddress</font></tt> </td>
<td WIDTH="232">Address of the current recipient (could be a list). </td>
</tr>
<tr>
<td WIDTH="127"> </td>
<td WIDTH="232"><tt><font FACE="Courier">RecipCount</font></tt> </td>
<td WIDTH="232">Contains the number of recipients for the current piece of mail. </td>
</tr>
<tr>
<td WIDTH="127"> </td>
<td WIDTH="232"><tt><font FACE="Courier">RecipDisplayName</font></tt> </td>
<td WIDTH="232">The display name associated with an address in the address book. </td>
</tr>
<tr>
<td WIDTH="127"> </td>
<td WIDTH="232"><tt><font FACE="Courier">RecipIndex</font></tt> </td>
<td WIDTH="232">Points to the current recipient in the list. </td>
</tr>
<tr>
<td WIDTH="127"> </td>
<td WIDTH="232"><tt><font FACE="Courier">RecipType</font></tt> </td>
<td WIDTH="232">Shows what type of recipient is currently pointed to by the <tt><font
FACE="Courier">RecipIndex</font></tt> property. A value of <tt><font FACE="Courier">0</font></tt>
= <tt><font FACE="Courier">OrigList</font></tt> (used only by the message editor); <tt><font
FACE="Courier">1</font></tt> = <tt><font FACE="Courier">ToList</font></tt> (a person in a
"To" address list); <tt><font FACE="Courier">2</font></tt> = <tt><font
FACE="Courier">CcList</font></tt> (a person on the courtesy copy list); <tt><font
FACE="Courier">3</font></tt> = <tt><font FACE="Courier">BccList</font></tt> (a person on
the blind courtesy copy list). </td>
</tr>
<tr>
<td WIDTH="127">Other</td>
<td WIDTH="232"><tt><font FACE="Courier">Action</font></tt> </td>
<td WIDTH="232">Carryover from Visual Basic 3.0-use the new methods instead. </td>
</tr>
<tr>
<td WIDTH="127"> </td>
<td WIDTH="232"><tt><font FACE="Courier">SessionID</font></tt> </td>
<td WIDTH="232">Contains the value of the <tt><font FACE="Courier">SessionID</font></tt>
generated by the <tt><font FACE="Courier">MAPISession</font></tt> control. You must update
this property before you can perform any Message operations. </td>
</tr>
</table>
</center></div>
<p>You can use these properties to modify the behavior of the MAPI dialog boxes supplied
by the mail server. For example, you can change the caption of the address list, change
the number of buttons that appear on the list, even change the caption of the <tt><font
FACE="Courier">To:</font></tt> button. You can also use these properties to add increased
functionality to your Visual Basic mail applications by honoring attached documents,
allowing the use of blind courtesy copy recipients, and so on. </p>
<p>While there are a number of things you can do with the numerous properties of the <tt><font
FACE="Courier">MAPIMessage</font></tt><font FACE="AGaramond Bold"> </font>control, one of
the most useful is the ability to create e-mail attachments. That is the subject of the
next section. </p>
<h4>Creating E-Mail Attachments</h4>
<p>Creating e-mail attachments is very useful and very easy to do with the <tt><font
FACE="Courier">MAPIMessage</font></tt> control and Visual Basic. Attachments can be simple
text files, word processing documents, or even databases. For the next example, you'll
attach a system file from a user's workstation and prepare a message to send to the help
desk at a large corporation. </p>
<p>There are four property values you need to set in order to successfully create an
e-mail attachment:
<ul>
<li><tt><i><font FACE="Courier">AttachmentPathName</font></i></tt>-This contains the
complete filename as it is used by the operating system (for example, <tt><font
FACE="Courier">c:\config.sys</font></tt> or <tt><font FACE="Courier">\\server\directory1\file.ext</font></tt>).
</li>
<li><tt><i><font FACE="Courier">AttachmentName</font></i></tt>-This is a text string that
appears underneath the attachment icon in the message. </li>
<li><tt><i><font FACE="Courier">AttachmentType</font></i></tt>-This flag tells the server
what type of attachment you are using. Visual Basic constants for this property are <tt><font
FACE="Courier">mapData</font></tt> (a data file), <tt><font FACE="Courier">mapEOLE</font></tt>
(an embedded OLE object), and <tt><font FACE="Courier">mapSOLE</font></tt> (a static OLE
object). </li>
<li><tt><i><font FACE="Courier">AttachmentPosition</font></i></tt>-This is an integer value
that contains the exact character position where the attachment icon is to appear in the
message text. </li>
</ul>
<div align="center"><center>
<table BORDERCOLOR="#000000" BORDER="1" WIDTH="80%">
<tr>
<td><b>Note</b></td>
</tr>
<tr>
<td><blockquote>
<p>If you plan on adding multiple attachments to the message, you'll also need to use the <tt><font
FACE="Courier">AttachmentCount</font></tt> and <tt><font FACE="Courier">AttachmentIndex</font></tt>
properties to fetch the attachments when you read the message. </p>
</blockquote>
</td>
</tr>
</table>
</center></div>
<p>You can add an attachment to any valid message in the compose buffer. The code example
below creates a new message and adds the workstation's <tt><font FACE="Courier">CONFIG.SYS</font></tt>
file as an attachment. Modify the <tt><font FACE="Courier">Form_Load</font></tt> event of <tt><font
FACE="Courier">CDG0702.FRM</font></tt> to match the code in Listing 7.11. </p>
<hr>
<blockquote>
<b><p>Listing 7.11. Creating an e-mail attachment.<br>
</b></p>
</blockquote>
<blockquote>
<tt><font FACE="Courier"><p>Private Sub Form_Load()<br>
'<br>
MAPISession1.SignOn ' log into MAPI
server<br>
MAPIMessages1.SessionID = MAPISession1.SessionID <br>
'<br>
MAPIMessages1.Compose ' clear buffer<br>
MAPIMessages1.MsgSubject = "User's CONFIG.SYS File"<br>
MAPIMessages1.MsgNoteText = "Here is the CONFIG.SYS
File" + Chr(13) + " "<br>
'<br>
MAPIMessages1.AttachmentPosition = Len(MAPIMessages1.MsgNoteText) <br>
MAPIMessages1.AttachmentType = mapData <br>
MAPIMessages1.AttachmentName = "System Configuration
File"<br>
MAPIMessages1.AttachmentPathName = "C:\CONFIG.SYS" <br>
'<br>
MAPIMessages1.Send True ' send it<br>
'<br>
MAPISession1.SignOff ' exit MAPI server<br>
End<br>
'<br>
End Sub</font></tt> </p>
</blockquote>
<hr>
<p>Now save and run the <tt><font FACE="Courier">CDG0702.VBP</font></tt> project. After
logging onto the mail server, you'll see a form appear with the <tt><font FACE="Courier">C:\CONFIG.SYS</font></tt>
file already attached to the message (see Figure 7.5). </p>
<p><a HREF="f7-5.gif"><b>Figure 7.5 : </b><i>Viewing an added attachment to the message.</i></a>
</p>
<h2><a NAME="BuildingaSimpleMAPIClientApplicatio"><font SIZE="5" COLOR="#FF0000">Building
a Simple MAPI Client Application</font></a></h2>
<p>The rest of this chapter covers the creation of a complete e-mail client for Simple
MAPI access. This example uses all of the default MAPI services supplied by the installed
MAPI service provider. The look and feel of the sign-in dialog box, the compose form, and
the address book are completely controlled by the underlying MAPI engine running on the
workstation. As you saw earlier in the chapter, each of these forms looks different
depending on whether you are running Microsoft Mail, Microsoft Exchange, or any other
MAPI-compliant messaging provider (such as Perfect Office). By using the services already
available on the workstation, you can reduce your coding and maintain a familiar look and
feel for your users' e-mail applications. </p>
<p>You will notice that one of the services unavailable within this client is the ability
to store and retrieve old messages within the existing private and public mail folders.
Simple MAPI services do not include access to the message store. You can only read
information from the inbox using Simple MAPI. The <tt><font FACE="Courier">Send</font></tt>
method automatically writes messages to the outbox, but the Simple MAPI client cannot view
messages in the outbox once they are placed there. </p>
<div align="center"><center>
<table BORDERCOLOR="#000000" BORDER="1" WIDTH="80%">
<tr>
<td><b>Note</b></td>
</tr>
<tr>
<td><blockquote>
<p>The ability to access mail folders is available through MAPI OLE Messaging. You'll
learn how to use OLE Messaging in <a HREF="ch8.htm">Chapter 8</a>, "The OLE Messaging
Library." </p>
</blockquote>
</td>
</tr>
</table>
</center></div>
<h3><a NAME="LayingOuttheForms">Laying Out the Forms</a></h3>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -