Valhalla Legends Forums Archive | Visual Basic Programming | Sending an email..

AuthorMessageTime
QwertyMonster
  [code]
  ' need SMTP server to route message thru, 25 (SMTP)
  Winsock1.Connect "smtp.freeserve.net", 25
  [/code]

The email server isn't working. Any ideas on what i can put for connecting to a server to send an email, in visual basic?
July 8, 2005, 6:33 PM
R.a.B.B.i.T
It may not run on port 25.  If it's using TLS or some other form of secure stream, you'll need to connect to the proper port.
July 8, 2005, 7:31 PM
QwertyMonster
It is 25, i have been reading tutorials on it. Its sent via SMTP. Any ideas people? Or could somebody point me in another direction for what to connect to, to send an email? Thanks in advance!
July 8, 2005, 8:20 PM
UserLoser.
That address works fine... just tested and it sent me:
[pre]
220 cmailm1.svr.pol.co.uk ESMTP Exim 4.41 Fri, 08 Jul 2005 21:57:25 +0100
[/pre]
July 8, 2005, 8:57 PM
QwertyMonster
some more problems, connects and everything but i dont receive email.

heres my code

[code]
  sFrom$ = Me.frmemail.Text
  sTo$ = "<my email here>"
  sSubject$ = "testy"
  sMessage$ ="this is a test"
 
  ' need SMTP server to route message thru, 25 (SMTP)
  Winsock1.Connect "smtp.freeserve.net", 25
 
  Do While Winsock1.State <> sckConnected: DoEvents: Loop
 
 
  sendMsg "HELO " & "Peaches"
  sendMsg "MAIL FROM: <" & sFrom & ">"
  sendMsg "RCPT TO: <" & sTo & ">"
  sendMsg "DATA"
 

  m$ = m$ + "From: <" + sFrom + ">" + vbCrLf
  m$ = m$ + "To: <" + sTo + ">" + vbCrLf
  m$ = m$ + "Subject: " + sSubject$ + vbCrLf
  m$ = m$ + "Date: " + Format$(Now, "h:mm:ss") + vbCrLf
  m$ = m$ + "MIME-Version: 1.0" + vbCrLf
  m$ = m$ + "Content-Type: text/plain; charset=us-ascii" + vbCrLf + vbCrLf
 
  m$ = m$ + sMessage$ + vbCrLf + vbCrLf + "." + vbCrLf
 
  sendMsg m$ + "QUIT"
 
  Winsock1.Close
[/code]
July 8, 2005, 9:08 PM
Newby
Uh.

sendMsg m$
sendMsg "QUIT"

Try that instead of combining them.

I'd re-write all of that coding, personally.

It's sloppy as hell.
July 8, 2005, 9:21 PM
QwertyMonster
Well it doesn't crash anymore. But still no email. Any ideas people?
July 8, 2005, 9:23 PM
Newby
I don't know much about SMTP, but is there a message you're supposed to send when you're done with DATA?
July 8, 2005, 9:59 PM
Mangix
erm i just read something on winsockvb.com and it says that after you attempt to send it, the SMTP(or POP3) server replies with a number indicating what happened. perhaps you could get the number with the DataArrival sub to find out why it isnt sending?

then again im not familiar with SMTP servers.
July 8, 2005, 10:18 PM
UserLoser.
Maybe that mail server requires authentication?
July 9, 2005, 12:29 AM
R.a.B.B.i.T
554 SMTP synchronization error

You're not allowed to send mail.

More info: http://www.networksorcery.com/enp/protocol/smtp.htm
July 9, 2005, 3:05 AM
QwertyMonster
554: Transaction failed.

Thanks for that website Rabbit. :) It helps. I will post when i get more problems :)
July 9, 2005, 10:03 AM
Myndfyr
If you're on a Workstation- or Server-based machine with IIS and the SMTP virtual server, you can send mail through the local server via the object CDONTS.NewMail.
July 9, 2005, 2:55 PM
QwertyMonster
Im i got confused in the sloppy coding so im restarting. What is the easiest way to send an email? Thanks in advance!
July 9, 2005, 5:07 PM
Newby
[quote author=QwertyMonster link=topic=12146.msg119834#msg119834 date=1120928850]
Im i got confused in the sloppy coding so im restarting. What is the easiest way to send an email? Thanks in advance!
[/quote]

SMTP server!
July 9, 2005, 5:33 PM
Myndfyr
Assuming VB and that you're on a Windows NT Workstation- or Server-based system that has IIS and the SMTP Virtual Server installed, if you use the CDONTS.NewMail object:

[code]
Dim mailObj As CDONTS.NewMail
Set mailObj = CreateObject("CDONTS.NewMail")

mailObj.To = "MyndFyre@gmail.com"
mailObj.From = "Someone@Unimportant.net"
mailObj.Subject = "This is spam."
mailObj.Body = "This is a spam message from everyone who directly copied your code sample from vL."

mailObj.Send

Set mailObj = Nothing
[/code]
July 9, 2005, 11:58 PM
QwertyMonster
Ah i will look into CDONTS. Thanks MyndFyre.
July 10, 2005, 12:43 PM
R.a.B.B.i.T
Just stick with telnet, it's more fun :)
July 10, 2005, 3:26 PM

Search