Sending email

juggernot

Well-known member
Joined
Sep 28, 2006
Messages
173
Programming Experience
Beginner
I'd like to know how to send email in vb.net. In the program I'm working on, the user inputs his email when he registers, then if he forgets his password he can type his username and get the password sent back to him.
 
Are there any constraints of your environment? Would you be sending emails only to uses on your local network? Does that network run a POP or Exchange mail server?
 
There's nothing in the System.Net.Mail namespace that restricts you to a local network. As long as you have a valid SMTP server to reference there is no issue. Have you followed the link I provided? Have you followed the links on that page to related topics, like the SmtpServer class?
 
sorry, but could I get a code example of how you would set up the smpt class and send an email. I know I should try it out first, and I have, but I seem to be having troubles.
 
I would also like to see an example b/c I am kinda lost with this. I have a question though. With a SMTP server; will a POP mail account be the what you are talking about or is this totally different? For example; if I setup to send an e-mail could I just program my e-mail account credentials?
 
Great link John. Why didn't I think of that? ;) Juggernot, the code on that page is C# but don't assume that that's no use and ignore it. LOOK at the code and try to understand what it's doing. The majority of the lines of C# code simply require the semicolon to be removed and they are VB code. The ones that need more are mostly just declarations. There are also plenty of free code converters available on the Web.
 
I would also like to see an example b/c I am kinda lost with this. I have a question though. With a SMTP server; will a POP mail account be the what you are talking about or is this totally different? For example; if I setup to send an e-mail could I just program my e-mail account credentials?
SMTP is the protocol used to send e-mail, while POP3 is the protocol used to retrieve it. n When you set up an e-mail account in Outlook or whatever you have to specify an SMTP server and a POP3 server, remember? You can send e-mail using your current e-mail address by specifying that as the From address and specifying your ISP's SMTP server address, which you can get from your current e-mail client. .NET supports sending e-mail via SMTP but it has no explicit support for retrieving it via POP3. I have seen free third-party componentson the Web that support POP3 if you want to build a full e-mail client. Microsoft rightly consider sending e-mail as a much more common requirement of an application than receiveing it, which is normally the domain of dedicated e-mail clients.
 
Great link John. Why didn't I think of that?
Yes, the MSDN documentation is very great, but I noticed this topic was only C# just after I posted and changed it to some site with VB.Net code also. systemnetmail.com (and systemwebmail.com) are also good resources for using and getting out of trouble when using the mail namespaces.
 
O, thanks jmcilhinney. I don't mind recieving it. For what I need using MS Outlook or going to Y! to check it will be fine I was just wondering how to send it. So if that is what does it I am golden. I thought i tried this in the past and failed but soon I will be trying it again. Thanks again :)
 
k, fixed it. I just needed to add a reference. onto the next problem.

Additional information: Could not access 'CDO.Message' object.
it highlight the code:

SmtpMail.Send(mail)

any ideas?
 
juggernot, don't use system.web.mail in .Net 2.0, system.net.mail is the replacement.
 
Back
Top