⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch7.htm

📁 MAPI__SAPI__TAPI
💻 HTM
📖 第 1 页 / 共 5 页
字号:
  &nbsp;&nbsp;&nbsp;&nbsp;MAPIMessages1.SessionID = MAPISession1.SessionID <br>
  &nbsp;&nbsp;&nbsp;&nbsp;'<br>
  &nbsp;&nbsp;&nbsp;&nbsp;MAPIMessages1.Fetch&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' get messages<br>
  &nbsp;&nbsp;&nbsp;&nbsp;MAPIMessages1.Forward&nbsp;&nbsp;&nbsp;' forward the current 
  message<br>
  &nbsp;&nbsp;&nbsp;&nbsp;MAPIMessages1.Send True ' send it<br>
  &nbsp;&nbsp;&nbsp;&nbsp;'<br>
  &nbsp;&nbsp;&nbsp;&nbsp;MAPISession1.SignOff&nbsp;&nbsp;&nbsp;&nbsp;' exit MAPI server<br>
  &nbsp;&nbsp;&nbsp;&nbsp;End<br>
  &nbsp;&nbsp;&nbsp;&nbsp;'<br>
  End Sub</font></tt> </p>
</blockquote>

<hr>

<p>You can use the <tt><font FACE="Courier">Fetch</font></tt> method to tell the mail 
server to send your Visual Basic program all the messages that are currently on file in 
the inbox for the logged-on user. The code example shown in Listing 7.8 fetches all the 
messages for the user and then uses the <tt><font FACE="Courier">MsgCount</font></tt> 
property to find out how many messages are actually on file. </p>

<hr>

<blockquote>
  <b><p>Listing 7.8. Displaying the <tt><font FACE="Courier">MsgCount</font></tt> property.<br>
  </b></p>
</blockquote>

<blockquote>
  <tt><font FACE="Courier"><p>Private Sub Form_Load()<br>
  &nbsp;&nbsp;&nbsp;&nbsp;'<br>
  &nbsp;&nbsp;&nbsp;&nbsp;MAPISession1.SignOn&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' log into MAPI 
  server<br>
  &nbsp;&nbsp;&nbsp;&nbsp;MAPIMessages1.SessionID = MAPISession1.SessionID <br>
  &nbsp;&nbsp;&nbsp;&nbsp;'<br>
  &nbsp;&nbsp;&nbsp;&nbsp;MAPIMessages1.Fetch&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' get all 
  messages into inbox<br>
  &nbsp;&nbsp;&nbsp;&nbsp;MsgBox Str(MAPIMessages1.MsgCount)&nbsp;&nbsp;' show number of 
  msgs<br>
  &nbsp;&nbsp;&nbsp;&nbsp;'<br>
  &nbsp;&nbsp;&nbsp;&nbsp;MAPISession1.SignOff&nbsp;&nbsp;&nbsp;&nbsp;' exit MAPI server<br>
  &nbsp;&nbsp;&nbsp;&nbsp;End<br>
  &nbsp;&nbsp;&nbsp;&nbsp;'<br>
  End Sub</font></tt> </p>
</blockquote>

<hr>

<p>You can use the <tt><font FACE="Courier">Delete</font></tt> method to remove messages 
from the user's collection. The <tt><font FACE="Courier">Delete</font></tt> method can 
also be used to remove a single recipient from a list of addresses or to remove a single 
attachment from a list of currently attached files. The code in Listing 7.9 removes the 
current message from the user's collection. </p>

<hr>

<blockquote>
  <b><p>Listing 7.9. Deleting a message from the user's storage.<br>
  </b></p>
</blockquote>

<blockquote>
  <tt><font FACE="Courier"><p>Private Sub Form_Load()<br>
  &nbsp;&nbsp;&nbsp;&nbsp;'<br>
  &nbsp;&nbsp;&nbsp;&nbsp;MAPISession1.SignOn&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' log into MAPI 
  server<br>
  &nbsp;&nbsp;&nbsp;&nbsp;MAPIMessages1.SessionID = MAPISession1.SessionID <br>
  &nbsp;&nbsp;&nbsp;&nbsp;'<br>
  &nbsp;&nbsp;&nbsp;&nbsp;MAPIMessages1.Fetch&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' get all 
  messages into inbox<br>
  &nbsp;&nbsp;&nbsp;&nbsp;MsgBox Str(MAPIMessages1.MsgCount)<br>
  &nbsp;&nbsp;&nbsp;&nbsp;MAPIMessages1.Delete&nbsp;&nbsp;&nbsp;&nbsp;' get rid of first 
  message<br>
  &nbsp;&nbsp;&nbsp;&nbsp;MsgBox Str(MAPIMessages1.MsgCount)<br>
  &nbsp;&nbsp;&nbsp;&nbsp;'<br>
  &nbsp;&nbsp;&nbsp;&nbsp;MAPISession1.SignOff&nbsp;&nbsp;&nbsp;&nbsp;' exit MAPI server<br>
  &nbsp;&nbsp;&nbsp;&nbsp;End<br>
  &nbsp;&nbsp;&nbsp;&nbsp;'<br>
  End Sub</font></tt> </p>
