views:

38

answers:

1

Hello,

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

A: 

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("[email protected]", "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

related questions