?
Solved

E-mail using winsock

Posted on 1998-12-28
2
Medium Priority
?
349 Views
Last Modified: 2013-12-25
I want to send e-mail using VB 5.0
The expert, mysqlG has said:

Using VB and assuming the computer you run it from
   has internet access.  Its a very simple thing using
   the SMTP and winsck.ocx.
   From memory its as easy as.
   add a winsock control to the form
   set it up using your mail server and set it to       tcpprotocol (0)
   and port 25..
   then connect
   and:

   Winsock1.SendData "HELO your.mail.server" & vbCrLf
   Winsock1.SendData "mail from: youremail" & vbCrLf
   Winsock1.SendData "RCPT To:" & whoeverinvar & vbCrLf
   Winsock1.SendData "data" & vbCrLf
   Winsock1.SendData "the text you wanna send" & vbCrLf
   Winsock1.SendData vbCrLf & "." & vbCrLf
   its that simple..

------------------------------------------
I try this , but I can't do it.
I will appreciate if the expert can send me the source sample Or give me the more suggestion.
Please E-mail to huangxb@usa.net
0
Comment
Question by:huangxb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 

Accepted Solution

by:
jmnolan earned 100 total points
ID: 1498578
well..  I see a small problem with that code. First of all is the problem with conecting to port 25 or does it connect and just not work? That code is correct except that this line:

Winsock1.SendData "RCPT To:" & whoeverinvar & vbCrLf

should read:

Winsock1.SendData "RCPT To:<" & whoeverinvar & ">" & vbCrLf
(add angle-brackets around the address)

you should also send this when you are done:

Winsock1.SendData "quit" & vbCrLf

0
 

Author Comment

by:huangxb
ID: 1498579
I have not successed following the suggestion of the expert, jmnolan
Please give me more suggestion or send me a sample
Thanks.

-----------------------------------------

Situation:
      Mail host:    mail.csair.com   Microsoft Exchange server 5.5
      User E-mail address:   huangxb@csair.com
      PC:   win95
The following is my VB5.0 program, It can connect to the port 25 of
the remote mail host( mail.csair.com) and send all the data


Dim blnCompleted As Boolean

Private Sub cmdExit_Click()
Unload Me
End Sub

Private Sub cmdSend_Click()
Dim i As Long
Dim e
Dim whoeverinvar As String
blnCompleted = False
If cmdSend.Caption = "Send" Then
  cmdSend.Caption = "Stop"
  cmdExit.Enabled = False
Else
  blnStop = True
  Exit Sub
End If
blnStop = False

If Winsock1.State <> sckClosed Then
  Winsock1.Close
End If
If Winsock1.State = 0 Then
   Winsock1.Connect
End If

Text1.Text = "Connecting remote host"
Do While Winsock1.State <> sckConnected
  e = DoEvents
  If blnStop = True Then
     If Winsock1.State <> sckClosed Then
        Winsock1.Close
     End If
     Text1 = "Connection has been stoped"
     cmdSend.Caption = "OK"
     cmdExit.Enabled = True
     Exit Sub
  End If
Loop
Text1 = "Remote host connected"

   whoeverinvar = "huangxb@csair.com"
   Winsock1.SendData "HELO mail.csair.com" & vbCrLf
   Winsock1.SendData "mail from:huangxb@csair.com" & vbCrLf
   'Winsock1.SendData "RCPT To:huangxb@csair.com" & whoeverinvar & vbCrLf
   Winsock1.SendData "RCPT To:<" & whoeverinvar & ">" & vbCrLf
   'Winsock1.SendData "RCPT To:<huangxb@csair.com>" & vbCrLf
   Winsock1.SendData "data" & vbCrLf
   Winsock1.SendData "the text you wanna send " & vbCrLf
   Winsock1.SendData vbCrLf & "." & vbCrLf
   Winsock1.SendData "quit" & vbCrLf
Do While blnCompleted = False
  e = DoEvents
  If blnStop = True Then
     Text1 = "Stoped"
     Winsock1.Close
    cmdOK.Caption = "Send"
    cmdExit.Enabled = True
    Exit Sub
  End If
Loop
Winsock1.Close
Text1 = "Closed"
cmdSend.Caption = "Send"
cmdExit.Enabled = True
MsgBox "OK"
End Sub

Private Sub Winsock1_SendComplete()
blnCompleted = True
End Sub

0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month14 days, 13 hours left to enroll

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question