</blockquote>

<hr>

<p>Finally, you can tell the mail server to show you a list of all the mail server 
addresses on file by invoking the <tt><font FACE="Courier">Show</font></tt> method. The <tt><font
FACE="Courier">Show</font></tt> method can also be used to display details of the current 
message recipient (if this is supported by the MAPI mail server). The example code shown 
in Listing 7.10 will display the current mail server address list. </p>

<hr>

<blockquote>
  <b><p>Listing 7.10. Showing the MAPI address book.<br>
  </b></p>
</blockquote>

<blockquote>
  <tt><font FACE="Courier"><p>Private Sub Form_Load()<br>
  &nbsp;&nbsp;&nbsp;&nbsp;'<br>
  &nbsp;&nbsp;&nbsp;&nbsp;MAPISession1.SignOn&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' log into MAPI 
  server<br>
  &nbsp;&nbsp;&nbsp;&nbsp;MAPIMessages1.SessionID = MAPISession1.SessionID <br>
  &nbsp;&nbsp;&nbsp;&nbsp;'<br>
  &nbsp;&nbsp;&nbsp;&nbsp;MAPIMessages1.Show&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' show the 
  addresss list<br>
  &nbsp;&nbsp;&nbsp;&nbsp;'<br>
  &nbsp;&nbsp;&nbsp;&nbsp;MAPISession1.SignOff&nbsp;&nbsp;&nbsp;&nbsp;' exit MAPI server<br>
  &nbsp;&nbsp;&nbsp;&nbsp;End<br>
  &nbsp;&nbsp;&nbsp;&nbsp;'<br>
  End Sub</font></tt> </p>
</blockquote>

<hr>

<h4>Properties</h4>

<p>The <tt><font FACE="Courier">MAPIMessage</font></tt> control has more than thirty 
MAPI-related properties. We will quickly review them here. You can find more detailed 
information on each of the <tt><font FACE="Courier">MAPIMessage</font></tt> control 
properties by consulting the topic &quot;<tt><font FACE="Courier">MAPIMessage</font></tt> 
Control&quot; in the Visual Basic online help file. </p>

<p>The <tt><font FACE="Courier">MAPIMessage</font></tt> control properties can be divided 
into several groups. Each group contains a set of properties that all deal with the same 
aspect of the message services provided by the mail server. Table 7.1 shows the 
MAPI-related properties, divided by service group.<br>
</p>

<p align="center"><b>Table 7.1. MAPI-related properties of the <tt><font FACE="Courier">MAPIMessage</font></tt> 
control.</b> </p>
<div align="center"><center>

