phreaky Posted December 13, 2002 Posted December 13, 2002 How can I send a simple string by using an SMTP server to an especific email address?, what's the code necessary?. Quote tHe pHrEaKy
*Gurus* divil Posted December 13, 2002 *Gurus* Posted December 13, 2002 Connect via a Socket class, then you'll need to have the following conversation with the SMTP server (port 25): < 220 Ready > MAIL FROM:myemail@mydomain.com < 250 Sender ok > RCPT TO:recipient@domain.com < 250 Recipient ok > DATA < 354 Ok Send data ending with <CRLF>.<CRLF> > sample email line! > . < 250 Ok, sent > QUIT < 221 I suggest you read the SMTP RFC for more information on the protocol. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
phreaky Posted December 13, 2002 Author Posted December 13, 2002 Many thanks for your answer, could you specify me more (or give any link) about the socket class connection, I'm really newbie to that. Thanks again. In fact, what I seem in your code is that it's very like a TELNET sending of an email, but, what I really don't know is how to make that code to function automatized by VB application. Quote tHe pHrEaKy
*Gurus* divil Posted December 13, 2002 *Gurus* Posted December 13, 2002 Yes, it's a TCP connection just like a telnet one. There are .NET classes under System.Web.Mail but you said you wanted to send one directly using an SMTP server so I assumed you wanted to do it manually. There are examples of using the Socket class in the documentation and samples in the SDK. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
phreaky Posted December 13, 2002 Author Posted December 13, 2002 Well, actually I think that manually is the best way, here it is what I need to do: I need to send through an email just one string, but, I need to do it automatized way, what I will send and where I'm going to send it are constants, so, I don't need to enter them ("to" and "data") every time it will be sent. Now, you tell me, what's the best for me?, maybe I could use System.Web.Mail class, in fact, it sounds much more easier for what I need, but using this class I can set the target (TO) and the content (DATA) and send it without disturbing my user (of the application)?. :) Quote tHe pHrEaKy
*Gurus* Derek Stone Posted December 13, 2002 *Gurus* Posted December 13, 2002 As long as you have access to a SMTP server then System.Web.Mail will do all that you need. Quote Posting Guidelines
phreaky Posted December 13, 2002 Author Posted December 13, 2002 Well, could you give the link to the explanation on how to use those? Quote tHe pHrEaKy
phreaky Posted December 16, 2002 Author Posted December 16, 2002 As long as you have access to a SMTP server then System.Web.Mail will do all that you need. Ok, I got my SMTP server, in fact, mi ISP gives me SMTP server completely free and with no restrictions, now, how do I do it? :( Quote tHe pHrEaKy
*Gurus* divil Posted December 16, 2002 *Gurus* Posted December 16, 2002 Straight from the help: Dim from As String = "from@microsoft.com" Dim mailto As String = "to@microsoft.com" Dim subject As String = "UtilMailMessage001" Dim body As String = "<html><body>UtilMailMessage001 - success</body></html>" SmtpMail.Send(from, mailto, subject, body) string from = "from@microsoft.com"; string to = "to@microsoft.com"; string subject = "UtilMailMessage001"; string body = "<html><body>UtilMailMessage001 - success</body></html>"; SmtpMail.Send(from, to, subject, body); Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
*Gurus* Derek Stone Posted December 16, 2002 *Gurus* Posted December 16, 2002 [mshelp]ms-help://MS.VSCC/MS.MSDNVS/cpref/html/frlrfSystemWebMail.htm[/mshelp] Quote Posting Guidelines
phreaky Posted December 18, 2002 Author Posted December 18, 2002 Well, the code that divil gave me didn't work, it doesn't recognizer SMTPMail.xxxxxx as a function or a class. In the other side, there's a weird thing that's happening, I read what Derek gaves to me, about the class System.Web.Mail.SMTP that appears on the help, but IT DOESN'T RECOGNIZES this one either!, I mean, when a start typing System, the VB suggest diferent kinds of options of sub divisions of the class System (as usual), but there's no subdivision Web and of course none of the others sub of the sub, anyway, I installed it complete!, so, I really dunno why is that happening. Any clue? Quote tHe pHrEaKy
*Experts* Volte Posted December 18, 2002 *Experts* Posted December 18, 2002 OK, first this you have to do is go to the 'Project' menu and click 'Add Reference'. Find 'System.Web.dll' in the list of references, and double click it, then click OK. Then the code will work. Dim m As System.Web.Mail.SmtpMail Dim sFrom, sTo, sSubject, sMessage As String sFrom = "email@mail.com" sTo = "email@mail.com" sSubject = "This is a test" sMessage = "Blah blah blah" m.Send(sFrom, sTo, sSubject, sMessage) Quote
phreaky Posted December 18, 2002 Author Posted December 18, 2002 MANY, MANY THANKS!. It worked perfectly adding the reference library. Quote tHe pHrEaKy
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.