Valhalla Legends Archive

Programming => General Programming => Visual Basic Programming => Topic started by: QwertyMonster on July 08, 2005, 01:33 PM

Title: Sending an email..
Post by: QwertyMonster on July 08, 2005, 01:33 PM
   
  ' need SMTP server to route message thru, 25 (SMTP)
  Winsock1.Connect "smtp.freeserve.net", 25
   


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?
Title: Re: Sending an email..
Post by: R.a.B.B.i.T on July 08, 2005, 02:31 PM
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.
Title: Re: Sending an email..
Post by: QwertyMonster on July 08, 2005, 03:20 PM
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!
Title: Re: Sending an email..
Post by: UserLoser. on July 08, 2005, 03:57 PM
That address works fine... just tested and it sent me:

220 cmailm1.svr.pol.co.uk ESMTP Exim 4.41 Fri, 08 Jul 2005 21:57:25 +0100
Title: Re: Sending an email..
Post by: QwertyMonster on July 08, 2005, 04:08 PM
some more problems, connects and everything but i dont receive email.

heres my 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
Title: Re: Sending an email..
Post by: Newby on July 08, 2005, 04:21 PM
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.
Title: Re: Sending an email..
Post by: QwertyMonster on July 08, 2005, 04:23 PM
Well it doesn't crash anymore. But still no email. Any ideas people?
Title: Re: Sending an email..
Post by: Newby on July 08, 2005, 04:59 PM
I don't know much about SMTP, but is there a message you're supposed to send when you're done with DATA?
Title: Re: Sending an email..
Post by: Mangix on July 08, 2005, 05:18 PM
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.
Title: Re: Sending an email..
Post by: UserLoser. on July 08, 2005, 07:29 PM
Maybe that mail server requires authentication?
Title: Re: Sending an email..
Post by: R.a.B.B.i.T on July 08, 2005, 10:05 PM
554 SMTP synchronization error

You're not allowed to send mail.

More info: http://www.networksorcery.com/enp/protocol/smtp.htm
Title: Re: Sending an email..
Post by: QwertyMonster on July 09, 2005, 05:03 AM
554: Transaction failed.

Thanks for that website Rabbit. :) It helps. I will post when i get more problems :)
Title: Re: Sending an email..
Post by: MyndFyre on July 09, 2005, 09:55 AM
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.
Title: Re: Sending an email..
Post by: QwertyMonster on July 09, 2005, 12:07 PM
Im i got confused in the sloppy coding so im restarting. What is the easiest way to send an email? Thanks in advance!
Title: Re: Sending an email..
Post by: Newby on July 09, 2005, 12:33 PM
Quote from: QwertyMonster on July 09, 2005, 12:07 PM
Im i got confused in the sloppy coding so im restarting. What is the easiest way to send an email? Thanks in advance!

SMTP server!
Title: Re: Sending an email..
Post by: MyndFyre on July 09, 2005, 06:58 PM
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 (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cdo/html/_denali_newmail_object_cdonts_library_.asp) object:


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

mailObj.To = "[email protected]"
mailObj.From = "[email protected]"
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
Title: Re: Sending an email..
Post by: QwertyMonster on July 10, 2005, 07:43 AM
Ah i will look into CDONTS. Thanks MyndFyre.
Title: Re: Sending an email..
Post by: R.a.B.B.i.T on July 10, 2005, 10:26 AM
Just stick with telnet, it's more fun :)