Click to See Complete Forum and Search --> : .NET 2.0 MailMessage - probably a dumb question..
jenbuh
01-15-2009, 05:49 PM
Let me just preface by saying that I recently learned ASP (not .NET) in a college class I took and then decided to develop my own webpage. Little did I know that .NET is now the standard.
Anyway, I converted my html form over to .NET so that I could take advantage of the e-mailing feature.
I've found a lot of information on how to use this but can't seem to find one simple detail.
All documentation says: "Create a MailMessage object and assign its properties."
How and WHERE do I do this?
chazzy
01-15-2009, 06:47 PM
in your backing page. you should have a .cs or .vb file for the page.
jenbuh
01-15-2009, 07:10 PM
How do I create the object?
debiguana
01-16-2009, 01:20 AM
First off, if your college is still teaching Classic ASP, they're *WAY* behind the times... They have in all likelihood taught you things which you will now have to un-learn.
As far as how to send the email,
This article (http://aspnet.4guysfromrolla.com/articles/072606-1.aspx) does a great job of showing you how to do it.
As far as the other side of things (learning .NET), 4guysfromrolla.com is a very good resource, and are other areas (and the MSDN documentation is actually one of the best resources as well). I would also recommend picking up a copy of "ASP.Net 2.0 with C# 2005" (Murach) - it will help you make the transition quickly (it did for me with moving from the PHP/Unix world to .NET)
Hope this helps!
-Doug
mayanksrmcem
01-16-2009, 04:31 AM
you can try an other link to look some code example for sending e-mails...
the link is as follows...
http://www.aspnettutorials.com/tutorials/email/
thanks
ryanbutler
01-16-2009, 10:40 AM
As far as creating the object, C# would look like:
MailMessage mailMsg=new MailMessage();
The constructor takes four parameters/arguments by default, I usually use the first two parameters and go from there ,like so:
MailMessage mailMsg=new MailMessage(EmailTB.Text, "myemail@domain.com");
mailMsg.Subject="BLah";
mailMsg.Body="Something";
SmtpClient smtp=new SmtpClient();
smtp.Send(mailMsg);
If I'd quit being lazy, I'd write an article on this for webreference.com.