home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic 4 Unleashed / Visual_Basic_4_Unleashed_SAMS_Publishing_1995.iso / source / chap25 / vbu2503.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-09-13  |  7.4 KB  |  247 lines

  1. VERSION 4.00
  2. Begin VB.Form Main 
  3.    Caption         =   "Simple Mail Tool"
  4.    ClientHeight    =   4035
  5.    ClientLeft      =   1245
  6.    ClientTop       =   1545
  7.    ClientWidth     =   6435
  8.    Height          =   4440
  9.    Left            =   1185
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   4035
  12.    ScaleWidth      =   6435
  13.    Top             =   1200
  14.    Width           =   6555
  15.    Begin VB.CommandButton Command1 
  16.       Caption         =   "E&xit"
  17.       Height          =   300
  18.       Index           =   8
  19.       Left            =   5100
  20.       TabIndex        =   10
  21.       Top             =   3600
  22.       Width           =   1215
  23.    End
  24.    Begin VB.CommandButton Command1 
  25.       Caption         =   "Address &Book"
  26.       Height          =   300
  27.       Index           =   7
  28.       Left            =   5100
  29.       TabIndex        =   9
  30.       Top             =   3060
  31.       Width           =   1215
  32.    End
  33.    Begin VB.CommandButton Command1 
  34.       Caption         =   "&Read"
  35.       Height          =   300
  36.       Index           =   6
  37.       Left            =   5100
  38.       TabIndex        =   8
  39.       Top             =   2640
  40.       Width           =   1215
  41.    End
  42.    Begin VB.CommandButton Command1 
  43.       Caption         =   "&Delete"
  44.       Height          =   300
  45.       Index           =   5
  46.       Left            =   5100
  47.       TabIndex        =   7
  48.       Top             =   2220
  49.       Width           =   1200
  50.    End
  51.    Begin VB.CommandButton Command1 
  52.       Caption         =   "&Reply &All"
  53.       Height          =   300
  54.       Index           =   4
  55.       Left            =   5100
  56.       TabIndex        =   6
  57.       Top             =   1800
  58.       Width           =   1200
  59.    End
  60.    Begin VB.CommandButton Command1 
  61.       Caption         =   "R&eply"
  62.       Height          =   300
  63.       Index           =   3
  64.       Left            =   5100
  65.       TabIndex        =   5
  66.       Top             =   1380
  67.       Width           =   1200
  68.    End
  69.    Begin VB.CommandButton Command1 
  70.       Caption         =   "&Forward"
  71.       Height          =   300
  72.       Index           =   2
  73.       Left            =   5100
  74.       TabIndex        =   4
  75.       Top             =   960
  76.       Width           =   1200
  77.    End
  78.    Begin VB.CommandButton Command1 
  79.       Caption         =   "&Copy"
  80.       Height          =   300
  81.       Index           =   1
  82.       Left            =   5100
  83.       TabIndex        =   3
  84.       Top             =   540
  85.       Width           =   1200
  86.    End
  87.    Begin VB.CommandButton Command1 
  88.       Caption         =   "&New"
  89.       Height          =   300
  90.       Index           =   0
  91.       Left            =   5100
  92.       TabIndex        =   2
  93.       Top             =   120
  94.       Width           =   1200
  95.    End
  96.    Begin VB.ListBox List1 
  97.       Height          =   2790
  98.       Left            =   120
  99.       TabIndex        =   0
  100.       Top             =   480
  101.       Width           =   4815
  102.    End
  103.    Begin MSMAPI.MAPIMessages MAPIMessages1 
  104.       Left            =   1140
  105.       Top             =   3420
  106.       _Version        =   65536
  107.       _ExtentX        =   741
  108.       _ExtentY        =   741
  109.       _StockProps     =   0
  110.    End
  111.    Begin MSMAPI.MAPISession MAPISession1 
  112.       Left            =   540
  113.       Top             =   3360
  114.       _Version        =   65536
  115.       _ExtentX        =   741
  116.       _ExtentY        =   741
  117.       _StockProps     =   0
  118.    End
  119.    Begin VB.Label Label1 
  120.       BorderStyle     =   1  'Fixed Single
  121.       Caption         =   "Messages:"
  122.       Height          =   255
  123.       Left            =   120
  124.       TabIndex        =   1
  125.       Top             =   120
  126.       Width           =   4815
  127.    End
  128. Attribute VB_Name = "Main"
  129. Attribute VB_Creatable = False
  130. Attribute VB_Exposed = False
  131. Option Explicit
  132. Private Sub Command1_Click(Index As Integer)
  133.     '
  134.     ' handle user clicks
  135.     '
  136.     On Error GoTo Command1ClickErr
  137.     '
  138.     Dim nTemp As Integer
  139.     '
  140.     Select Case Index
  141.         Case 0
  142.             ' new message
  143.             MAPIMessages1.Compose   ' clear compose buffer
  144.             MAPIMessages1.Send True ' start server dialog
  145.         Case 1
  146.             ' copy message
  147.             MAPIMessages1.MsgIndex = List1.ListIndex    ' point to msg
  148.             MAPIMessages1.Copy      ' copy in to compose buffer
  149.             MAPIMessages1.Send True ' start server dialog
  150.         Case 2
  151.             ' forward message
  152.             MAPIMessages1.MsgIndex = List1.ListIndex    ' point to msg
  153.             MAPIMessages1.Forward   ' copy as forwarded in to buffer
  154.             MAPIMessages1.Send True ' start dialog
  155.         Case 3
  156.             ' reply to message
  157.             MAPIMessages1.MsgIndex = List1.ListIndex    ' point to msg
  158.             MAPIMessages1.Reply     ' copy as reply into buffer
  159.             MAPIMessages1.Send True ' start server dialog
  160.         Case 4
  161.             ' reply to all senders
  162.             MAPIMessages1.MsgIndex = List1.ListIndex    ' point to msg
  163.             MAPIMessages1.ReplyAll  ' copy as reply aal into buffer
  164.             MAPIMessages1.Send True ' start server dialog
  165.         Case 5
  166.             ' delete message
  167.             nTemp = MsgBox("Delete Current Message?", vbYesNo, "Delete Message")
  168.             If nTemp = vbYes Then       ' if confirmed delete
  169.                 MAPIMessages1.MsgIndex = List1.ListIndex    ' point to msg
  170.                 MAPIMessages1.Delete    ' tell server to delete msg
  171.                 GetMessages             ' refresh local list
  172.             End If
  173.         Case 6
  174.             ' read message
  175.             MAPIMessages1.MsgIndex = List1.ListIndex    ' point to msg
  176.             Reader.Show vbModal     ' start read form
  177.         Case 7
  178.             ' address book
  179.             MAPIMessages1.Show      ' show book
  180.         Case 8
  181.             ' exit program
  182.             nTemp = MsgBox("Exit Program?", vbInformation + vbYesNo, "Program Exit")
  183.             If nTemp = vbYes Then   ' if confirmed exit
  184.                 Unload Me           ' shut down
  185.             End If
  186.     End Select
  187.     '
  188.     Exit Sub
  189.     '
  190. Command1ClickErr:
  191.     MsgBox Error$, vbCritical, "Error Code: " + Str(Err)
  192.     '
  193. End Sub
  194. Private Sub Form_Load()
  195.     '
  196.     ' attempt signon
  197.     '
  198.     On Error GoTo FormLoadErr
  199.     '
  200.     MAPISession1.SignOn ' tell server to log me in
  201.     MAPIMessages1.SessionID = MAPISession1.SessionID
  202.     GetMessages         ' get lost of messages
  203.     '
  204.     Exit Sub
  205.     '
  206. FormLoadErr:
  207.     MsgBox Error$, vbCritical, "Error Code " + Str(Err)
  208.     Unload Me
  209.     End
  210. End Sub
  211. Private Sub Form_Unload(Cancel As Integer)
  212.     '
  213.     On Error Resume Next
  214.     MAPISession1.SignOff
  215.     '
  216. End Sub
  217. Public Sub GetMessages()
  218.     '
  219.     ' get all unread stuff fro this user
  220.     '
  221.     Dim x As Integer
  222.     Dim cLine As String
  223.     '
  224.     On Error GoTo GetMessagesErr
  225.     '
  226.     MAPIMessages1.Fetch     ' get messages from server
  227.     '
  228.     List1.Clear             ' clear local list control
  229.     If MAPIMessages1.MsgCount > 0 Then  ' got at least one?
  230.         For x = 0 To MAPIMessages1.MsgCount - 1
  231.             MAPIMessages1.MsgIndex = x      ' move pointer
  232.             cLine = MAPIMessages1.MsgSubject    ' get subject
  233.             List1.AddItem cLine     ' add to list control
  234.         Next x
  235.     End If
  236.     '
  237.     Exit Sub
  238.     '
  239. GetMessagesErr:
  240.     MsgBox Error$, vbCritical, "Error Code: " + Str(Err)
  241.     Unload Me
  242.     '
  243. End Sub
  244. Private Sub List1_DblClick()
  245.     Command1_Click 6    ' read message
  246. End Sub
  247.