📄 ch8.htm
字号:
8.4 shows the important <tt><font FACE="Courier">InfoStore</font></tt> object properties,
their types, and their descriptions.<br>
</p>
<p align="center"><b>Table 8.4. The <tt><font FACE="Courier">InfoStore</font></tt> object
properties.</b> </p>
<div align="center"><center>
<table BORDERCOLOR="#000000" BORDER="1" WIDTH="80%">
<tr>
<td><i>Property name</i></td>
<td WIDTH="123"><i>Type</i> </td>
<td WIDTH="330"><i>Description</i></td>
</tr>
<tr>
<td WIDTH="138"><tt><font FACE="Courier">Application</font></tt> </td>
<td WIDTH="123">String</td>
<td WIDTH="330">Name of the library. Always set to <tt><font FACE="Courier">OLE/Messaging</font></tt>.
</td>
</tr>
<tr>
<td WIDTH="138"><tt><font FACE="Courier">Class</font></tt></td>
<td WIDTH="123">Long</td>
<td WIDTH="330">Internal identifying code for all MAPI objects. Always set to <tt><font
FACE="Courier">1</font></tt> for <tt><font FACE="Courier">InfoStore</font></tt> objects. </td>
</tr>
<tr>
<td WIDTH="138"><tt><font FACE="Courier">ID</font></tt></td>
<td WIDTH="123">String</td>
<td WIDTH="330">A unique value that never changes. It is assigned by MAPI when the store
is created. </td>
</tr>
<tr>
<td WIDTH="138"><tt><font FACE="Courier">Index</font></tt></td>
<td WIDTH="123">Long</td>
<td WIDTH="330">The count position of the <tt><font FACE="Courier">InfoStore</font></tt>
in the <tt><font FACE="Courier">InfoStores</font></tt> collection. This can be used with
the <tt><font FACE="Courier">Item</font></tt> property of the <tt><font FACE="Courier">InfoStores</font></tt>
object. </td>
</tr>
<tr>
<td WIDTH="138"><tt><font FACE="Courier">Name</font></tt></td>
<td WIDTH="123">String</td>
<td WIDTH="330">The display name of the message store. </td>
</tr>
<tr>
<td WIDTH="138"><tt><font FACE="Courier">ProviderName</font></tt> </td>
<td WIDTH="123">String</td>
<td WIDTH="330">The name of the message store vendor or programmer. </td>
</tr>
<tr>
<td WIDTH="138"><tt><font FACE="Courier">RootFolder</font></tt> </td>
<td WIDTH="123"><tt><font FACE="Courier">Folder</font></tt> object </td>
<td WIDTH="330">The starting folder of the message store.</td>
</tr>
</table>
</center></div>
<p>Now add some code to view the properties of an <tt><font FACE="Courier">InfoStore</font></tt>
object. First, add another command button to the control array and set its caption to <tt><font
FACE="Courier">InfoStore</font></tt>. Then modify the <tt><font FACE="Courier">Command1_Click</font></tt>
routine so that it matches the one in Listing 8.13. </p>
<hr>
<blockquote>
<b><p>Listing 8.13. Updated <tt><font FACE="Courier">Command1_Click</font></tt> event.<br>
</b></p>
</blockquote>
<blockquote>
<tt><font FACE="Courier"><p>Private Sub Command1_Click(Index As Integer) <br>
'<br>
' handle user selections<br>
'<br>
Select Case Index<br>
Case 0 ' mapi start<br>
MAPIStart <br>
Case 1 ' mapi end<br>
MAPIEnd <br>
Case 2 ' call address book<br>
MAPIAddrBook <br>
Case 3 ' session properties<br>
SessionProps <br>
Case 4 ' show infostores collection<br>
SessionInfoStoreColl
<br>
Case 5 ' show infostore properties<br>
InfoStoreProps <br>
End Select<br>
'<br>
End Sub<br>
</font></tt></p>
</blockquote>
<p>Now add the <tt><font FACE="Courier">InfoStoreProps</font></tt> subroutine and enter
the code shown in Listing 8.14. </p>
<hr>
<blockquote>
<b><p>Listing 8.14. Adding the <tt><font FACE="Courier">InfoStoreProps</font></tt>
routine.<br>
</b></p>
</blockquote>
<blockquote>
<tt><font FACE="Courier"><p>Public Sub InfoStoreProps()<br>
'<br>
' show the infostore object properties <br>
'<br>
Dim cMsg As String<br>
'<br>
Set objInfoStoreColl = objSession.InfoStores <br>
For Each objInfoStore In objInfoStoreColl <br>
cMsg = "Application: " &
objInfoStore.Application & Chr(13)<br>
cMsg = cMsg & "Class: "
& CStr(objInfoStore.Class) & Chr(13) <br>
cMsg = cMsg & "ID: " &
objInfoStore.ID & Chr(13)<br>
cMsg = cMsg & "Name: " &
objInfoStore.Name & Chr(13)<br>
cMsg = cMsg & "ProviderName:
" & objInfoStore.ProviderName & Chr(13)<br>
cMsg = cMsg & "RootFolder: "
& objInfoStore.RootFolder.Name<br>
'<br>
MsgBox cMsg, vbInformation,
"InfoStore Object Properties"<br>
Next<br>
'<br>
End Sub</font></tt> </p>
</blockquote>
<hr>
<p>Note that the <tt><font FACE="Courier">InfoStore</font></tt> object is part of what is
called a <i>small</i> <i>collection</i>. OLE object collections that are considered to
have a limited number of members are called <i>small collections</i>. All small collection
objects have an <tt><font FACE="Courier">Index</font></tt> property and a <tt><font
FACE="Courier">Count</font></tt> property. Most of them also have an <tt><font
FACE="Courier">Item</font></tt> property. Small collection objects support the use of the <tt><font
FACE="Courier">For Each...Next</font></tt> programming construct. </p>
<p>Save and run the project. After clicking the <tt><font FACE="Courier">InfoStore</font></tt>
button, you should see a series of dialog boxes showing the properties of each message
store available to your client (see Figure 8.5). </p>
<p><a HREF="f8-5.gif"><b>Figure 8.5 : </b><i>Viewing the InfoStore properties.</i></a> </p>
<p>The next object to review is the <tt><font FACE="Courier">Folder</font></tt> object and
the <tt><font FACE="Courier">Folders</font></tt> collection object. </p>
<h2><b><a NAME="TheFolderObjectsandCollections"><font SIZE="5" COLOR="#FF0000">The </font><tt><font
SIZE="5" COLOR="#FF0000" FACE="Courier">Folder</font></tt><font SIZE="5" COLOR="#FF0000">
Objects and Collections</font></a></b></h2>
<p>One of the first level objects below the <tt><font FACE="Courier">InfoStore</font></tt>
object is the <tt><font FACE="Courier">Folder</font></tt> object. The <tt><font
FACE="Courier">Folder</font></tt> object can hold messages and other folders. Each <tt><font
FACE="Courier">InfoStore</font></tt> object also has a <tt><font FACE="Courier">Folders</font></tt>
collection object that contains a list of all the <tt><font FACE="Courier">Folder</font></tt>
objects in the message store. </p>
<p>There is no limit to the number of messages or folders a <tt><font FACE="Courier">Folder</font></tt>
object can have. For this reason it is called a <tt><font FACE="Courier">large collection</font></tt>
object. <tt><font FACE="Courier">large collection</font></tt> objects do not have an <tt><font
FACE="Courier">Index</font></tt> property or a <tt><font FACE="Courier">Count</font></tt>
property. The only way you can locate all the folders in a message store is to "walk
through" the store using a set of methods to get each item. All <tt><font
FACE="Courier">large collection</font></tt> objects support the use of the <tt><font
FACE="Courier">GetFirst</font></tt>, <tt><font FACE="Courier">GetNext</font></tt>, <tt><font
FACE="Courier">GetPrevious</font></tt>, and <tt><font FACE="Courier">GetLast</font></tt>
methods to provide a way to navigate through the collection. You'll use these methods in
the next few examples. </p>
<h3><b><a NAME="TheFoldersCollectionObject">The <tt><font SIZE="4" FACE="Courier">Folders</font></tt><font
SIZE="4"> Collection Object</font></a></b></h3>
<p>The <tt><font FACE="Courier">Folders</font></tt> collection object has only a few
properties and methods. Table 8.5 shows the important <tt><font FACE="Courier">Folders</font></tt>
collection object properties and Table 8.6 shows the <tt><font FACE="Courier">Folders</font></tt>
collection object methods.<br>
</p>
<p align="center"><b>Table 8.5. The <tt><font FACE="Courier">Folders</font></tt>
collection object properties.</b> </p>
<div align="center"><center>
<table BORDERCOLOR="#000000" BORDER="1" WIDTH="80%">
<tr>
<td><i>Property name</i></td>
<td WIDTH="61"><i>Type</i> </td>
<td WIDTH="402"><i>Description</i></td>
</tr>
<tr>
<td WIDTH="128"><tt><font FACE="Courier">Application</font></tt> </td>
<td WIDTH="61">String</td>
<td WIDTH="402">Name of the library. Always set to <tt><font FACE="Courier">OLE/Messaging</font></tt>.
</td>
</tr>
<tr>
<td WIDTH="128"><tt><font FACE="Courier">Class</font></tt></td>
<td WIDTH="61">Long</td>
<td WIDTH="402">Internal identifying code for all MAPI objects. Always set to <tt><font
FACE="Courier">18</font></tt> for <tt><font FACE="Courier">Folders</font></tt> objects. </td>
</tr>
</table>
</center></div>
<p align="center"><b>Table 8.6. The <tt><font FACE="Courier">Folders</font></tt>
collection object methods.</b> </p>
<div align="center"><center>
<table BORDERCOLOR="#000000" BORDER="1" WIDTH="80%">
<tr>
<td><i>Method name</i></td>
<td WIDTH="94"><i>Parameters</i> </td>
<td WIDTH="369"><i>Description</i></td>
</tr>
<tr>
<td WIDTH="128"><tt><font FACE="Courier">GetFirst</font></tt> </td>
<td WIDTH="94">(none)</td>
<td WIDTH="369">Points to the first <tt><font FACE="Courier">Folder</font></tt> object in
the collection. </td>
</tr>
<tr>
<td WIDTH="128"><tt><font FACE="Courier">GetLast</font></tt> </td>
<td WIDTH="94">(none)</td>
<td WIDTH="369">Points to the last <tt><font FACE="Courier">Folder</font></tt> object in
the collection. </td>
</tr>
<tr>
<td WIDTH="128"><tt><font FACE="Courier">GetNext</font></tt> </td>
<td WIDTH="94">(none)</td>
<td WIDTH="369">Points to the next <tt><font FACE="Courier">Folder</font></tt> object in
the collection. </td>
</tr>
<tr>
<td WIDTH="128"><tt><font FACE="Courier">GetPrevious</font></tt> </td>
<td WIDTH="94">(none)</td>
<td WIDTH="369">Points to the previous <tt><font FACE="Courier">Folder</font></tt> object
in the collection. </td>
</tr>
</table>
</center></div>
<p>To test the <tt><font FACE="Courier">Folders</font></tt> object, add two new variables
to the general declaration area of the form. Your form-level variable list should now look
like this: </p>
<blockquote>
<tt><font FACE="Courier"><p>Option Explicit<br>
'<br>
Dim objSession As Object ' for mapi session<br>
Dim objInfoStoreColl As Object ' collection of stores<br>
Dim objInfoStore As Object ' single info store<br>
Dim objFolderColl As Object ' collection of folders<br>
Dim objFolder As Object ' single folder</font></tt> </p>
</blockquote>
<p>Now add another command button to the control array and set its <tt><font
FACE="Courier">Caption</font></tt> property to <tt><font FACE="Courier">FolderColl</font></tt>.
Then modify the <tt><font FACE="Courier">Command1_Click</font></tt> event so that it
matches the code in Listing 8.15. </p>
<hr>
<blockquote>
<b><p>Listing 8.15. Updated <tt><font FACE="Courier">Command1_Click</font></tt> event.<br>
</b></p>
</blockquote>
<blockquote>
<tt><font FACE="Courier"><p>Private Sub Command1_Click(Index As Integer) <br>
'<br>
' handle user selections<br>
'<br>
Select Case Index<br>
Case 0 ' mapi start<br>
MAPIStart <br>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -