Hi
I would like to know how to send an email through a VB6 application. I'm using WizBang's Winsock-SMTP Server mailer. So far I've got...
I get the error message:Code:Dim UserName$, UserMail$, MailRecipiant$, MailBody$, SockData$ Private Sub Command1_Click() UserName = "JetlagJad" UserMail = "Jarryd <[email protected]>" MailRecipiant = UserMail MailBody = "The message goes here" Winsock1.LocalPort = 0 Winsock1.RemoteHost = "smtp.gmail.com" Winsock1.RemotePort = 587 Winsock1.Connect End Sub Private Sub Winsock1_Connect() Label1 = "Sending message..." Winsock1.SendData "EHLO " & UserName & vbCrLf If Not WaitFor("250") Then GoTo 100 Winsock1.SendData "MAIL FROM: " & UserMail & vbCrLf If Not WaitFor("250") Then GoTo 100 Winsock1.SendData "RCPT TO: " & MailRecipiant & vbCrLf If Not WaitFor("250") Then GoTo 100 Winsock1.SendData "DATA" & vbCrLf If Not WaitFor("354") Then GoTo 100 Winsock1.SendData MailBody & vbCrLf & "." & vbCrLf If Not WaitFor("250") Then GoTo 100 Winsock1.SendData "QUIT" & vbCrLf If Not WaitFor("221") Then GoTo 100 Label1 = "Message sent" GoTo 200 100 Label1 = SockData 200 Winsock1.Close End Sub Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long) Winsock1.GetData SockData End Sub Private Sub Winsock1_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean) Label1 = "Error: " & Description SockData = "Error" Winsock1.Close End Sub Private Function WaitFor(SockResponse As String) As Boolean Do While Left(SockData, 3) <> SockResponse And Left(SockData, 3) <> "220" And Left(SockData, 3) <> "250" DoEvents If Left(SockData, 3) > "400" Then Exit Function Loop WaitFor = 1 SockData = "" End Function
530 5.7.0 Must issue a STARTTLS command first. f42sm2188083rvb.3
Thanks in advance! Oh and by the way.. first post! Woohoo!![]()




Reply With Quote