VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



a The easiest way to send mail

by Dustin Davis (17 Submissions)
Category: Custom Controls/Forms/Menus
Compatability: Visual Basic 3.0
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating: (14 Votes)

I have seen some e-mail stuff on this site, but all are so freakin complicated. This is simple and VERY easy to use!

Rate a The easiest way to send mail

Dim sRes As String
Private Sub Command1_Click()
Winsock1.RemotePort = 25
Winsock1.RemoteHost = your_mail_server_here 'use your mail server
Winsock1.Connect
Do Until Winsock1.State = 7 '7=connected
  DoEvents
Loop
sRes = "0"
Winsock1.SendData "MAIL FROM: " & your_email_here & vbCrLf
Do Until sRes = "250"
  DoEvents
Loop
sRes = "0"
Winsock1.SendData "RCPT TO: " & someone_email_here & vbCrLf
Do Until sRes = "250"
  DoEvents
Loop
sRes = "0"
Winsock1.SendData "DATA" & vbCrLf
Do Until sRes = "354"
  DoEvents
Loop
Winsock1.SendData "FROM: " & your_name_here & vbCrLf
Winsock1.SendData "SUBJECT: " & subject_here & vbCrLf
Winsock1.SendData Text1.Text & vbCrLf & "." & vbCrLf
Do Until sRes = "250"
  DoEvents
Loop
Winsock1.Close
MsgBox "Mail sent!"
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim Data As String
Dim Length As Long
Winsock1.GetData Data
Length = Len(Data)
sRes = Left$(Data, 3)
End Sub

Download this snippet    Add to My Saved Code

a The easiest way to send mail Comments

No comments have been posted about a The easiest way to send mail. Why not be the first to post a comment about a The easiest way to send mail.

Post your comment

Subject:
Message:
0/1000 characters