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

📄 ch6.htm

📁 MAPI__SAPI__TAPI
💻 HTM
📖 第 1 页 / 共 5 页
字号:
    <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=&amp;H1</font></tt> (display logon dialog)<br>
    <tt><font FACE="Courier">MAPI_NEW_SESSION=&amp;H2</font></tt> (start new session)<br>
    <tt><font FACE="Courier">MAPI_DIALOG=&amp;H8</font></tt> (show resolve dialog)<br>
    <tt><font FACE="Courier">MAPI_AB_NOMODIFY=&amp;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>
  &nbsp;&nbsp;&nbsp;&nbsp;'<br>
  &nbsp;&nbsp;&nbsp;&nbsp;' handle button press<br>
  &nbsp;&nbsp;&nbsp;&nbsp;'<br>
  &nbsp;&nbsp;&nbsp;&nbsp;Select Case Index<br>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Case 0 ' log on session<br>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SMAPIStart <br>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Case 1 ' log off session<br>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SMAPIEnd <br>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Case 2 ' addressbook <br>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AddressBook <br>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Case 3 ' resolve name<br>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ResolveName <br>
  &nbsp;&nbsp;&nbsp;&nbsp;End Select<br>
  &nbsp;&nbsp;&nbsp;&nbsp;'<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>
  &nbsp;&nbsp;&nbsp;&nbsp;'<br>
  &nbsp;&nbsp;&nbsp;&nbsp;'&nbsp;test resolvename service<br>
  &nbsp;&nbsp;&nbsp;&nbsp;'<br>
  &nbsp;&nbsp;&nbsp;&nbsp;lReturn = MAPIResolveName(lSession, Me.hWnd, &quot;MCA&quot;, 
  MAPI_DIALOG, 0, udtRecip)<br>
  &nbsp;&nbsp;&nbsp;&nbsp;If lReturn &lt;&gt; SUccESS_SUccESS Then <br>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MsgBox MAPIErr(lReturn) <br>
  &nbsp;&nbsp;&nbsp;&nbsp;End If<br>
  &nbsp;&nbsp;&nbsp;&nbsp;'<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=&amp;H1</font></tt> (force log on)<br>
    <tt><font FACE="Courier">MAPI_NEW_SESSION=&amp;H2</font></tt> (force new session)<br>
    <tt><font FACE="Courier">MAPI_AB_NOMODIFY=&amp;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>
  &nbsp;&nbsp;&nbsp;&nbsp;'<br>
  &nbsp;&nbsp;&nbsp;&nbsp;'&nbsp;handle button press<br>
  &nbsp;&nbsp;&nbsp;&nbsp;'<br>
  &nbsp;&nbsp;&nbsp;&nbsp;Select Case Index<br>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Case 0 ' log on session<br>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SMAPIStart <br>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Case 1 ' log off session<br>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SMAPIEnd <br>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Case 2 ' addressbook <br>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AddressBook <br>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Case 3 ' resolve name<br>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ResolveName <br>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Case 4 ' addr details<br>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AddrDetails <br>
  &nbsp;&nbsp;&nbsp;&nbsp;End Select<br>
  &nbsp;&nbsp;&nbsp;&nbsp;'<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>
  &nbsp;&nbsp;&nbsp;&nbsp;'<br>
  &nbsp;&nbsp;&nbsp;&nbsp;' show the details of a valid address <br>
  &nbsp;&nbsp;&nbsp;&nbsp;'<br>
  &nbsp;&nbsp;&nbsp;&nbsp;lReturn = MAPIResolveName(lSession, Me.hWnd, &quot;MCA/Win&quot;, 
  0, 0, udtRecip)<br>
  &nbsp;&nbsp;&nbsp;&nbsp;If lReturn &lt;&gt; SUccESS_SUccESS Then <br>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MsgBox MAPIErr(lReturn) <br>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Exit Sub<br>
  &nbsp;&nbsp;&nbsp;&nbsp;End If<br>
  &nbsp;&nbsp;&nbsp;&nbsp;'<br>
  &nbsp;&nbsp;&nbsp;&nbsp;lReturn = MAPIDetails(lSession, Me.hWnd, udtRecip, MAPI_LOGON_UI, 
  0)<br>
  &nbsp;&nbsp;&nbsp;&nbsp;If lReturn &lt;&gt; SUccESS_SUccESS Then <br>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MsgBox MAPIErr(lReturn) <br>
  &nbsp;&nbsp;&nbsp;&nbsp;End If<br>
  &nbsp;&nbsp;&nbsp;&nbsp;'<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 + -