Send email from vb.net

bunze

Well-known member
Joined
Aug 4, 2005
Messages
52
Location
Adirolf
Programming Experience
1-3
I want to click my SendButton and send the text from a textbox to my email account.

It is a GMail account. How would I do this?
 
There are many ways to send emails from VB .Net. But I think the most independent one, though not the easiest, is using Socket (winsock). Commonly, the recipient address does not matter much here. But for the sender, you have to have access to the smtp server. In your case, if you're using your Gmail account to to send email from VB .Net that would be very difficult if not impossible. Better user you company mail (and such).

Hope this link helps:
http://www.vbcity.com/forums/topic.asp?tid=20413&highlight=mail|using|socket
 
every ISP (i've looked up a lot but i'm not actually saying that everyone does) allows you to use their smtp to send email
 
My only response is, if you can't code something yourself then maybe programming isn't for you. I don't mean to be rude, that's not my intention -- but if you use someones code for one project, you'll think you can get away with using someone's code for all other projects too.

But I don't want to be a complainer that can't offer any help. Basically what you want to do is figure out how to use the System.Net.Sockets.Socket class and look up the protocol specifications on SMTP. That's the hard way. I'm sure, with some research, there are classes/components that are already designed to do this that can be easily found.

With that said, many ISPs do not authenticate for outgoing (SMTP) mail -- especially the local ones (the ones that just serve local areas). Most free email providers (Hotmail, Yahoo, gMail) and nationwide ISPs authenticate to keep traffic down to a minimum.

If it helps at all, there is one I can give you that's local to my area that last I knew didn't authenticate. smtp.ramcell.net
 
I dissagree with the previous poster. By looking at another persons code, you can learn new ways to program. I am a mostly self taught VB.Net programer. I have learned through trial and error, looking stuff up on the internet, and generally working through most problems on my own. For me, I dont NEED this code in any of my programs, but it would be a fun thing to learn how to do.

This site I thought was meant to help people learn how to use the functions of .Net and connect people with those willing to help them. By saying you need to code it yourself, it seems to me you are defeating the purpose of this site.

I am sure the code in the link would work, but I dont really know much about email programs, or how they send emails, or any of that, but, if I could see a way that the code was implemented, it would answer many questions for me. It is not that you are writing my code for me, it is that you are helping another person understand how the code is written. Once I see how the code is written, I can go through it step by step and learn how each part works together, and when I see something that doesnt make sence to me, I can look it up. But I cant go through it step by step, if I am missing part of the equation.

I dont mean to cause offense, and if I have, I will gladdly erase this post, but what I was trying to say is that I am interested by this post, and would also like to learn how to do this, but was confused by the code in the other post.
 
Point taken. While this is a good place to share .NET, it's classes, and overall VB.NET functionality -- it isn't a code vault either. I'm not the administrator of this website, so the previous sentence is my initial understanding. I mean, if you want code examples there are sites for this. If you want help with your existing code then this is the place to get it. To me, that seems to be the purpose of this forum.

No offense was taken from you. I understand where you are coming from but it also sounds like you expect this forum to be a place that was designed to be nothing like planet-source-code.com, for example. There are lots of sites like that, but few good forums like this. Especially geared specifically for VB.NET discussion.

As for how sending email works:

SMTP is command driven. In fact, you can start a Telnet session with an SMTP server and communicate with it. By knowing the commands to the SMTP protocol you can use Telnet or "automate" the process with your program code to compose and send an email message.

With a 5 second google search, I was able to locate a site that lists the SMTP commands: http://www.networksorcery.com/enp/protocol/smtp.htm

Each command is sent as a String followed by a CrLf (carriage-return, line-feed) character. Ergo, ("RCPT someuser@someemail.net" & vbCrLf)

In my earlier post, I stated that learning the System.Net.Sockets.Socket (winsock) class would be the first step to accomplishing this task. This can be learned by reading tutorials (the best way) or picking apart code examples (if that works for you, but many are sloppy and poorly written). Once you learn that, you will know how to apply SMTP commands in your own session with an SMTP server.

I hope that answers any and all questions on the subject. Further questions are welcome :)
 
You should look at Microsoft's 101 Code Samples, which also contains a example of how to create a program that can send e-mails.

Look at www.msdn.com, under most popular developer downloads.
 
Back
Top