给出示例代码如下:
sendemail.frm
VERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 5250 ClientLeft = 60 ClientTop = 345 ClientWidth = 5865 LinkTopic = "Form1" ScaleHeight = 5250 ScaleWidth = 5865 StartUpPosition = 3 ''''窗口缺省 Begin VB.TextBox Text5 Height = 2055 Left = 480 MultiLine = -1 ''''True TabIndex = 8 Top = 2880 Width = 4815 End Begin VB.TextBox Text2 Height = 375 Left = 2040 TabIndex = 7 Top = 720 Width = 2535 End Begin VB.CommandButton Command1 Caption = "send" Height = 375 Left = 3600 TabIndex = 6 Top = 2160 Width = 975 End Begin VB.TextBox Text4 Height = 375 Left = 1440 TabIndex = 5 Text = "qaymuic@wocall.com" Top = 2160 Width = 2055 End Begin VB.TextBox Text3 Height = 735 Left = 360 MultiLine = -1 ''''True TabIndex = 3 Top = 1320 Width = 4215 End Begin VB.TextBox Text1 Height = 375 Left = 1920 TabIndex = 1 Top = 120 Width = 2655 End Begin VB.Label Label3 Caption = "from" Height = 375 Left = 240 TabIndex = 4 Top = 2160 Width = 975 End Begin VB.Label Label2 Caption = "to:" Height = 375 Left = 360 TabIndex = 2 Top = 720 Width = 1335 End Begin VB.Label Label1 Caption = "smtp server" Height = 375 Left = 360 TabIndex = 0 Top = 120 Width = 1335 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Declare Function socket Lib "wsock32.dll" (ByVal af As Long, ByVal s_type As Long, ByVal protocal As Long) As Long Private Const AF_INET = 2 Private Const SOCK_STREAM = 1 Private Declare Function closesocket Lib "wsock32.dll" (ByVal s As Long) As Long Private Declare Function WSAStartup Lib "wsock32.dll" (ByVal wversion As Long, lpwsadata As wsadata) As Long Private Type wsadata wversion As Integer whighversion As Integer szdescription(0 To 256) As Byte szsystemstatus(0 To 128) As Byte imaxsockets As Integer imaxudpdg As Integer lpvendorinfo As Long End Type Dim sendok As Boolean Dim rcptok As Boolean Private Declare Function WSAAsyncSelect Lib "wsock32.dll" (ByVal s As Long, ByVal hwnd As Long, ByVal wmsg As Long, ByVal levent As Long) As Long Private Const FD_READ = &H1 Private Declare Function WSACleanup Lib "wsock32.dll" () As Long Dim mailok As Boolean Private Declare Function connect Lib "wsock32.dll" (ByVal s As Long, addr As sockaddr, ByVal namelen As Long) As Long Private Type sockaddr sin_family As Integer sin_port As Integer sin_addr As Long sin_zero As String * 8 End Type Private Declare Function gethostbyname Lib "wsock32.dll" (ByVal host_name As String) As Long Private Type hostent h_name As Long h_aliases As Long h_addrtype As Integer h_length As Integer h_addr_list As Long End Type Dim sll As Long Private Declare Function htons Lib "wsock32.dll" (ByVal hostshort As Long) As Integer Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long) Private Declare Function send Lib "wsock32.dll" (ByVal s As Long, buf As Any, ByVal buflen As Long, ByVal flags As Long) As Long Private Declare Function recv Lib "wsock32.dll" (ByVal s As Long, ByVal buf As Any, ByVal buflen As Long, ByVal flags As Long) As Long Private Sub Command1_Click()
Dim rc As Long Dim xxz As wsadata Dim sck As sockaddr mailok = False rcptok = False sendok = False Text5.Text = "" sll = 0 sck.sin_family = AF_INET sck.sin_addr = getipaddress(Text1.Text) sck.sin_port = htons(25) sck.sin_zero = String(8, 0) rc = WSAStartup(&H101, xxz) sll = socket(AF_INET, SOCK_STREAM, 0) rc = connect(sll, sck, Len(sck)) WSAAsyncSelect sll, Text5.hwnd, &H100, FD_R [1] [2] 下一页 [系统软件]如何在Linux系统上进行快速磁带备份 [常用软件]在POWERBUILDER中使用WINSOCK控件的方法 [C语言系列]如何在Jbuilder9中使用SQLServer JDBC驱动 [VB.NET程序]如何在Visual Basic 6.0 中连接加密的Access数据库 [Delphi程序]Delphi Winsock Hooking Example by Aphex [Delphi程序]如何在delphi6中调试web程序 [Delphi程序]winsock 函数简介 [Delphi程序]如何在Delphi中用代码来完成计算字段的创建 [Delphi程序]如何在 Listbox 上显示 In-place Tooltips [Delphi程序]如何在Delphi应用程序中调用CHM文档
|