📄 ch6.htm
字号:
<td WIDTH="391">A string containing the name to be resolved. </td>
</tr>
<tr>
<td WIDTH="109"><tt><font FACE="Courier">Flags</font></tt></td>
<td WIDTH="90">Long</td>
<td WIDTH="391">A bitmask of flags. The following flags are defined: <br>
<tt><font FACE="Courier">MAPI_LOGON_UI=&H1</font></tt> (display logon dialog)<br>
<tt><font FACE="Courier">MAPI_NEW_SESSION=&H2</font></tt> (start new session)<br>
<tt><font FACE="Courier">MAPI_DIALOG=&H8</font></tt> (show resolve dialog)<br>
<tt><font FACE="Courier">MAPI_AB_NOMODIFY=&H400</font></tt> (no modify address book) </td>
</tr>
<tr>
<td WIDTH="109"><tt><font FACE="Courier">Reserved</font></tt> </td>
<td WIDTH="90">Long</td>
<td WIDTH="391">Reserved for future use. This parameter must be 0. </td>
</tr>
<tr>
<td WIDTH="109"><tt><font FACE="Courier">Recipient</font></tt> </td>
<td WIDTH="90">MapiRecip</td>
<td WIDTH="391">A recipient type set by <tt><font FACE="Courier">MAPIResolveName</font></tt>
if the resolution results in a single match. The type contains the recipient information
of the resolved name. The descriptor can then be used in calls to <tt><font FACE="Courier">MAPISendMail</font></tt>,
<tt><font FACE="Courier">MAPISaveMail</font></tt>, and <tt><font FACE="Courier">MAPIAddress</font></tt>.
</td>
</tr>
</table>
</center></div>
<p>To test <tt><font FACE="Courier">MAPIResolve</font></tt>, add a new button to the
control array and set its caption to <tt><font FACE="Courier">ResolveName</font></tt>.
Then modify the <tt><font FACE="Courier">Command1_Click</font></tt> event to match the one
in Listing 6.12. </p>
<hr>
<blockquote>
<b><p>Listing 6.12. Modifying the <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 button press<br>
'<br>
Select Case Index<br>
Case 0 ' log on session<br>
SMAPIStart <br>
Case 1 ' log off session<br>
SMAPIEnd <br>
Case 2 ' addressbook <br>
AddressBook <br>
Case 3 ' resolve name<br>
ResolveName <br>
End Select<br>
'<br>
End Sub</font></tt> </p>
</blockquote>
<hr>
<p>Now add the new <tt><font FACE="Courier">ResolveName</font></tt> subroutine and enter
the code in Listing 6.13. </p>
<hr>
<blockquote>
<b><p>Listing 6.13. Adding the <tt><font FACE="Courier">ResolveName</font></tt> routine.<br>
</b></p>
</blockquote>
<blockquote>
<tt><font FACE="Courier"><p>Public Sub ResolveName()<br>
'<br>
' test resolvename service<br>
'<br>
lReturn = MAPIResolveName(lSession, Me.hWnd, "MCA",
MAPI_DIALOG, 0, udtRecip)<br>
If lReturn <> SUccESS_SUccESS Then <br>
MsgBox MAPIErr(lReturn) <br>
End If<br>
'<br>
End Sub</font></tt> </p>
</blockquote>
<hr>
<p>If you run this routine and supply an ambiguous name, MAPI returns a dialog box asking
you to resolve the differences (see Figure 6.3). </p>
<p><a HREF="f6-3.gif"><b>Figure 6.3 : </b><i>Viewing the ResolveName dialog box.</i></a> </p>
<p>You can avoid viewing the dialog box (and just trap any error) by setting the <tt><font
FACE="Courier">Flag</font></tt> value to 0. </p>
<h4><tt><font FACE="Courier">MAPIDetails</font></tt></h4>
<p>The <tt><font FACE="Courier">MAPIDetails</font></tt> function returns a special dialog
box that allows users to inspect and edit information about a single recipient. You can
use this in your programs to give users direct access to an address entry edit form. Table
6.8 shows the <tt><font FACE="Courier">MAPIDetails</font></tt> parameter list.<br>
</p>
<p align="center"><b>Table 6.8. The <tt><font FACE="Courier">MAPIDetails</font></tt>
parameters.</b> </p>
<div align="center"><center>
<table BORDERCOLOR="#000000" BORDER="1" WIDTH="80%">
<tr>
<td><i>Parameter</i></td>
<td WIDTH="120"><i>Type</i> </td>
<td WIDTH="361"><i>Description</i></td>
</tr>
<tr>
<td WIDTH="109"><tt><font FACE="Courier">Session</font></tt> </td>
<td WIDTH="120">Long</td>
<td WIDTH="361">A unique session handle whose value represents a session with the
messaging subsystem. Session handles are returned by <tt><font FACE="Courier">MAPILogon</font></tt>
and invalidated by <tt><font FACE="Courier">MAPILogoff</font></tt>. If the value is 0,
MAPI sets up a session from a system default session (if one exists) or by presenting a
sign-in dialog box. </td>
</tr>
<tr>
<td WIDTH="109"><tt><font FACE="Courier">UIParam</font></tt> </td>
<td WIDTH="120">Long</td>
<td WIDTH="361">The parent window handle for the dialog box. A value of 0 specifies that
any dialog box displayed is application modal. </td>
</tr>
<tr>
<td WIDTH="109"><tt><font FACE="Courier">Recipient</font></tt> </td>
<td WIDTH="120">MAPIRecip</td>
<td WIDTH="361">A recipient descriptor containing the entry whose details are to be
displayed. All fields of the <tt><font FACE="Courier">MapiRecip</font></tt> type except <tt><font
FACE="Courier">EIDSize</font></tt> and <tt><font FACE="Courier">EntryID</font></tt> are
ignored. If the field <tt><font FACE="Courier">EIDSize</font></tt> is zero, <tt><font
FACE="Courier">MAPI_E_AMBIG_RECIP</font></tt> is returned. </td>
</tr>
<tr>
<td WIDTH="109"><tt><font FACE="Courier">Flags</font></tt></td>
<td WIDTH="120">Long</td>
<td WIDTH="361">A bitmask of flags. Unspecified flags should always be passed as 0.
Undocumented flags are reserved. The following flags are defined: <br>
<tt><font FACE="Courier">MAPI_LOGON_UI=&H1</font></tt> (force log on)<br>
<tt><font FACE="Courier">MAPI_NEW_SESSION=&H2</font></tt> (force new session)<br>
<tt><font FACE="Courier">MAPI_AB_NOMODIFY=&H400</font></tt> (no <tt><font
FACE="Courier">addrbook</font></tt> changes) </td>
</tr>
<tr>
<td WIDTH="109"><tt><font FACE="Courier">Reserved</font></tt> </td>
<td WIDTH="120">Long</td>
<td WIDTH="361">Reserved for future use. This parameter must be 0. </td>
</tr>
</table>
</center></div>
<p>Add a new button to the control array and set its caption to <tt><font FACE="Courier">MAPIDetails</font></tt>.
Then modify the <tt><font FACE="Courier">Command1_Click</font></tt> event to match the
code in Listing 6.14. </p>
<hr>
<blockquote>
<b><p>Listing 6.14. Modifying the <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 button press<br>
'<br>
Select Case Index<br>
Case 0 ' log on session<br>
SMAPIStart <br>
Case 1 ' log off session<br>
SMAPIEnd <br>
Case 2 ' addressbook <br>
AddressBook <br>
Case 3 ' resolve name<br>
ResolveName <br>
Case 4 ' addr details<br>
AddrDetails <br>
End Select<br>
'<br>
End Sub</font></tt> </p>
</blockquote>
<hr>
<p>Now add the <tt><font FACE="Courier">AddrDetails</font></tt> subroutine and fill it in
with the code from Listing 6.15. </p>
<hr>
<blockquote>
<b><p>Listing 6.15. Adding the <tt><font FACE="Courier">AddrDetails</font></tt> routine.<br>
</b></p>
</blockquote>
<blockquote>
<tt><font FACE="Courier"><p>Public Sub AddrDetails()<br>
'<br>
' show the details of a valid address <br>
'<br>
lReturn = MAPIResolveName(lSession, Me.hWnd, "MCA/Win",
0, 0, udtRecip)<br>
If lReturn <> SUccESS_SUccESS Then <br>
MsgBox MAPIErr(lReturn) <br>
Exit Sub<br>
End If<br>
'<br>
lReturn = MAPIDetails(lSession, Me.hWnd, udtRecip, MAPI_LOGON_UI,
0)<br>
If lReturn <> SUccESS_SUccESS Then <br>
MsgBox MAPIErr(lReturn) <br>
End If<br>
'<br>
End Sub</font></tt> </p>
</blockquote>
<hr>
<p>When you save and run the project, you will see an address entry dialog box appear when
you press the <tt><font FACE="Courier">AddrDetails</font></tt> button (see Figure 6.4). </p>
<p><a HREF="f6-4.gif"><b>Figure 6.4 : </b><i>Viewing the Address Book Details dialog box.</i></a>
</p>
<h4><tt><font FACE="Courier">MAPISendDocuments</font></tt></h4>
<p>The <tt><font FACE="Courier">MAPISendDocuments</font></tt> function is unique. You do
not need to log in to MAPI before you call this function. As an option, you can fill
simple test strings with information for attachments and pass them in the call, too. When
the call is used, it brings up a full-featured compose dialog box that you can use to
create and send an e-mail message. Table 6.9 shows the parameters for <tt><font
FACE="Courier">MAPISendDocuments</font></tt>. <br>
</p>
<p align="center"><b>Table 6.9. The <tt><font FACE="Courier">MAPISendDocuments</font></tt>
parameters.</b> </p>
<div align="center"><center>
<table BORDERCOLOR="#000000" BORDER="1" WIDTH="80%">
<tr>
<td><i>Parameter</i></td>
<td WIDTH="61"><i>Type</i> </td>
<td WIDTH="421"><i>Description</i></td>
</tr>
<tr>
<td WIDTH="109"><tt><font FACE="Courier">UIParam</font></tt> </td>
<td WIDTH="61">Long</td>
<td WIDTH="421">The parent window handle for the dialog box. A value of 0 specifies that
the Send Note dialog box is application modal. </td>
</tr>
<tr>
<td WIDTH="109"><tt><font FACE="Courier">DelimChar</font></tt> </td>
<td WIDTH="61">String</td>
<td WIDTH="421">A string containing the character used to delimit the names in the <tt><font
FACE="Courier">FilePaths</font></tt> and <tt><font FACE="Courier">FileNames</font></tt>
parameters. This character should not be used in filenames on your operating system. </td>
</tr>
<tr>
<td WIDTH="109"><tt><font FACE="Courier">FilePaths</font></tt> </td>
<td WIDTH="61">String</td>
<td WIDTH="421">A string containing the list of full paths (including drive letters) for
the attached files. The list is formed by concatenating correctly formed file paths
separated by the character specified in the <tt><font FACE="Courier">DelimChar</font></tt>
parameter. The files specified in this parameter are added to the message as file
attachments. </td>
</tr>
<tr>
<td WIDTH="109"><tt><font FACE="Courier">FileNames</font></tt> </td>
<td WIDTH="61">String</td>
<td WIDTH="421">A string containing the list of the original filenames (in 8.3 format) as
they should be displayed in the message. When multiple names are specified, the list is
formed by concatenating the filenames separated by the character specified in the <tt><font
FACE="Courier">DelimChar</font></tt> parameter. </td>
</tr>
<tr>
<td WIDTH="109"><tt><font FACE="Courier">Reserved</font></tt> </td>
<td WIDTH="61">Long</td>
<td WIDTH="421">Reserved for future use. This parameter must be 0. </td>
</tr>
</table>
</center></div>
<p>Add another button to the control array and set its caption to <tt><font FACE="Courier">SendDocs</font></tt>.
Make sure your <tt><font FACE="Courier">Command1_Click</font></t
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -