home *** CD-ROM | disk | FTP | other *** search
/ On Hand / On_Hand_From_Softbank_1994_Release_2_Disc_2_1994.iso / 00202 / s / disk3 / mailsup.ba_ / mailsup.bin
Text File  |  1993-04-28  |  22KB  |  585 lines

  1. Global Const MAPI_ORIG = 0            '// Recipient is message originator
  2. Global Const MAPI_TO = 1              '// Recipient is a primary recipient
  3. Global Const MAPI_CC = 2              '// Recipient is a copy recipient
  4. Global Const MAPI_BCC = 3             '// Recipient is blind copy recipient
  5. Global Const MAIL_LONGDATE = 0
  6. Global Const MAIL_LISTVIEW = 1
  7.  
  8. Global Const Option_General = 1       '// Constant for Option Dialog Type - General Options
  9. Global Const Option_Messaage = 2      '// Constant for Option Dialog Type - Message Options
  10.  
  11. Global Const MAPI_ATT_File = 0        'Attachment Type: data File
  12. Global Const MAPI_ATT_EOle = 1        'Attachment Type: embedded OLE Object
  13. Global Const MAPI_ATT_SOle = 2        'Attachment Type: static OLE Object
  14.  
  15. Type ListDisplay
  16.     Name As String * 20
  17.     Subject As String * 40
  18.     Date As String * 20
  19. End Type
  20. Global currentRCIndex As Integer
  21. Global UnRead As Integer
  22. Global SendWithMapi As Integer
  23. Global ReturnRequest As Integer
  24. Global OptionType As Integer
  25.  
  26. '----------------------------------------------------------------------------
  27. ' ACTION PROPERTY CONSTANTS
  28. '----------------------------------------------------------------------------
  29. Global Const MESSAGE_FETCH = 1             ' Load all messages from message store
  30. Global Const MESSAGE_SENDDLG = 2           ' Send mail bring up default mapi dialog
  31. Global Const MESSAGE_SEND = 3              ' Send mail without default mapi dialog
  32. Global Const MESSAGE_SAVEMSG = 4           ' Save message in the compose buffer
  33. Global Const MESSAGE_COPY = 5              ' Copy current message to compose buffer
  34. Global Const MESSAGE_COMPOSE = 6           ' Initialize compose buffer (previous
  35.                                     ' data is lost
  36. Global Const MESSAGE_Reply = 7             ' Fill Compose buffer as REPLY
  37. Global Const MESSAGE_ReplyAll = 8          ' Fill Compose buffer as REPLY ALL
  38. Global Const Message_Forward = 9           ' Fill Compose buffer as FORWARD
  39. Global Const MESSAGE_DELETE = 10           ' Delete current message
  40. Global Const MESSAGE_SHOWADBOOK = 11       ' Show Address book
  41. Global Const MESSAGE_SHOWDETAILS = 12      ' Show details of the current recipient
  42. Global Const MESSAGE_RESOLVENAME = 13      ' Resolve the display name of the recipient
  43. Global Const RECIPENT_DELETE = 14          ' Delete the current Reciptent
  44. '----------------------------------------------------------------------------
  45. ' Windows API Routines
  46. '----------------------------------------------------------------------------
  47. Declare Function GetProfileString% Lib "Kernel" (ByVal lpSection$, ByVal lpEntry$, ByVal lpDefault$, ByVal Buffer$, ByVal cbBuffer%)
  48.  
  49. Sub Attachments (Msg As Form)
  50. '---- Clear the current attachment list
  51.     Msg.aList.Clear
  52.  
  53. '---- If there are attachments, load them into the listbox
  54.     If VBMail.MapiMess.AttachmentCount Then
  55.         Msg.NumAtt = VBMail.MapiMess.AttachmentCount + " Files"
  56.         For i% = 0 To VBMail.MapiMess.AttachmentCount - 1
  57.             VBMail.MapiMess.AttachmentIndex = i%
  58.             a$ = VBMail.MapiMess.AttachmentName
  59.             Select Case VBMail.MapiMess.AttachmentType
  60.                 Case MAPI_ATT_File
  61.                     a$ = a$ + " (Data File)"
  62.                 Case MAPI_ATT_EOle
  63.                     a$ = a$ + " (Embedded OLE Object)"
  64.                 Case MAPI_ATT_SOle
  65.                     a$ = a$ + " (Static OLE Object)"
  66.                 Case Else
  67.                     a$ = a$ + " (Unknown attachment type)"
  68.             End Select
  69.             Msg.aList.AddItem a$
  70.         Next i%
  71.         
  72.         If Not Msg.AttachWin.Visible Then
  73.             Msg.AttachWin.Visible = True
  74.             Call SizeMessageWindow(Msg)
  75.             'If Msg.WindowState = 0 Then
  76.             '    Msg.Height = Msg.Height + Msg.AttachWin.Height
  77.             'End If
  78.         End If
  79.     
  80.     Else
  81.         If Msg.AttachWin.Visible Then
  82.             Msg.AttachWin.Visible = False
  83.             Call SizeMessageWindow(Msg)
  84.             'If Msg.WindowState = 0 Then
  85.             '    Msg.Height = Msg.Height - Msg.AttachWin.Height
  86.             'End If
  87.         End If
  88.     End If
  89.     Msg.Refresh
  90. End Sub
  91.  
  92. Sub CopyNamestoMsgBuffer (Msg As Form, fResolveNames As Integer)
  93.     Call KillRecips(VBMail.MapiMess)
  94.     Call SetRCList(Msg.txtTo, VBMail.MapiMess, MAPI_TO, fResolveNames)
  95.     Call SetRCList(Msg.txtcc, VBMail.MapiMess, MAPI_CC, fResolveNames)
  96. End Sub
  97.  
  98. Function DateFromMapiDate$ (ByVal S$, wFormat%)
  99. '----------------------------------------------------
  100. '   This routine formats a MAPI Date in one of
  101. '   two formats for use in viewing the message
  102. '----------------------------------------------------
  103.     Y$ = Left$(S$, 4)
  104.     M$ = Mid$(S$, 6, 2)
  105.     D$ = Mid$(S$, 9, 2)
  106.     T$ = Mid$(S$, 12)
  107.     Ds# = DateValue(M$ + "/" + D$ + "/" + Y$) + TimeValue(T$)
  108.     Select Case wFormat
  109.         Case MAIL_LONGDATE
  110.             f$ = "dddd, mmmm d, yyyy, h:mmAM/PM"
  111.         Case MAIL_LISTVIEW
  112.             f$ = "mm/dd/yy hh:mm"
  113.     End Select
  114.     DateFromMapiDate = Format$(Ds#, f$)
  115. End Function
  116.  
  117. Sub DeleteMessage ()
  118.   '------------------------------------------------------------------
  119.   '  If the currently active form is a message, set the MListIndex to
  120.   '  the correct value
  121.   '------------------------------------------------------------------
  122.     If TypeOf VBMail.ActiveForm Is MsgView Then
  123.         MailLst.MList.ListIndex = Val(VBMail.ActiveForm.Tag)
  124.         ViewingMsg = True
  125.     End If
  126.  
  127.    '------------------------------------------------------------------
  128.    ' Delete the mail message
  129.    '------------------------------------------------------------------
  130.     If MailLst.MList.ListIndex <> -1 Then
  131.         VBMail.MapiMess.MsgIndex = MailLst.MList.ListIndex
  132.         VBMail.MapiMess.Action = 10  'Delete Mail
  133.         x% = MailLst.MList.ListIndex
  134.         MailLst.MList.RemoveItem x%
  135.         If x% < MailLst.MList.ListCount - 1 Then
  136.             MailLst.MList.ListIndex = x%
  137.         Else
  138.             MailLst.MList.ListIndex = MailLst.MList.ListCount - 1
  139.         End If
  140.         VBMail.MsgCountLbl = Format$(VBMail.MapiMess.MsgCount) + " Messages"
  141.  
  142.      '--------------------------------------------------------------------------
  143.      ' Go through and adjust the index values for currently viewed messages
  144.      '--------------------------------------------------------------------------
  145.         If ViewingMsg Then
  146.             VBMail.ActiveForm.Tag = Str$(-1)
  147.         End If
  148.  
  149.         For i = 0 To Forms.Count - 1
  150.             If TypeOf Forms(i) Is MsgView Then
  151.                 If Val(Forms(i).Tag) > x% Then
  152.                     Forms(i).Tag = Val(Forms(i).Tag) - 1
  153.                 End If
  154.             End If
  155.         Next i
  156.      '--------------------------------------------------------------------------
  157.      ' If we were viewing a message, load the next message into the MsgView form
  158.      ' if the message isn't currently displayed...
  159.      '--------------------------------------------------------------------------
  160.         If ViewingMsg Then
  161.             '--------------------------------------------------------------
  162.             ' First Check to see if the message is currently being viewed
  163.             '--------------------------------------------------------------
  164.             WindowNum% = FindMsgWindow((MailLst.MList.ListIndex))
  165.             If WindowNum% > 0 Then
  166.                 If Forms(WindowNum%).Caption <> VBMail.ActiveForm.Caption Then
  167.                     Unload VBMail.ActiveForm
  168.                     '--- find the correct window again and show it.  Index isn't valid after the unload
  169.                      Forms(FindMsgWindow((MailLst.MList.ListIndex))).Show
  170.                 Else
  171.                      Forms(WindowNum%).Show
  172.                 End If
  173.             Else
  174.                 Call LoadMessage(MailLst.MList.ListIndex, VBMail.ActiveForm)
  175.             End If
  176.         Else
  177.             '---- Check to see if there was a window viewing the message and unload it
  178.             WindowNum% = FindMsgWindow(x%)
  179.             If WindowNum% > 0 Then
  180.                 Unload Forms(x%)
  181.             End If
  182.         End If
  183.      End If
  184. End Sub
  185.  
  186. Sub DisplayAttachedFile (ByVal FileName As String)
  187. On Error Resume Next
  188.     '----- Determine the extension
  189.         ext$ = FileName
  190.         junk$ = Token$(ext$, ".")
  191.     '----- Get the application from the WIN.INI file to run
  192.         Buffer$ = String$(256, " ")
  193.         errCode% = GetProfileString("Extensions", ext$, "NOTFOUND", Buffer$, 255)
  194.         If errCode% Then
  195.             Buffer$ = Mid$(Buffer$, 1, errCode% - 1)
  196.             If Buffer$ <> "NOTFOUND" Then
  197.                 '---- Strip off the ^.EXT information from the string
  198.                 ExeName$ = Token$(Buffer$, " ")
  199.                 errCode% = Shell(ExeName$ + " " + FileName, 1)
  200.                 If Err Then
  201.                     MsgBox "Error occured during the shell: " + Error$
  202.                 End If
  203.             Else
  204.                 MsgBox "Application that uses: <" + ext$ + "> not found in WIN.INI"
  205.             End If
  206.         End If
  207. End Sub
  208.  
  209. Function FindMsgWindow (Index As Integer) As Integer
  210. '------------------------------------------------------
  211. '  This function searchs through the active windows
  212. '  and locates those w/ the MsgView type and then
  213. '  checked to see if the tag contains the index we
  214. '  are searching for
  215. '------------------------------------------------------
  216.         For i = 0 To Forms.Count - 1
  217.             If TypeOf Forms(i) Is MsgView Then
  218.                 If Val(Forms(i).Tag) = Index Then
  219.                     FindMsgWindow = i
  220.                     Exit Function
  221.                 End If
  222.             End If
  223.         Next i
  224.         FindMsgWindow = -1
  225. End Function
  226.  
  227. Function GetHeader (Msg As Control) As String
  228. Dim CR As String
  229. CR = Chr$(13) + Chr$(10)
  230.       Header$ = String$(25, "-") + CR
  231.       Header$ = Header$ + "Form: " + Msg.MsgOrigDisplayName + CR
  232.       Header$ = Header$ + "To: " + GetRCList(Msg, MAPI_TO) + CR
  233.       Header$ = Header$ + "Cc: " + GetRCList(Msg, MAPI_CC) + CR
  234.       Header$ = Header$ + "Subject: " + Msg.MsgSubject + CR
  235.       Header$ = Header$ + "Date: " + DateFromMapiDate$(Msg.MsgDateReceived, MAIL_LONGDATE) + CR + CR
  236.       GetHeader = Header$
  237. End Function
  238.  
  239. Sub GetMessageCount ()
  240. '--------------------------------------------------
  241. '  Reads all mail messages and displays the count
  242. '--------------------------------------------------
  243.     Screen.MousePointer = 11
  244.     VBMail.MapiMess.FetchUnreadOnly = 0
  245.     VBMail.MapiMess.Action = MESSAGE_FETCH
  246.     VBMail.MsgCountLbl = Format$(VBMail.MapiMess.MsgCount) + " Messages"
  247.     Screen.MousePointer = 0
  248. End Sub
  249.  
  250. Function GetRCList (Msg As Control, RCType As Integer) As String
  251. '--------------------------------------------------
  252. '  Given a list of Recips, this function returns
  253. '  a list of Recips of the specified type in the
  254. '  following format:
  255. '
  256. '       Person 1;Person 2;Person 3
  257. '
  258. '--------------------------------------------------
  259.     For i = 0 To Msg.RecipCount - 1
  260.         Msg.RecipIndex = i
  261.         If RCType = Msg.RecipType Then
  262.                 a$ = a$ + ";" + Msg.RecipDisplayName
  263.         End If
  264.     Next i
  265.     If a$ <> "" Then
  266.        a$ = Mid$(a$, 2)  'Strip-off leading ";"
  267.     End If
  268.     GetRCList = a$
  269. End Function
  270.  
  271. Sub KillRecips (MsgControl As Control)
  272. '---- Delete each reciptent.  Loop until no more exist
  273.     While MsgControl.RecipCount
  274.         MsgControl.Action = RECIPENT_DELETE
  275.     Wend
  276. End Sub
  277.  
  278. Sub LoadList (mailctl As Control)
  279. '------------------------------------------------------
  280. '   This routines loads the mail message headers
  281. '   into the MailLst.MList.  Unread messages have
  282. '   a chr$(187) placed at the beginning of the string
  283. '------------------------------------------------------
  284.     MailLst.MList.Clear
  285.     UnRead = 0
  286.     StartIndex = 0
  287.     For i = 0 To mailctl.MsgCount - 1
  288.         mailctl.MsgIndex = i
  289.         If Not mailctl.MsgRead Then
  290.             a$ = Chr$(187) + " "
  291.             If UnRead = 0 Then
  292.                 StartIndex = i  'Position to start in the mail list
  293.             End If
  294.             UnRead = UnRead + 1
  295.         Else
  296.             a$ = "  "
  297.         End If
  298.         a$ = a$ + Mid$(Format$(mailctl.MsgOrigDisplayName, "!" + String$(10, "@")), 1, 10)
  299.         If mailctl.MsgSubject <> "" Then
  300.             b$ = Mid$(Format$(mailctl.MsgSubject, "!" + String$(35, "@")), 1, 35)
  301.         Else
  302.             b$ = String$(30, " ")
  303.         End If
  304.         C$ = Mid$(Format$(DateFromMapiDate(mailctl.MsgDateReceived, MAIL_LISTVIEW), "!" + String$(15, "@")), 1, 15)
  305.         MailLst.MList.AddItem a$ + Chr$(9) + b$ + Chr$(9) + C$
  306.         MailLst.MList.Refresh
  307.     Next i
  308.  
  309.     MailLst.MList.ListIndex = StartIndex
  310.     
  311.     '----- Enable the correct buttons
  312.     VBMail.Next.Enabled = True
  313.     VBMail.Previous.Enabled = True
  314.     VBMail![Delete].Enabled = True
  315.  
  316.     '----- Adjust the value of the labels displaying message counts
  317.     If UnRead Then
  318.         VBMail.UnreadLbl = " - " + Format$(UnRead) + " Unread"
  319.         MailLst.Icon = MailLst.NewMail.Picture
  320.     Else
  321.         VBMail.UnreadLbl = ""
  322.         MailLst.Icon = MailLst.nonew.Picture
  323.     End If
  324. End Sub
  325.     
  326.  
  327. Sub LoadMessage (ByVal Index As Integer, Msg As Form)
  328. '------------------------------------------------------
  329. '   This routine loads the specified mail message into
  330. '   a form to either view or edit a message
  331. '------------------------------------------------------
  332.     If TypeOf Msg Is MsgView Then
  333.         a$ = MailLst.MList.List(Index)
  334.         '---- Message is unread; reset the text
  335.         If Mid$(a$, 1, 1) = Chr$(187) Then
  336.             Mid$(a$, 1, 1) = " "
  337.             MailLst.MList.List(Index) = a$
  338.             UnRead = UnRead - 1
  339.             If UnRead Then
  340.                 VBMail.UnreadLbl = Format$(UnRead) + " Unread"
  341.             Else
  342.                 VBMail.UnreadLbl = ""
  343.                 '---- Change the icon on the list window
  344.                 MailLst.Icon = MailLst.nonew.Picture
  345.             End If
  346.         End If
  347.     End If
  348.  
  349.     '----- These fields only apply to viewing
  350.     If TypeOf Msg Is MsgView Then
  351.         VBMail.MapiMess.MsgIndex = Index
  352.         Msg.txtDate = DateFromMapiDate$(VBMail.MapiMess.MsgDateReceived, MAIL_LONGDATE)
  353.         Msg.txtFrom = VBMail.MapiMess.MsgOrigDisplayName
  354.         MailLst.MList.ItemData(Index) = True
  355.     End If
  356.     '----- These fields apply to both form types
  357.     Call Attachments(Msg)
  358.     Msg.txtNoteText = VBMail.MapiMess.MsgNoteText
  359.     Msg.txtsubject = VBMail.MapiMess.MsgSubject
  360.     Msg.Caption = VBMail.MapiMess.MsgSubject
  361.     Msg.Tag = Index
  362.     Call UpdateRecips(Msg)
  363.     Msg.Refresh
  364.     Msg.Show
  365. End Sub
  366.  
  367. Sub LogOffUser ()
  368.     On Error Resume Next
  369.     VBMail.MapiSess.Action = 2
  370.     If Err <> 0 Then
  371.         MsgBox "Logoff Failure: " + ErrorR
  372.     Else
  373.         VBMail.MapiMess.SessionID = 0
  374.         '----- Adjust the menu items
  375.         VBMail.LogOff.Enabled = 0
  376.         VBMail.Logon.Enabled = -1
  377.         '---- Unload all the windows; but the MDIForm
  378.         Do Until Forms.Count = 1
  379.             i = Forms.Count - 1
  380.             If TypeOf Forms(i) Is MDIForm Then
  381.                 'do nothing
  382.             Else
  383.                 Unload Forms(i)
  384.             End If
  385.         Loop
  386.         '---- Disable the toolbar buttons
  387.         VBMail.Next.Enabled = False
  388.         VBMail.Previous.Enabled = False
  389.         VBMail![Delete].Enabled = False
  390.         VBMail.SendCtl(MESSAGE_COMPOSE).Enabled = False
  391.         VBMail.SendCtl(MESSAGE_ReplyAll).Enabled = False
  392.         VBMail.SendCtl(MESSAGE_Reply).Enabled = False
  393.         VBMail.SendCtl(Message_Forward).Enabled = False
  394.         VBMail.rMsgList.Enabled = False
  395.         VBMail.PrintMessage.Enabled = False
  396.         VBMail.DispTools.Enabled = False
  397.         VBMail.EditDelete.Enabled = False
  398.                           
  399.         '---- Reset the caption for the status bar labels
  400.         VBMail.MsgCountLbl = "Off Line"
  401.         VBMail.UnreadLbl = ""
  402.     End If
  403.  
  404. End Sub
  405.  
  406. Sub PrintLongText (ByVal LongText As String)
  407. '------------------------------------------------------
  408. '   This routine prints a text stream to a printer and
  409. '   ensures that words are not split between lines and
  410. '   wrap as needed
  411. '------------------------------------------------------
  412.     Do Until LongText = ""
  413.         Word$ = Token$(LongText, " ")
  414.         If Printer.TextWidth(Word$) + Printer.CurrentX > Printer.Width - Printer.TextWidth("ZZZZZZZZ") Then
  415.             Printer.Print
  416.         End If
  417.         Printer.Print " " + Word$;
  418.     Loop
  419. End Sub
  420.  
  421. Sub PrintMail ()
  422.     '---- In List view all selected messages are printed
  423.     '---- In Message view, the selected message is printed
  424.  
  425.     If TypeOf VBMail.ActiveForm Is MsgView Then
  426.         Call PrintMessage(VBMail.MapiMess, False)
  427.         Printer.EndDoc
  428.     ElseIf TypeOf VBMail.ActiveForm Is MailLst Then
  429.         For i = 0 To MailLst.MList.ListCount - 1
  430.             If MailLst.MList.Selected(i) Then
  431.                 VBMail.MapiMess.MsgIndex = i
  432.                 Call PrintMessage(VBMail.MapiMess, False)
  433.             End If
  434.         Next i
  435.         Printer.EndDoc
  436.     End If
  437. End Sub
  438.  
  439. Sub PrintMessage (Msg As Control, fNewPage As Integer)
  440.     '-------------------------------------------
  441.     '   Print a mail message
  442.     '-------------------------------------------
  443.     Screen.MousePointer = 11
  444.     '----- Start a new page if needed
  445.     If fNewPage Then
  446.         Printer.NewPage
  447.     End If
  448.     Printer.FontName = "Arial"
  449.     Printer.FontBold = True
  450.     Printer.DrawWidth = 10
  451.     Printer.Line (0, Printer.CurrentY)-(Printer.Width, Printer.CurrentY)
  452.     Printer.Print
  453.     Printer.FontSize = 9.75
  454.     Printer.Print "From:";
  455.     Printer.CurrentX = Printer.TextWidth(String$(30, " "))
  456.     Printer.Print Msg.MsgOrigDisplayName
  457.     Printer.Print "To:";
  458.     Printer.CurrentX = Printer.TextWidth(String$(30, " "))
  459.     Printer.Print GetRCList(Msg, MAPI_TO)
  460.     Printer.Print "Cc:";
  461.     Printer.CurrentX = Printer.TextWidth(String$(30, " "))
  462.     Printer.Print GetRCList(Msg, MAPI_CC)
  463.     Printer.Print "Subject:";
  464.     Printer.CurrentX = Printer.TextWidth(String$(30, " "))
  465.     Printer.Print Msg.MsgSubject
  466.     Printer.Print "Date:";
  467.     Printer.CurrentX = Printer.TextWidth(String$(30, " "))
  468.     Printer.Print DateFromMapiDate$(Msg.MsgDateReceived, MAIL_LONGDATE)
  469.     Printer.Print
  470.     Printer.DrawWidth = 5
  471.     Printer.Line (0, Printer.CurrentY)-(Printer.Width, Printer.CurrentY)
  472.     Printer.FontSize = 9.75
  473.     Printer.FontBold = False
  474.     Call PrintLongText(Msg.MsgNoteText)
  475.     Printer.Print
  476.     Screen.MousePointer = 0
  477. End Sub
  478.  
  479. Sub SaveMessage (Msg As Form)
  480.     '--- Save the current subject and note text
  481.     '    copy the message to the compose buffer
  482.     '    reset the subject and message text
  483.     '    save the message
  484.     svSub = Msg.txtsubject
  485.     svNote = Msg.txtNoteText
  486.     VBMail.MapiMess.Action = MESSAGE_COPY
  487.     VBMail.MapiMess.MsgSubject = svSub
  488.     VBMail.MapiMess.MsgNoteText = svNote
  489.     VBMail.MapiMess.Action = MESSAGE_SAVE
  490. End Sub
  491.  
  492. Sub SetRCList (ByVal NameList As String, Msg As Control, RCType As Integer, fResolveNames As Integer)
  493. '--------------------------------------------------
  494. '  Given a list of Recips in the form:
  495. '
  496. '       Person 1;Person 2;Person 3
  497. '
  498. '   This sub places then names into the Msg.Recip
  499. '   structures.
  500. '
  501. '--------------------------------------------------
  502.     If NameList = "" Then
  503.         Exit Sub
  504.     End If
  505.  
  506.     i = Msg.RecipCount
  507.     Do
  508.         Msg.RecipIndex = i
  509.         Msg.RecipDisplayName = Trim$(Token(NameList, ";"))
  510.         If fResolveNames Then
  511.             Msg.Action = MESSAGE_RESOLVENAME
  512.         End If
  513.         Msg.RecipType = RCType
  514.         i = i + 1
  515.     Loop Until (NameList = "")
  516. End Sub
  517.  
  518. Sub SizeMessageWindow (MsgWindow As Form)
  519.     If MsgWindow.WindowState <> 1 Then
  520.         '--- Determine smalled allowed window size based
  521.         '    on the visiblity of AttachWin (Attachment window)
  522.         If MsgWindow.AttachWin.Visible Then    'Attachment Window
  523.             MinSize = 3700
  524.         Else
  525.             MinSize = 3700 - MsgWindow.AttachWin.Height
  526.         End If
  527.  
  528.         '---- Maintain minimum form size
  529.         If MsgWindow.Height < MinSize And (MsgWindow.WindowState = 0) Then
  530.             MsgWindow.Height = MinSize
  531.             Exit Sub
  532.  
  533.         End If
  534.         '---- Adjust the size of the textbox
  535.         If MsgWindow.ScaleHeight > MsgWindow.txtNoteText.Top Then
  536.             If MsgWindow.AttachWin.Visible Then
  537.                 x% = MsgWindow.AttachWin.Height
  538.             Else
  539.                 x% = 0
  540.             End If
  541.             MsgWindow.txtNoteText.Height = MsgWindow.ScaleHeight - MsgWindow.txtNoteText.Top - x%
  542.             MsgWindow.txtNoteText.Width = MsgWindow.ScaleWidth
  543.         End If
  544.     End If
  545.  
  546. End Sub
  547.  
  548. Function Token$ (tmp$, search$)
  549.     x = InStr(1, tmp$, search$)
  550.     If x Then
  551.        Token$ = Mid$(tmp$, 1, x - 1)
  552.        tmp$ = Mid$(tmp$, x + 1)
  553.     Else
  554.        Token$ = tmp$
  555.        tmp$ = ""
  556.     End If
  557. End Function
  558.  
  559. Sub UpdateRecips (Msg As Form)
  560. '---- This routine updates the correct editfields the
  561. '---- the Recip information.
  562.     Msg.txtTo.Text = GetRCList(VBMail.MapiMess, MAPI_TO)
  563.     Msg.txtcc.Text = GetRCList(VBMail.MapiMess, MAPI_CC)
  564. End Sub
  565.  
  566. Sub ViewNextMsg ()
  567.     '--------------------------------------------------
  568.     ' Check to see if the message is currently loaded.
  569.     '    If YES -> Show that form
  570.     '    If NO  -> Load the message
  571.     '--------------------------------------------------
  572.     WindowNum% = FindMsgWindow((MailLst.MList.ListIndex))
  573.     If WindowNum% > 0 Then
  574.         Forms(WindowNum%).Show
  575.     Else
  576.         If TypeOf VBMail.ActiveForm Is MsgView Then
  577.             Call LoadMessage(MailLst.MList.ListIndex, VBMail.ActiveForm)
  578.         Else
  579.             Dim Msg As New MsgView
  580.             Call LoadMessage(MailLst.MList.ListIndex, Msg)
  581.         End If
  582.     End If
  583. End Sub
  584.  
  585.