<table BORDERCOLOR="#000000" BORDER="1" WIDTH="80%">
  <tr>
    <td><i>Group</i></td>
    <td WIDTH="232"><i>Property</i> </td>
    <td WIDTH="232"><i>Description</i></td>
  </tr>
  <tr>
    <td WIDTH="127">Address</td>
    <td WIDTH="232"><tt><font FACE="Courier">AddressCaption</font></tt> </td>
    <td WIDTH="232">Allows you to set the caption of the Address Book dialog box. </td>
  </tr>
  <tr>
    <td WIDTH="127"> </td>
    <td WIDTH="232"><tt><font FACE="Courier">AddressEditFieldCount</font></tt> </td>
    <td WIDTH="232">Use this property to set the number of edit buttons available on the 
    Address Book dialog box. </td>
  </tr>
  <tr>
    <td WIDTH="127"> </td>
    <td WIDTH="232"><tt><font FACE="Courier">AddressLabel</font></tt> </td>
    <td WIDTH="232">If you use only one edit button (<tt><font FACE="Courier">To:</font></tt>), 
    you can set the button label with this property. </td>
  </tr>
  <tr>
    <td WIDTH="127"> </td>
    <td WIDTH="232"><tt><font FACE="Courier">AddressModifiable</font></tt> </td>
    <td WIDTH="232">When set to <tt><font FACE="Courier">True</font></tt>, allows user to 
    modify the contents of the address book; the default is <tt><font FACE="Courier">False</font></tt>. 
    </td>
  </tr>
  <tr>
    <td WIDTH="127"> </td>
    <td WIDTH="232"><tt><font FACE="Courier">AddressResolveUI</font></tt> </td>
    <td WIDTH="232">When set to <tt><font FACE="Courier">True</font></tt>, presents a dialog 
    box to help users resolve rejected addresses. Use this property in conjunction with the <tt><font
    FACE="Courier">ResolveName</font></tt> method. The default is <tt><font FACE="Courier">False</font></tt>. 
    </td>
  </tr>
  <tr>
    <td WIDTH="127">Attachment</td>
    <td WIDTH="232"><tt><font FACE="Courier">AttachmentCount</font></tt> </td>
    <td WIDTH="232">Contains the number of attachments for the current message. </td>
  </tr>
  <tr>
    <td WIDTH="127"> </td>
    <td WIDTH="232"><tt><font FACE="Courier">AttachmentIndex</font></tt> </td>
    <td WIDTH="232">Pointer to the current attachment in the list. </td>
  </tr>
  <tr>
    <td WIDTH="127"> </td>
    <td WIDTH="232"><tt><font FACE="Courier">AttachmentName</font></tt> </td>
    <td WIDTH="232">Filename of the attachment pointed to by the <tt><font FACE="Courier">AttachmentIndex</font></tt> 
    property. </td>
  </tr>
  <tr>
    <td WIDTH="127"> </td>
    <td WIDTH="232"><tt><font FACE="Courier">AttachmentPathName</font></tt> </td>
    <td WIDTH="232">Contains full pathname of the current attachment. </td>
  </tr>
  <tr>
    <td WIDTH="127"> </td>
    <td WIDTH="232"><tt><font FACE="Courier">AttachmentPosition</font></tt> </td>
    <td WIDTH="232">Position (in characters) where the attachment is located within the 
    message body. </td>
  </tr>
  <tr>
    <td WIDTH="127"> </td>
    <td WIDTH="232"><tt><font FACE="Courier">AttachmentType</font></tt> </td>
    <td WIDTH="232">Indicates the type of the current attachment. Valid values are <tt><font
    FACE="Courier">DATA</font></tt> (data file), <tt><font FACE="Courier">EOLE</font></tt> 
    (embedded OLE object), and <tt><font FACE="Courier">SOLE</font></tt> (static OLE object). </td>
  </tr>
  <tr>
    <td WIDTH="127">Fetch</td>
    <td WIDTH="232"><tt><font FACE="Courier">FetchMsgType</font></tt> </td>
    <td WIDTH="232">Contains the type of message to look for when executing the <tt><font
    FACE="Courier">Fetch</font></tt> method. Not commonly used by current products. </td>
  </tr>
  <tr>
    <td WIDTH="127"> </td>
    <td WIDTH="232"><tt><font FACE="Courier">FetchSorted</font></tt> </td>
    <td WIDTH="232">Controls sort order when building message collection. Set to <tt><font
    FACE="Courier">True</font></tt> for First In, First Out sort order. Set to <tt><font
    FACE="Courier">False</font></tt> to sort by user's <tt><font FACE="Courier">InBox</font></tt> 
    setting. The default is <tt><font FACE="Courier">False</font></tt>. </td>
  </tr>
  <tr>
    <td WIDTH="127"> </td>
    <td WIDTH="232"><tt><font FACE="Courier">FetchUnreadOnly</font></tt> </td>
    <td WIDTH="232">Set to <tt><font FACE="Courier">True</font></tt> to get only the unread 
    messages into the user's collection. If <tt><font FACE="Courier">False</font></tt>, all 
    messages for the user's ID are loaded into the local set. The default is <tt><font
    FACE="Courier">True</font></tt>. </td>
  </tr>
  <tr>
    <td WIDTH="127">Message</td>
    <td WIDTH="232"><tt><font FACE="Courier">MsgConversationID</font></tt> </td>
    <td WIDTH="232">Contains internally generated ID that keeps track of all messages in a 
    related &quot;thread.&quot; You can use this value to collect all related messages into a 
    single group. </td>
  </tr>
  <tr>
    <td WIDTH="127"> </td>
    <td WIDTH="232"><tt><font FACE="Courier">MsgCount</font></tt> </td>
    <td WIDTH="232">Contains the total number of messages in the set. </td>
  </tr>
  <tr>
    <td WIDTH="127"> </td>
    <td WIDTH="232"><tt><font FACE="Courier">MsgDateReceived</font></tt> </td>
    <td WIDTH="232">Date the current message was received.</td>
  </tr>
  <tr>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -