Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

E-mail using winsock

Posted on 1998-12-28
2
Medium Priority
?
352 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

610 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