home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / Visual Basic new SourceCode and Projects / Vb E-mail Applictation / MAILSUP.BAS < prev    next >
Encoding:
BASIC Source File  |  1995-08-14  |  18.9 KB  |  559 lines

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