📄 ch10.htm
字号:
' set user-supplied info<br>
.Subject = cSubject <br>
.Text = cBody <br>
'<br>
' set stock properties <br>
.Type = "IPM.Discuss" <br>
.ConversationTopic = cTopic<br>
.ConversationIndex = MakeTimeStamp<br>
.TimeSent = Now() <br>
.TimeReceived = .TimeSent<br>
.Submitted = True <br>
.Unread = True <br>
.Sent = True<br>
'<br>
.Update ' force msg into the folder<br>
End With<br>
'<br>
objFolder.Update ' update the folder object <br>
'<br>
End Sub</font></tt> </p>
</blockquote>
<hr>
<p>There are quite a few things going on in this routine. First, it locates the folder and
message store where the message will be posted. Then a new message object is created,
populated with the appropriate values, and posted (using the <tt><font FACE="Courier">Update</font></tt>
method) to the target folder. </p>
<p>The <tt><font FACE="Courier">OLEMAPIReplyMsg</font></tt> is quite similar, but this
method carries information forward from the source message to make sure that the
conversation thread is maintained. Add the code from Listing 10.13 to your project. </p>
<hr>
<blockquote>
<b><p>Listing 10.13. Adding the <tt><font FACE="Courier">OLEMAPIReplyMsg</font></tt>
routine.<br>
</b></p>
</blockquote>
<blockquote>
<tt><font FACE="Courier"><p>Public Sub OLEMAPIReply(FolderName As String, iCount As
Integer, cSubject As <font FACE="ZAPFDINGBATS">Â</font>String, cBody As String)<br>
'<br>
' post a message reply (continues existing thread)<br>
'<br>
' -----------------<br>
' Inputs:<br>
' FolderName - string name of target
folder<br>
' iCount -
index into msg array (points to source msg)<br>
' cSubject - user's
subject line (if null uses "RE:" & source subject)<br>
' cBody -
user's msg body<br>
' -----------------<br>
'<br>
Dim cIndex As String<br>
Dim uMsg As MsgType<br>
Dim uFolder As FolderType<br>
Dim objSourceMsg As Object<br>
'<br>
' check msg pointer<br>
If iCount < 0 Then<br>
MsgBox "No Message Selected",
vbExclamation, "OLEMAPIReply" <br>
Exit Sub<br>
End If<br>
'<br>
' get folder for posting<br>
uFolder = GetFolderRec(FolderName)<br>
If uFolder.FolderID = "" Then <br>
MsgBox "Unable to locate
folder!", vbExclamation, FolderName<br>
Exit Sub<br>
End If<br>
'<br>
' get source message<br>
cIndex = MsgIndex(frmMsgs.list1, iCount) <br>
uMsg = MsgPtr(cIndex)<br>
Set objSourceMsg = objSession.GetMessage(uMsg.MsgID,
uFolder.StoreID)<br>
If objSourceMsg Is Nothing Then<br>
MsgBox "Unable to Load selected
Message!", vbExclamation, uMsg.Subject<br>
Exit Sub<br>
End If<br>
'<br>
' open target store, folder<br>
Set objFolder = objSession.GetFolder(uFolder.FolderID,
uFolder.StoreID)<br>
If objFolder Is Nothing Then<br>
MsgBox "Unable to open target
folder", vbExclamation, uFolder.Name<br>
Exit Sub<br>
End If<br>
'<br>
' create a new blank message object<br>
Set objMsg = objFolder.Messages.Add<br>
If objMsg Is Nothing Then<br>
MsgBox "Unable to add message to
folder", vbExclamation, objFolder.Name <br>
Exit Sub<br>
End If<br>
'<br>
' fix up target subject, if needed<br>
If cSubject = "" Then<br>
cSubject = "RE: " &
objSourceMsg.Subject<br>
End If<br>
'<br>
' now compose reply msg<br>
With objMsg<br>
'<br>
' user properties <br>
.Subject = cSubject <br>
.Text = cBody <br>
'<br>
' stock properties <br>
.Type = "IPM.Discuss" <br>
.ConversationTopic =
objSourceMsg.ConversationTopic<br>
.ConversationIndex =
objSourceMsg.ConversationIndex & MakeTimeStamp<br>
.TimeSent = Now() <br>
.TimeReceived = .TimeSent<br>
.Submitted = True <br>
.Unread = True <br>
.Sent = True<br>
'<br>
.Update ' force msg into folder<br>
End With<br>
'<br>
objFolder.Update ' update folder object <br>
'<br>
End Sub</font></tt> </p>
</blockquote>
<hr>
<p>That's all there is to this module. Save the module (<tt><font FACE="Courier">MAPIPOST.BAS</font></tt>)
and the project (<tt><font FACE="Courier">DISCUSS.VBP</font></tt>) before moving on to the
next section. </p>
<h2><a NAME="TheDiscussandMsgsForms"><b><font SIZE="5" COLOR="#FF0000">The Discuss and
Msgs Forms</font></b></a></h2>
<p>The two main forms for the Discuss project are the MDI Discuss form and the Msgs form.
The MDI form presents a button array and hosts all the other forms. The Msgs form is used
to display the threaded discussion list. </p>
<p>You'll also need to add a few values to a short BAS module. These are project-level
values that are used throughout the project. Add a BAS module, set its <tt><font
FACE="Courier">Name</font></tt> property to <tt><font FACE="Courier">ModDiscuss</font></tt>
and save it as <tt><font FACE="Courier">MODDISCUSS.BAS</font></tt>. Now add the code shown
in Listing 10.14 to the general declaration section of the form. </p>
<hr>
<blockquote>
<b><p>Listing 10.14. Adding project-level declarations.<br>
</b></p>
</blockquote>
<blockquote>
<tt><font FACE="Courier"><p>Option Explicit<br>
<br>
'<br>
' constants<br>
Public Const dscRead = 0<br>
Public Const dscNewPost = 1<br>
Public Const dscReply = 2<br>
<br>
'<br>
' variables<br>
Public cGroup As String<br>
Public cProfile As String<br>
Public bThreaded As Boolean</font></tt> </p>
</blockquote>
<hr>
<p>That's all you need to add to this form. Save it (<tt><font FACE="Courier">MODDISCUSS.BAS</font></tt>)
and close it now. </p>
<h3><a NAME="LayingOuttheDiscussForm"><b>Laying Out the Discuss Form</b></a></h3>
<p>The Discuss form is the MDI form that controls the entire project. Refer to Figure 10.3
and Table 10.2 when laying out the Discuss form. </p>
<p><a HREF="f10-3.gif"><b>Figure 10.3 : </b><i>Laying out the Discuss form.</i></a> <br>
</p>
<p align="center"><b>Table 10.2. Controls for the Discuss form.</b> </p>
<div align="center"><center>
<table BORDERCOLOR="#000000" BORDER="1" WIDTH="80%">
<tr>
<td><i>Control</i></td>
<td WIDTH="138"><i>Property</i> </td>
<td WIDTH="177"><i>Setting</i></td>
</tr>
<tr>
<td WIDTH="176"><tt><font FACE="Courier">VB.MDIForm</font></tt> </td>
<td WIDTH="138"><tt><font FACE="Courier">Name</font></tt></td>
<td WIDTH="177">mdiDiscuss</td>
</tr>
<tr>
<td WIDTH="176"> </td>
<td WIDTH="138"><tt><font FACE="Courier">BackColor</font></tt> </td>
<td WIDTH="177">&H8000000C&</td>
</tr>
<tr>
<td WIDTH="176"> </td>
<td WIDTH="138"><tt><font FACE="Courier">Caption</font></tt> </td>
<td WIDTH="177">"Discuss"</td>
</tr>
<tr>
<td WIDTH="176"> </td>
<td WIDTH="138"><tt><font FACE="Courier">ClientHeight</font></tt> </td>
<td WIDTH="177">5685</td>
</tr>
<tr>
<td WIDTH="176"> </td>
<td WIDTH="138"><tt><font FACE="Courier">ClientLeft</font></tt> </td>
<td WIDTH="177">735</td>
</tr>
<tr>
<td WIDTH="176"> </td>
<td WIDTH="138"><tt><font FACE="Courier">ClientTop</font></tt> </td>
<td WIDTH="177">1710</td>
</tr>
<tr>
<td WIDTH="176"> </td>
<td WIDTH="138"><tt><font FACE="Courier">ClientWidth</font></tt> </td>
<td WIDTH="177">9210</td>
</tr>
<tr>
<td WIDTH="176"> </td>
<td WIDTH="138"><tt><font FACE="Courier">Height</font></tt> </td>
<td WIDTH="177">6090</td>
</tr>
<tr>
<td WIDTH="176"> </td>
<td WIDTH="138"><tt><font FACE="Courier">Left</font></tt> </td>
<td WIDTH="177">675</td>
</tr>
<tr>
<td WIDTH="176"> </td>
<td WIDTH="138"><tt><font FACE="Courier">LinkTopic</font></tt> </td>
<td WIDTH="177">"MDIForm1"</td>
</tr>
<tr>
<td WIDTH="176"> </td>
<td WIDTH="138"><tt><font FACE="Courier">Top</font></tt> </td>
<td WIDTH="177">1365</td>
</tr>
<tr>
<td WIDTH="176"> </td>
<td WIDTH="138"><tt><font FACE="Courier">Width</font></tt> </td>
<td WIDTH="177">9330</td>
</tr>
<tr>
<td WIDTH="176"> </td>
<td WIDTH="138"><tt><font FACE="Courier">WindowState</font></tt> </td>
<td WIDTH="177">2 'Maximized</td>
</tr>
<tr>
<td WIDTH="176"><tt><font FACE="Courier">VB.PictureBox</font></tt> </td>
<td WIDTH="138"><tt><font FACE="Courier">Name</font></tt></td>
<td WIDTH="177">Picture2</td>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -