borderAndreaVB free resources for Visual Basic developersborder
borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2016 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (Bulk Sms Gateway)Next Topic (Outlook 2010/ Cannot open e-mail folders) New Topic New Poll Post Reply
AndreaVB Forum : Internet Applications : Sending an email with Winsock
Poster Message
ash11001
Level: Trainee

Registered: 07-04-2007
Posts: 1

icon Sending an email with Winsock

Hi all, I have some code I've written that should log into a specified SMTP server on port 25 and send an email, but it won't work, and I can't seem to figure out why. Any help is much appreciated.


Private Sub cmdSend_Click()


'grab everything after the "@" for the HELO command
Dim sym As Integer 'for holding the position of the "@" SYMbol
Dim total As Integer
Dim calc As Integer
Dim smtp As String



sym = InStr(txtSMTP.Text, "@")
total = Len(txtSMTP.Text)
calc = total - sym

smtp = Mid$(txtSMTP.Text, sym + 1, calc)

wskEmail.Close 'just in case it was left open for some reason, reset it before connect
wskEmail.Connect txtSMTP.Text, 25


Do While wskEmail.State <> sckConnected 'wait until we
DoEvents                                'are connected to
Loop                                    'send the email


'gotta use vbcr, not vbcrlf....or it won't work...
wskEmail.SendData "HELO " & smtp & vbCr
wskEmail.SendData "Mail from: " & txtFrom.Text & vbCr
wskEmail.SendData "Rcpt to: " & txtTo.Text & vbCr
wskEmail.SendData "data" & vbCr
wskEmail.SendData "Subject: " & txtSubj.Text & vbCr
wskEmail.SendData txtMsg.Text & vbCr
wskEmail.SendData "." & vbCr
wskEmail.SendData "quit" & vbCr
wskEmail.Close

MsgBox "Done"

End Sub

07-04-2007 at 11:43 PM
View Profile Send Email to User Show All Posts | Quote Reply
goldsmith
Level: Trainee

Registered: 02-02-2015
Posts: 1
icon Re: Sending an email with Winsock

this is very nice post

____________________________
Nawaz

02-02-2015 at 04:25 AM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : Internet Applications : Sending an email with Winsock
Previous Topic (Bulk Sms Gateway)Next Topic (Outlook 2010/ Cannot open e-mail folders) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
borderAndreaVB free resources for Visual Basic developersborder
borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2016 Andrea Tincaniborder