By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,327 Members | 2,661 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,327 IT Pros & Developers. It's quick & easy.

Trying to send e-mail via Winsock control, state remains CLOSED

P: 36
hi for every one

i have program using to send e-mail

i enter all information to this program put i can not sending from it

please if any one can help me i waiting

note : i write the source code :

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2. cdInsertFile.ShowOpen
  3. txtInsertFile.Text = "c:\ReadMe.txt"
  4.  
  5.  
  6.     wsk.Protocol = sckTCPProtocol
  7.     wsk.RemoteHost = "10.00.11.11"
  8.     wsk.RemotePort = 25
  9.     wsk.Connect
  10.  
  11.     Do
  12.         DoEvents
  13.     Loop Until wsk.State = 7
  14.  
  15.     wsk.SendData ("hello flashmail" + vbCrLf)
  16.     wsk.SendData ("MAIL FROM: " & "xyx-00@hotmail.com" & vbCrLf)
  17.     wsk.SendData ("rcpt to: " & "mas490@gmail.com" & vbCrLf)
  18.     wsk.SendData ("data" & vbCrLf)
  19.     wsk.SendData ("Subject: " & "Attach file" & vbCrLf)
  20.     wsk.SendData ("read this file " & vbCrLf)
  21.     wsk.SendData ("." & vbCrLf)
  22.     wsk.SendData ("quit" & vbCrLf)
  23.     wsk.Close
  24.  
  25.  
  26.     Timer1.Interval = 1000
  27.  
  28. End Sub
  29.  
  30. Private Sub Timer1_Timer()
  31. Select Case wsk.State
  32.  
  33.     Case Is = 0: lblStat.Caption = "Closed"
  34.     Case Is = 1: lblStat.Caption = "Open"
  35.     Case Is = 2: lblStat.Caption = "Listening"
  36.     Case Is = 3: lblStat.Caption = "Connection pending"
  37.     Case Is = 4: lblStat.Caption = "Resolving host"
  38.     Case Is = 5: lblStat.Caption = "Host resolved"
  39.     Case Is = 6: lblStat.Caption = "Connecting"
  40.     Case Is = 7: lblStat.Caption = "Connected"
  41.     Case Is = 8: lblStat.Caption = "Peer is closing the connection"
  42.     Case Is = 9: lblStat.Caption = "Error"
  43.  
  44. End Select
  45.  
  46. End Sub
thank you
Apr 18 '07 #1
Share this Question
Share on Google+
3 Replies


100+
P: 149
hi for every one

i have program using to send e-mail

i enter all information to this program put i can not sending from it

please if any one can help me i waiting

note : i write the source code :

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2. cdInsertFile.ShowOpen
  3. txtInsertFile.Text = "c:\ReadMe.txt"
  4.  
  5.  
  6.     wsk.Protocol = sckTCPProtocol
  7.     wsk.RemoteHost = "10.00.11.11"
  8.     wsk.RemotePort = 25
  9.     wsk.Connect
  10.  
  11.     Do
  12.         DoEvents
  13.     Loop Until wsk.State = 7
  14.  
  15.     wsk.SendData ("hello flashmail" + vbCrLf)
  16.     wsk.SendData ("MAIL FROM: " & "xyx-00@hotmail.com" & vbCrLf)
  17.     wsk.SendData ("rcpt to: " & "mas490@gmail.com" & vbCrLf)
  18.     wsk.SendData ("data" & vbCrLf)
  19.     wsk.SendData ("Subject: " & "Attach file" & vbCrLf)
  20.     wsk.SendData ("read this file " & vbCrLf)
  21.     wsk.SendData ("." & vbCrLf)
  22.     wsk.SendData ("quit" & vbCrLf)
  23.     wsk.Close
  24.  
  25.  
  26.     Timer1.Interval = 1000
  27.  
  28. End Sub
  29.  
  30. Private Sub Timer1_Timer()
  31. Select Case wsk.State
  32.  
  33.     Case Is = 0: lblStat.Caption = "Closed"
  34.     Case Is = 1: lblStat.Caption = "Open"
  35.     Case Is = 2: lblStat.Caption = "Listening"
  36.     Case Is = 3: lblStat.Caption = "Connection pending"
  37.     Case Is = 4: lblStat.Caption = "Resolving host"
  38.     Case Is = 5: lblStat.Caption = "Host resolved"
  39.     Case Is = 6: lblStat.Caption = "Connecting"
  40.     Case Is = 7: lblStat.Caption = "Connected"
  41.     Case Is = 8: lblStat.Caption = "Peer is closing the connection"
  42.     Case Is = 9: lblStat.Caption = "Error"
  43.  
  44. End Select
  45.  
  46. End Sub
thank you

Are you running this program behind a firewall. What is the exact error that you are getting.

-ansuman sahu
Apr 18 '07 #2

P: 36
the problem is the winsock state is every time is close .

and i stop the firewall but i cant running .
Apr 18 '07 #3

Expert 5K+
P: 8,434
Just a note to let you know, I'm going to change the title of this thread, so it's more helpful for later searching.
Apr 19 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.