可以参考一下:
Public Sub SendMail(strFrom As String, strTo As String, strSubject As String, strBody As TextBox, wsk As Winsock, Optional strAttachName As String, Optional txtEncodedFile As Control)
Dim intCount As Integer
Wait 0.5
wsk.SendData "EHLO " & wsk.LocalIP & vbCrLf
wsk.SendData "AUTH LOGIN" + vbCrLf
Wait 0.5
If Not nocheck Then
wsk.SendData B64E(strusername) + vbCrLf
wsk.SendData B64E(strpsd) + vbCrLf
End If
wsk.SendData "MAIL FROM:" & strFrom & vbCrLf