home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Object = "{FFACF7F3-B868-11CE-84A8-08005A9B23BD}#1.7#0"; "DSSOCK32.OCX"
- Begin VB.Form Form2
- BorderStyle = 3 'Fixed Dialog
- Caption = "SMTP Mail Example"
- ClientHeight = 3105
- ClientLeft = 3675
- ClientTop = 3375
- ClientWidth = 5430
- LinkTopic = "Form2"
- MaxButton = 0 'False
- MinButton = 0 'False
- PaletteMode = 1 'UseZOrder
- ScaleHeight = 3105
- ScaleWidth = 5430
- ShowInTaskbar = 0 'False
- Begin VB.CommandButton btnSend
- Caption = "send mail"
- Height = 255
- Left = 4200
- TabIndex = 16
- Top = 600
- Width = 975
- End
- Begin VB.TextBox txStatus
- Alignment = 2 'Center
- BackColor = &H00C0C0C0&
- BorderStyle = 0 'None
- Height = 285
- Left = 240
- TabIndex = 14
- Top = 2760
- Width = 4935
- End
- Begin VB.TextBox txMessage
- Height = 1335
- Left = 120
- MultiLine = -1 'True
- ScrollBars = 2 'Vertical
- TabIndex = 13
- Top = 1320
- Width = 5175
- End
- Begin VB.TextBox txSubject
- Height = 285
- Left = 840
- TabIndex = 11
- Text = "wow, the subject line (how elite)"
- Top = 720
- Width = 3135
- End
- Begin VB.TextBox txFrom
- Height = 285
- Left = 2400
- TabIndex = 9
- Text = "omg@omg.net"
- Top = 360
- Width = 1575
- End
- Begin VB.TextBox txTo
- Height = 285
- Left = 360
- TabIndex = 7
- Text = "heh@umm.com"
- Top = 360
- Width = 1455
- End
- Begin VB.TextBox txPassword
- Height = 285
- IMEMode = 3 'DISABLE
- Left = 4560
- PasswordChar = "*"
- TabIndex = 5
- Text = "password"
- Top = 0
- Width = 855
- End
- Begin VB.TextBox txUser
- Height = 285
- Left = 2760
- TabIndex = 1
- Text = "user"
- Top = 0
- Width = 855
- End
- Begin VB.TextBox txHost
- Height = 285
- Left = 960
- TabIndex = 0
- Text = "mail server"
- Top = 0
- Width = 1215
- End
- Begin dsSocketLib.dsSocket dsSocket1
- Height = 420
- Left = 4320
- TabIndex = 15
- Top = 840
- Width = 420
- _Version = 65543
- _ExtentX = 741
- _ExtentY = 741
- _StockProps = 64
- LocalPort = 0
- RemoteHost = ""
- RemotePort = 0
- ServiceName = ""
- RemoteDotAddr = ""
- Linger = -1 'True
- Timeout = 10
- LineMode = 0 'False
- EOLChar = 10
- BindConnect = 0 'False
- SocketType = 0
- End
- Begin VB.Label Label7
- BackStyle = 0 'Transparent
- Caption = "message:"
- Height = 255
- Left = 120
- TabIndex = 12
- Top = 1080
- Width = 735
- End
- Begin VB.Label Label6
- BackStyle = 0 'Transparent
- Caption = "subject:"
- Height = 255
- Left = 120
- TabIndex = 10
- Top = 720
- Width = 735
- End
- Begin VB.Label Label5
- BackStyle = 0 'Transparent
- Caption = "from:"
- Height = 255
- Left = 1920
- TabIndex = 8
- Top = 360
- Width = 495
- End
- Begin VB.Label Label4
- BackStyle = 0 'Transparent
- Caption = "to:"
- Height = 255
- Left = 120
- TabIndex = 6
- Top = 360
- Width = 255
- End
- Begin VB.Label Label3
- BackStyle = 0 'Transparent
- Caption = "password:"
- Height = 255
- Left = 3720
- TabIndex = 4
- Top = 0
- Width = 855
- End
- Begin VB.Label Label2
- BackStyle = 0 'Transparent
- Caption = "user:"
- Height = 255
- Left = 2280
- TabIndex = 3
- Top = 0
- Width = 495
- End
- Begin VB.Label Label1
- BackStyle = 0 'Transparent
- Caption = "mail server:"
- Height = 255
- Left = 0
- TabIndex = 2
- Top = 0
- Width = 975
- End
- Attribute VB_Name = "Form2"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Private Sub btnSend_Click()
- dsSocket1.RemotePort = 25 ' set port
- dsSocket1.RemoteHost = txHost ' set mail server
- dsSocket1.Connect ' connect to server
- End Sub
- Private Sub dsSocket1_Receive(ReceiveData As String)
- ' this is the main processing code for
- ' sending an email message
- ' the iState variable maintains the current
- ' state of the protocol exchange so that we
- ' know what to send next
- Static iState As Integer
- Dim iMsgNum As Integer
- Dim szMsg As String
- Dim i As Integer
- iMsgNum = Val(Left(ReceiveData, InStr(ReceiveData, " ")))
- Select Case iMsgNum
- Case 220 ' initial message
- dsSocket1.Send = "HELO " & txHost & vbCrLf
- txStatus = "Mail Server is ready"
- iState = 1
-
- Case 221
- If iState = 999 Then
- txStatus = "Disconnected from mail server after error"
- Else
- txStatus = "Disconnected from mail server"
- End If
- iState = 0
-
- Case 250
- Select Case iState
- Case 1:
- dsSocket1.Send = "MAIL FROM:<" & txFrom & ">" & vbCrLf
- Debug.Print "MAIL FROM:<" & txFrom & ">" & vbCrLf
- txStatus = "Sending FROM tag"
- iState = 2
-
- Case 2:
- dsSocket1.Send = "RCPT TO:<" & txTo & ">" & vbCrLf
- Debug.Print "RCPT TO:<" & txTo & ">" & vbCrLf
- txStatus = "Sending RCPT tag"
- iState = 3
-
- Case 3:
- dsSocket1.Send = "DATA" & vbCrLf
- Debug.Print "DATA" & vbCrLf
- txStatus = "Sending DATA tag"
- iState = 4
-
- Case 5:
- dsSocket1.Send = "QUIT" & vbCrLf
- Debug.Print "QUIT" & vbCrLf
- txStatus = "Disconnecting from mail server"
- iState = 6
-
- End Select
-
- Case 354
- iState = 5
- szMsg = txMessage
- txStatus = "Sending mail message data"
- dsSocket1.Send = "Subject: " & txSubject & vbCrLf
- dsSocket1.Send = szMsg
- 'While szMsg <> ""
- 'dsSocket1.Send = Left(szMsg, InStr(szMsg, Chr(10)))
- 'Debug.Print "Sending:" & Left(szMsg, InStr(szMsg, Chr(10)))
- 'szMsg = Mid(szMsg, InStr(szMsg, Chr(10)) + 1)
- 'Wend
- dsSocket1.Send = "." & vbCrLf
-
- Case 500 To 599
- dsSocket1.Send = "QUIT" & vbCrLf
- txStatus = "Error sending mail"
- Debug.Print "Error sending mail. Quitting"
- iState = 999
-
- End Select
- End Sub
- Private Sub dsSocket1_SendReady()
- ' the mail server connection is ready for data
- txStatus = "Connected to mail server"
- End Sub
-