home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / mainbvb5 / mailnblk.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1997-10-01  |  7.9 KB  |  254 lines

  1. VERSION 5.00
  2. Object = "{8BAF5903-01D9-11D0-9E0A-444553540000}#5.0#0"; "MMail32.OCX"
  3. Begin VB.Form Form1 
  4.    Appearance      =   0  'Flat
  5.    BackColor       =   &H00C0C0C0&
  6.    Caption         =   "Non-Blocking Sample"
  7.    ClientHeight    =   3675
  8.    ClientLeft      =   3360
  9.    ClientTop       =   3105
  10.    ClientWidth     =   5640
  11.    BeginProperty Font 
  12.       Name            =   "MS Sans Serif"
  13.       Size            =   8.25
  14.       Charset         =   0
  15.       Weight          =   700
  16.       Underline       =   0   'False
  17.       Italic          =   0   'False
  18.       Strikethrough   =   0   'False
  19.    EndProperty
  20.    ForeColor       =   &H80000008&
  21.    LinkTopic       =   "Form1"
  22.    PaletteMode     =   1  'UseZOrder
  23.    ScaleHeight     =   3675
  24.    ScaleWidth      =   5640
  25.    Begin MailLib.mMail Mail1 
  26.       Left            =   0
  27.       Top             =   1440
  28.       _Version        =   327680
  29.       _ExtentX        =   847
  30.       _ExtentY        =   847
  31.       _StockProps     =   0
  32.       Blocking        =   0   'False
  33.       Debug           =   0
  34.       Host            =   ""
  35.       Timeout         =   0
  36.       ConnectType     =   0
  37.       PopPort         =   110
  38.       SmtpPort        =   25
  39.    End
  40.    Begin VB.TextBox Text4 
  41.       Appearance      =   0  'Flat
  42.       Height          =   1575
  43.       Left            =   600
  44.       MultiLine       =   -1  'True
  45.       TabIndex        =   7
  46.       Top             =   1440
  47.       Width           =   4215
  48.    End
  49.    Begin VB.CommandButton Command1 
  50.       Appearance      =   0  'Flat
  51.       BackColor       =   &H80000005&
  52.       Caption         =   "Send Message"
  53.       BeginProperty Font 
  54.          Name            =   "MS Sans Serif"
  55.          Size            =   8.25
  56.          Charset         =   0
  57.          Weight          =   400
  58.          Underline       =   0   'False
  59.          Italic          =   0   'False
  60.          Strikethrough   =   0   'False
  61.       EndProperty
  62.       Height          =   375
  63.       Left            =   1440
  64.       TabIndex        =   3
  65.       Top             =   3120
  66.       Width           =   2175
  67.    End
  68.    Begin VB.TextBox Text3 
  69.       Appearance      =   0  'Flat
  70.       Height          =   285
  71.       Left            =   1560
  72.       TabIndex        =   2
  73.       Top             =   840
  74.       Width           =   2175
  75.    End
  76.    Begin VB.TextBox Text2 
  77.       Appearance      =   0  'Flat
  78.       Height          =   285
  79.       Left            =   1560
  80.       TabIndex        =   1
  81.       Top             =   480
  82.       Width           =   2175
  83.    End
  84.    Begin VB.TextBox Text1 
  85.       Appearance      =   0  'Flat
  86.       Height          =   285
  87.       Left            =   1560
  88.       TabIndex        =   0
  89.       Top             =   120
  90.       Width           =   2175
  91.    End
  92.    Begin VB.Label Label4 
  93.       Alignment       =   1  'Right Justify
  94.       Appearance      =   0  'Flat
  95.       BackColor       =   &H00C0C0C0&
  96.       Caption         =   "Message:"
  97.       BeginProperty Font 
  98.          Name            =   "MS Sans Serif"
  99.          Size            =   8.25
  100.          Charset         =   0
  101.          Weight          =   400
  102.          Underline       =   0   'False
  103.          Italic          =   0   'False
  104.          Strikethrough   =   0   'False
  105.       EndProperty
  106.       ForeColor       =   &H80000008&
  107.       Height          =   255
  108.       Left            =   480
  109.       TabIndex        =   8
  110.       Top             =   1200
  111.       Width           =   975
  112.    End
  113.    Begin VB.Label Label3 
  114.       Alignment       =   1  'Right Justify
  115.       Appearance      =   0  'Flat
  116.       BackColor       =   &H00C0C0C0&
  117.       Caption         =   "Subject:"
  118.       BeginProperty Font 
  119.          Name            =   "MS Sans Serif"
  120.          Size            =   8.25
  121.          Charset         =   0
  122.          Weight          =   400
  123.          Underline       =   0   'False
  124.          Italic          =   0   'False
  125.          Strikethrough   =   0   'False
  126.       EndProperty
  127.       ForeColor       =   &H80000008&
  128.       Height          =   255
  129.       Left            =   240
  130.       TabIndex        =   6
  131.       Top             =   840
  132.       Width           =   1215
  133.    End
  134.    Begin VB.Label Label2 
  135.       Alignment       =   1  'Right Justify
  136.       Appearance      =   0  'Flat
  137.       BackColor       =   &H00C0C0C0&
  138.       Caption         =   "SMTP Server:"
  139.       BeginProperty Font 
  140.          Name            =   "MS Sans Serif"
  141.          Size            =   8.25
  142.          Charset         =   0
  143.          Weight          =   400
  144.          Underline       =   0   'False
  145.          Italic          =   0   'False
  146.          Strikethrough   =   0   'False
  147.       EndProperty
  148.       ForeColor       =   &H80000008&
  149.       Height          =   255
  150.       Left            =   120
  151.       TabIndex        =   5
  152.       Top             =   480
  153.       Width           =   1335
  154.    End
  155.    Begin VB.Label Label1 
  156.       Alignment       =   1  'Right Justify
  157.       Appearance      =   0  'Flat
  158.       BackColor       =   &H00C0C0C0&
  159.       Caption         =   "To:"
  160.       BeginProperty Font 
  161.          Name            =   "MS Sans Serif"
  162.          Size            =   8.25
  163.          Charset         =   0
  164.          Weight          =   400
  165.          Underline       =   0   'False
  166.          Italic          =   0   'False
  167.          Strikethrough   =   0   'False
  168.       EndProperty
  169.       ForeColor       =   &H80000008&
  170.       Height          =   255
  171.       Left            =   240
  172.       TabIndex        =   4
  173.       Top             =   120
  174.       Width           =   1215
  175.    End
  176. Attribute VB_Name = "Form1"
  177. Attribute VB_GlobalNameSpace = False
  178. Attribute VB_Creatable = False
  179. Attribute VB_PredeclaredId = True
  180. Attribute VB_Exposed = False
  181.     Dim iState As Integer
  182. Private Sub Command1_Click()
  183.     On Error GoTo Some_Err
  184.     'validate entries
  185.     If Text1.Text = "" Or Text2.Text = "" Or Text3.Text = "" Then
  186.         MsgBox "Please fill in all values.", vbExclamation, "Missing Value"
  187.         Exit Sub
  188.     End If
  189.     Mail1.Debug = 1
  190.     'create a new message
  191.     Mail1.Action = MailActionNewMessage
  192.     Mail1.Date = Format$(Now, "ddd, dd mmm yyyy hh:mm:ss")
  193.     '
  194.     'Your user friendly name
  195.     Mail1.From = "Your Name"
  196.     '
  197.     'The return e-mail address
  198.     Mail1.EMailAddress = "you@yourdomain.com"
  199.     '
  200.     'the lucky recipient
  201.     Mail1.To = Text1.Text
  202.     Mail1.Subject = Text3.Text
  203.     'create the headers for the message
  204.     '
  205.     Mail1.Body(0) = Text4.Text
  206.     'basic host configuration
  207.     Mail1.Blocking = False
  208.     Mail1.Host = Text2.Text
  209.     Mail1.ConnectType = 0 'MailConnectTypeSMTP
  210.     'send the message
  211.     Command1.Enabled = False
  212.     MousePointer = 11
  213.     iState = MailActionConnect
  214.     Mail1.Action = MailActionConnect
  215.     'the Done event of the Mail control handles the
  216.     'next actions
  217.     Exit Sub
  218. Some_Err:
  219.     MsgBox CStr(Err)
  220.     On Error Resume Next
  221.     Mail1.Action = MailActionDisconnect
  222.     MousePointer = 0
  223.     Command1.Enabled = True
  224. End Sub
  225. Private Sub Mail1_AsyncError(ByVal ErrorCode As Integer, ByVal ErrorMsg As String)
  226.     MsgBox "AsyncError: " & CStr(ErrorCode) & " - " & ErrorMsg
  227.     On Error Resume Next
  228.     iState = MailActionDisconnect
  229.     Mail1.Action = iState
  230. End Sub
  231. Private Sub Mail1_Debug(ByVal Message As String)
  232.     Debug.Print Message
  233. End Sub
  234. Private Sub Mail1_Done()
  235.     Select Case iState
  236.         Case MailActionConnect
  237.             Me.Caption = "Connected. Writing message..."
  238.             Mail1.Flags = MailDstIsHost
  239.             iState = MailActionWriteMessage
  240.             Mail1.Action = iState
  241.         Case MailActionWriteMessage
  242.             Me.Caption = "Message sent. Disconnecting..."
  243.             iState = MailActionDisconnect
  244.             Mail1.Action = iState
  245.         Case MailActionDisconnect
  246.             Me.Caption = "Disconnected!"
  247.             MousePointer = 0
  248.             Command1.Enabled = True
  249.         Case Else
  250.             MousePointer = 0
  251.             Command1.Enabled = True
  252.     End Select
  253. End Sub
  254.