home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / CODE_UPLOAD33342102000.psc / Sample / frmMain.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  2000-02-10  |  17.6 KB  |  495 lines

  1. VERSION 5.00
  2. Object = "{BDC217C8-ED16-11CD-956C-0000C04E4C0A}#1.1#0"; "TABCTL32.OCX"
  3. Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
  4. Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
  5. Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
  6. Begin VB.Form frmMain 
  7.    BorderStyle     =   3  'Fixed Dialog
  8.    Caption         =   "MAPI Mail Sample Program"
  9.    ClientHeight    =   7170
  10.    ClientLeft      =   45
  11.    ClientTop       =   330
  12.    ClientWidth     =   9270
  13.    Icon            =   "frmMain.frx":0000
  14.    LinkTopic       =   "Form1"
  15.    LockControls    =   -1  'True
  16.    MaxButton       =   0   'False
  17.    MinButton       =   0   'False
  18.    ScaleHeight     =   7170
  19.    ScaleWidth      =   9270
  20.    ShowInTaskbar   =   0   'False
  21.    StartUpPosition =   2  'CenterScreen
  22.    Begin MSComctlLib.Toolbar tbMain 
  23.       Align           =   1  'Align Top
  24.       Height          =   660
  25.       Left            =   0
  26.       TabIndex        =   6
  27.       Top             =   0
  28.       Width           =   9270
  29.       _ExtentX        =   16351
  30.       _ExtentY        =   1164
  31.       ButtonWidth     =   1032
  32.       ButtonHeight    =   1005
  33.       Appearance      =   1
  34.       ImageList       =   "imgMain"
  35.       _Version        =   393216
  36.       BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628} 
  37.          NumButtons      =   8
  38.          BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  39.             Object.ToolTipText     =   "Send"
  40.             ImageIndex      =   1
  41.          EndProperty
  42.          BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  43.             Object.ToolTipText     =   "Check"
  44.             ImageIndex      =   2
  45.          EndProperty
  46.          BeginProperty Button3 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  47.             Object.ToolTipText     =   "Delete"
  48.             ImageIndex      =   3
  49.          EndProperty
  50.          BeginProperty Button4 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  51.             Object.ToolTipText     =   "Reply"
  52.             ImageIndex      =   5
  53.          EndProperty
  54.          BeginProperty Button5 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  55.             Object.ToolTipText     =   "New"
  56.             ImageIndex      =   6
  57.          EndProperty
  58.          BeginProperty Button6 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  59.             Object.ToolTipText     =   "Foward"
  60.             ImageIndex      =   7
  61.          EndProperty
  62.          BeginProperty Button7 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  63.             Object.ToolTipText     =   "Print"
  64.             ImageIndex      =   8
  65.          EndProperty
  66.          BeginProperty Button8 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  67.             Object.ToolTipText     =   "Exit"
  68.             ImageIndex      =   4
  69.          EndProperty
  70.       EndProperty
  71.    End
  72.    Begin MSComctlLib.StatusBar sbMain 
  73.       Align           =   2  'Align Bottom
  74.       Height          =   330
  75.       Left            =   0
  76.       TabIndex        =   5
  77.       Top             =   6840
  78.       Width           =   9270
  79.       _ExtentX        =   16351
  80.       _ExtentY        =   582
  81.       _Version        =   393216
  82.       BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628} 
  83.          NumPanels       =   3
  84.          BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
  85.             AutoSize        =   1
  86.             Object.Width           =   11165
  87.          EndProperty
  88.          BeginProperty Panel2 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
  89.          EndProperty
  90.          BeginProperty Panel3 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
  91.          EndProperty
  92.       EndProperty
  93.    End
  94.    Begin MSComctlLib.ImageList imgMain 
  95.       Left            =   60
  96.       Top             =   6165
  97.       _ExtentX        =   1005
  98.       _ExtentY        =   1005
  99.       BackColor       =   -2147483643
  100.       ImageWidth      =   32
  101.       ImageHeight     =   32
  102.       MaskColor       =   12632256
  103.       _Version        =   393216
  104.       BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} 
  105.          NumListImages   =   9
  106.          BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  107.             Picture         =   "frmMain.frx":0442
  108.             Key             =   ""
  109.          EndProperty
  110.          BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  111.             Picture         =   "frmMain.frx":0896
  112.             Key             =   ""
  113.          EndProperty
  114.          BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  115.             Picture         =   "frmMain.frx":0CEA
  116.             Key             =   ""
  117.          EndProperty
  118.          BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  119.             Picture         =   "frmMain.frx":1006
  120.             Key             =   ""
  121.          EndProperty
  122.          BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  123.             Picture         =   "frmMain.frx":1322
  124.             Key             =   ""
  125.          EndProperty
  126.          BeginProperty ListImage6 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  127.             Picture         =   "frmMain.frx":1776
  128.             Key             =   ""
  129.          EndProperty
  130.          BeginProperty ListImage7 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  131.             Picture         =   "frmMain.frx":1A92
  132.             Key             =   ""
  133.          EndProperty
  134.          BeginProperty ListImage8 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  135.             Picture         =   "frmMain.frx":1DAE
  136.             Key             =   ""
  137.          EndProperty
  138.          BeginProperty ListImage9 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  139.             Picture         =   "frmMain.frx":268A
  140.             Key             =   ""
  141.          EndProperty
  142.       EndProperty
  143.    End
  144.    Begin TabDlg.SSTab sstMain 
  145.       Height          =   6105
  146.       Left            =   15
  147.       TabIndex        =   4
  148.       TabStop         =   0   'False
  149.       Top             =   705
  150.       Width           =   9240
  151.       _ExtentX        =   16298
  152.       _ExtentY        =   10769
  153.       _Version        =   393216
  154.       Style           =   1
  155.       Tabs            =   2
  156.       TabsPerRow      =   2
  157.       TabHeight       =   520
  158.       TabCaption(0)   =   "Receive Electronic Mail "
  159.       TabPicture(0)   =   "frmMain.frx":29A6
  160.       Tab(0).ControlEnabled=   -1  'True
  161.       Tab(0).Control(0)=   "fraMain"
  162.       Tab(0).Control(0).Enabled=   0   'False
  163.       Tab(0).Control(1)=   "fraMessage"
  164.       Tab(0).Control(1).Enabled=   0   'False
  165.       Tab(0).ControlCount=   2
  166.       TabCaption(1)   =   "Send Electronic Mail "
  167.       TabPicture(1)   =   "frmMain.frx":29C2
  168.       Tab(1).ControlEnabled=   0   'False
  169.       Tab(1).Control(0)=   "lblDestination"
  170.       Tab(1).Control(0).Enabled=   0   'False
  171.       Tab(1).Control(1)=   "lblCC"
  172.       Tab(1).Control(1).Enabled=   0   'False
  173.       Tab(1).Control(2)=   "lblSubject"
  174.       Tab(1).Control(2).Enabled=   0   'False
  175.       Tab(1).Control(3)=   "lblMessage"
  176.       Tab(1).Control(3).Enabled=   0   'False
  177.       Tab(1).Control(4)=   "lblAttachments"
  178.       Tab(1).Control(4).Enabled=   0   'False
  179.       Tab(1).Control(5)=   "lvAttachments"
  180.       Tab(1).Control(5).Enabled=   0   'False
  181.       Tab(1).Control(6)=   "txtDestination"
  182.       Tab(1).Control(6).Enabled=   0   'False
  183.       Tab(1).Control(7)=   "txtCC"
  184.       Tab(1).Control(7).Enabled=   0   'False
  185.       Tab(1).Control(8)=   "txtSubject"
  186.       Tab(1).Control(8).Enabled=   0   'False
  187.       Tab(1).Control(9)=   "txtNewMessage"
  188.       Tab(1).Control(9).Enabled=   0   'False
  189.       Tab(1).Control(10)=   "cmdBrowse"
  190.       Tab(1).Control(10).Enabled=   0   'False
  191.       Tab(1).Control(11)=   "cdMain"
  192.       Tab(1).Control(11).Enabled=   0   'False
  193.       Tab(1).ControlCount=   12
  194.       Begin MSComDlg.CommonDialog cdMain 
  195.          Left            =   -74895
  196.          Top             =   4965
  197.          _ExtentX        =   847
  198.          _ExtentY        =   847
  199.          _Version        =   393216
  200.       End
  201.       Begin VB.CommandButton cmdBrowse 
  202.          Caption         =   "Browse"
  203.          Height          =   375
  204.          Left            =   -73920
  205.          TabIndex        =   18
  206.          Top             =   5550
  207.          Width           =   1380
  208.       End
  209.       Begin VB.TextBox txtNewMessage 
  210.          Height          =   2925
  211.          Left            =   -73920
  212.          MultiLine       =   -1  'True
  213.          ScrollBars      =   2  'Vertical
  214.          TabIndex        =   3
  215.          Top             =   1605
  216.          Width           =   8010
  217.       End
  218.       Begin VB.TextBox txtSubject 
  219.          Height          =   315
  220.          Left            =   -73920
  221.          TabIndex        =   2
  222.          Top             =   1230
  223.          Width           =   8010
  224.       End
  225.       Begin VB.TextBox txtCC 
  226.          Height          =   315
  227.          Left            =   -73920
  228.          TabIndex        =   1
  229.          Top             =   855
  230.          Width           =   8010
  231.       End
  232.       Begin VB.TextBox txtDestination 
  233.          Height          =   315
  234.          Left            =   -73920
  235.          TabIndex        =   0
  236.          Top             =   480
  237.          Width           =   8010
  238.       End
  239.       Begin VB.Frame fraMessage 
  240.          Caption         =   "Message Text"
  241.          Height          =   3405
  242.          Left            =   75
  243.          TabIndex        =   8
  244.          Top             =   2610
  245.          Width           =   9090
  246.          Begin MSComctlLib.ListView lvMain 
  247.             Height          =   930
  248.             Left            =   45
  249.             TabIndex        =   11
  250.             TabStop         =   0   'False
  251.             Top             =   2415
  252.             Width           =   8985
  253.             _ExtentX        =   15849
  254.             _ExtentY        =   1640
  255.             LabelWrap       =   -1  'True
  256.             HideSelection   =   -1  'True
  257.             _Version        =   393217
  258.             Icons           =   "imgMain"
  259.             ForeColor       =   -2147483640
  260.             BackColor       =   -2147483643
  261.             BorderStyle     =   1
  262.             Appearance      =   1
  263.             NumItems        =   0
  264.          End
  265.          Begin VB.TextBox txtMessage 
  266.             Height          =   2160
  267.             Left            =   60
  268.             Locked          =   -1  'True
  269.             MultiLine       =   -1  'True
  270.             ScrollBars      =   2  'Vertical
  271.             TabIndex        =   9
  272.             TabStop         =   0   'False
  273.             Top             =   255
  274.             Width           =   8955
  275.          End
  276.       End
  277.       Begin VB.Frame fraMain 
  278.          Caption         =   "Available Messages"
  279.          Height          =   2175
  280.          Left            =   75
  281.          TabIndex        =   7
  282.          Top             =   390
  283.          Width           =   9090
  284.          Begin MSFlexGridLib.MSFlexGrid fgMain 
  285.             Height          =   1860
  286.             Left            =   60
  287.             TabIndex        =   10
  288.             TabStop         =   0   'False
  289.             Top             =   240
  290.             Width           =   8955
  291.             _ExtentX        =   15796
  292.             _ExtentY        =   3281
  293.             _Version        =   393216
  294.             Cols            =   3
  295.             FixedCols       =   0
  296.             BorderStyle     =   0
  297.          End
  298.       End
  299.       Begin MSComctlLib.ListView lvAttachments 
  300.          Height          =   930
  301.          Left            =   -73935
  302.          TabIndex        =   16
  303.          TabStop         =   0   'False
  304.          Top             =   4590
  305.          Width           =   8040
  306.          _ExtentX        =   14182
  307.          _ExtentY        =   1640
  308.          LabelWrap       =   -1  'True
  309.          HideSelection   =   -1  'True
  310.          _Version        =   393217
  311.          Icons           =   "imgMain"
  312.          ForeColor       =   -2147483640
  313.          BackColor       =   -2147483643
  314.          BorderStyle     =   1
  315.          Appearance      =   1
  316.          NumItems        =   0
  317.       End
  318.       Begin VB.Label lblAttachments 
  319.          AutoSize        =   -1  'True
  320.          Caption         =   "Attachments:"
  321.          Height          =   195
  322.          Left            =   -74895
  323.          TabIndex        =   17
  324.          Top             =   4620
  325.          Width           =   930
  326.       End
  327.       Begin VB.Label lblMessage 
  328.          AutoSize        =   -1  'True
  329.          Caption         =   "Message:"
  330.          Height          =   195
  331.          Left            =   -74895
  332.          TabIndex        =   15
  333.          Top             =   1605
  334.          Width           =   690
  335.       End
  336.       Begin VB.Label lblSubject 
  337.          AutoSize        =   -1  'True
  338.          Caption         =   "Subject:"
  339.          Height          =   195
  340.          Left            =   -74895
  341.          TabIndex        =   14
  342.          Top             =   1260
  343.          Width           =   585
  344.       End
  345.       Begin VB.Label lblCC 
  346.          AutoSize        =   -1  'True
  347.          Caption         =   "CC:"
  348.          Height          =   195
  349.          Left            =   -74895
  350.          TabIndex        =   13
  351.          Top             =   885
  352.          Width           =   255
  353.       End
  354.       Begin VB.Label lblDestination 
  355.          AutoSize        =   -1  'True
  356.          Caption         =   "To:"
  357.          Height          =   195
  358.          Left            =   -74895
  359.          TabIndex        =   12
  360.          Top             =   510
  361.          Width           =   240
  362.       End
  363.    End
  364. Attribute VB_Name = "frmMain"
  365. Attribute VB_GlobalNameSpace = False
  366. Attribute VB_Creatable = False
  367. Attribute VB_PredeclaredId = True
  368. Attribute VB_Exposed = False
  369. Option Explicit
  370. Private Sub cmdBrowse_Click()
  371.     Dim itmX As Variant
  372.     On Local Error GoTo ReportError
  373.     cdMain.CancelError = True
  374.     cdMain.DialogTitle = "Add Attachment"
  375.     cdMain.Filter = "Any File (*.*)|*.*"
  376.     cdMain.InitDir = App.Path
  377.     cdMain.ShowOpen
  378.     If cdMain.FileName <> "" Then
  379.         Set itmX = lvAttachments.ListItems.Add(, , cdMain.FileTitle, 9)
  380.         itmX.Tag = cdMain.FileName
  381.     End If
  382.     Exit Sub
  383. ReportError:
  384.     Exit Sub
  385. End Sub
  386. Private Sub fgMain_Click()
  387.     Dim tMessages As Variant
  388.     Dim Attachments As Variant
  389.     Dim FileName As String
  390.     Dim itmX As Variant
  391.     Dim y As Integer
  392.     lvMain.ListItems.Clear
  393.     tMessages = oReceive.RcdMessages
  394.     txtMessage.Text = tMessages(3, fgMain.RowSel)
  395.     If Not IsArrayEmpty(tMessages(4, fgMain.RowSel)) Then  'Attachments
  396.         Attachments = tMessages(4, fgMain.RowSel)
  397.         For y = 0 To UBound(Attachments)
  398.             FileName = GetNamePart(CStr(Attachments(y)))
  399.             Set itmX = lvMain.ListItems.Add(, , FileName, 9)
  400.             itmX.Tag = CStr(Attachments(y))
  401.         Next
  402.     End If
  403. End Sub
  404. Private Sub Form_Load()
  405.     fgMain.Rows = 1
  406.     fgMain.Row = 0
  407.     fgMain.Col = 0
  408.     fgMain.ColWidth(0) = 3000
  409.     fgMain.Text = "From"
  410.     fgMain.Col = 1
  411.     fgMain.ColWidth(1) = 1900
  412.     fgMain.Text = "Date"
  413.     fgMain.Col = 2
  414.     fgMain.ColWidth(2) = 4000
  415.     fgMain.Text = "Subject"
  416. End Sub
  417. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
  418.     If MsgBox("Are you sure you want to quit?", _
  419.                vbYesNo + vbQuestion, "Quit?") = vbYes Then
  420.         Cancel = False
  421.     Else
  422.         Cancel = True
  423.     End If
  424. End Sub
  425. Private Sub Form_Unload(Cancel As Integer)
  426.     If Not oMail.LogOff(ErrCode, ErrMsg) Then
  427.         MsgBox "Error: " & ErrCode & " - " & ErrMsg, _
  428.                 vbCritical + vbOKOnly, "Log Off Error"
  429.     End If
  430.     Set oReceive = Nothing
  431.     Set oSend = Nothing
  432.     Set oMail = Nothing
  433.     Set frmMain = Nothing
  434. End Sub
  435. Private Sub sstMain_Click(PreviousTab As Integer)
  436.     If PreviousTab = 0 Then
  437.         txtDestination.SetFocus
  438.     End If
  439. End Sub
  440. Private Sub tbMain_ButtonClick(ByVal Button As MSComctlLib.Button)
  441.     Dim tMessages As Variant
  442.     Dim Attachments As Variant
  443.     Dim FileName As String
  444.     Dim itmX As Variant
  445.     Dim y As Integer
  446.     On Local Error GoTo ReportError
  447.     Select Case Button.Index
  448.     Case 1  'Send
  449.         If lvAttachments.ListItems.Count > 0 Then
  450.             ReDim Attachments(lvAttachments.ListItems.Count) As String
  451.             For y = 1 To lvAttachments.ListItems.Count
  452.                 Attachments(y - 1) = lvAttachments.ListItems.Item(y).Tag
  453.             Next
  454.         End If
  455.         
  456.         If Not SendMail(txtDestination.Text, txtCC.Text, txtSubject.Text, _
  457.                         txtNewMessage.Text, Attachments, ErrCode, ErrMsg) Then
  458.             GoTo ReportError
  459.         Else
  460.             MsgBox "Email sent...", vbOKOnly + vbInformation, "Sent"
  461.         End If
  462.     Case 2  'Check
  463.         If Not GetMail(fgMain, True, ErrCode, ErrMsg) Then
  464.             GoTo ReportError
  465.         ElseIf oReceive.MessageCount > 0 Then
  466.             lvMain.ListItems.Clear
  467.             tMessages = oReceive.RcdMessages
  468.             txtMessage.Text = tMessages(3, 0)
  469.             If Not IsArrayEmpty(tMessages(4, 0)) Then  'Attachments
  470.                 Attachments = tMessages(4, 0)
  471.                 For y = 0 To UBound(Attachments)
  472.                     FileName = GetNamePart(CStr(Attachments(y)))
  473.                     Set itmX = lvMain.ListItems.Add(, , FileName, 9)
  474.                     itmX.Tag = CStr(Attachments(y))
  475.                 Next
  476.             End If
  477.         End If
  478.     Case 3  'Delete
  479.     Case 4  'Reply
  480.     Case 5  'New
  481.     Case 6  'Foward
  482.     Case 7  'Print
  483.     Case 8  'Exit
  484.         Unload Me
  485.     End Select
  486.     Exit Sub
  487. ReportError:
  488.     If ErrCode = 0 Then
  489.         ErrCode = Err.Number
  490.         ErrMsg = Err.Description
  491.     End If
  492.     MsgBox "Error: " & ErrCode & " - " & ErrMsg, vbCritical + vbOKOnly, "Error"
  493.     Exit Sub
  494. End Sub
  495.