3

Is it possible to send an e-mail using the VS2010 development server? If that's possible, can someone point me to a sample the web?

I'd like to send an e-mail to the person who register so to keep a proof that we (yes or not) received his request. The e-mail will contains a few pertinent info, such as the name, time, and son on.

EDIT

At my work, we collect data and to whoever needs as long as the ministry we work for tells as to do so. After we receive the paper form, we write an e-mail to the form sender. Until now, we use a paper form to know who needs data. I'd like to put that form online and also be able to generate an e-mail to the sender of the request. So, since I'm still developing the application, I need to test how sending the e-mail will work. That's why I'm asking if I can send an e-mail, for instance, to my Yahoo account from my laptop using VS2008 web development server.

I remember, 2 years ago, while learning HTML with DreamWeaver, we where able to send e-mail and received them in our Yahoo e-mail accounts (without any special configuration).

Thanks for helping

MPelletier
  • 16,256
  • 15
  • 86
  • 137
Richard77
  • 20,343
  • 46
  • 150
  • 252
  • Not sure I understand what you are trying to do... Can you explain a bit more? – NinjaCat Aug 05 '10 at 13:36
  • @NinjaCat: Thanks for the remark. Look then the EDIT of the post above – Richard77 Aug 05 '10 at 13:56
  • So what you are trying to know is how to get your app to be able to send an email out when someone fills out a form on your site/your application? – NinjaCat Aug 05 '10 at 17:28
  • @NinjaCat: I know that'll be feasable and I've seen many samples on that matter online. Hoewver, no where it said that I can obtain that functionality using VS2010's development server. That why I'd like to know if I can send an e-mail know that I'm still writing the application. If that's the case, then how to do so. – Richard77 Aug 06 '10 at 09:39

2 Answers2

3

The web server won't make a difference. Whether you can will depend on the environment your server is in.

The simplest option is to use .NET's built-in email classes. You're probably using .NET 3.5 so that's System.Net.Mail, e.g.

MailMessage message = new MailMessage()
                       {
                         From = new MailAddress("you@youraddress", "Your Name"),
                         Subject = "The subject",
                         Body = @"Simple text body; set IsBodyHtml for HTML"
                       };
message.To.Add(new MailAddress("first@recipient.address", "First recipient - can add more"));
SmtpClient smtpClient = new SmtpClient("your.smtp.server");
smtpClient.Send(message);

If you don't specify an SMTP server name in the constructor it will read it from web.config.

If you don't have access to an SMTP server but do have permission to use external web services then you could use something like http://postmarkapp.com/ - I've seen other questions about them here but haven't used them myself.

Rup
  • 33,765
  • 9
  • 83
  • 112
3

Not answering straight to the question, but:

If testing the emails sent when running on a development server is the purpose, a simple SMTP stub server like smtp4dev is a good alternative?

Touko
  • 11,359
  • 16
  • 75
  • 105