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

send e-mail using winsock

P: 36
hi for every one

i have program use to send e-mil using winsock and i try to send e-mail from this program but i failure

i write the code of program in here and i want to help me to solve this problem :

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 = "19.154.0.20"
  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: " & "C-RHQ" & vbCrLf)
  17.     wsk.SendData ("rcpt to: " & "xxx@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
please help me to solve this problem

Question:
can i attach the program in here ?

thank you .
Mar 20 '07 #1
Share this Question
Share on Google+
1 Reply


100+
P: 149
hi for every one

i have program use to send e-mil using winsock and i try to send e-mail from this program but i failure

i write the code of program in here and i want to help me to solve this problem :

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 = "19.154.0.20"
  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: " & "C-RHQ" & vbCrLf)
  17.     wsk.SendData ("rcpt to: " & "xxx@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
please help me to solve this problem

Question:
can i attach the program in here ?

thank you .
Hi ,

Look at this sample code .

http://www.vbip.com/winsock/winsock_simple_sender.asp

There is a sample program that you can download to see hoe this works.

thanks
ansuman sahu
Mar 20 '07 #2

Post your reply

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