WEB-DESIGN-Co.Com - How to programatically send an email through ASP.NET 2.0 and C#
Web Design Co
 
WEB DESIGN Co
 
 
 
 
 
 
 
 
 
 
Royal Vegas Casino

How to programatically send an email through ASP.NET 2.0 and C#
By: ANDRE SHOWAIRY

There are several ways to programatically send an email from a given web site. It depends on what platform and what language you are using.

I am not going to describe in this article what should be done in Java or PHP; I will try to do reserve each language an article.

This code shows the code behind a push button that could could be added to a form of type aspx. Just add a push button; label it with the wanted description like "Send message now"; double-click the button; and finally, copy and paste this code to the click event handler of the push button. Surely, the aspx form should have some text boxes, radio buttons, check boxes, combo boxes, lists, and labels asking the user to fill them out. Do not forget the validition control that would help a lot in filtering the wrong imput.

protected bool SendMessageAsEmail()
{
bool RetVal = true;
MailMessage objEmail = new MailMessage();
objEmail.To.Add("toemail@somewebsite.com");
objEmail.From = new MailAddress("fromemail@somewebsite.com");
objEmail.Subject = "Message from a visitor";
objEmail.Body = "this is the body of the message";
objEmail.Priority = MailPriority.High; // if you want to change the priority; else, remove this line


try
{
SmtpClient smtp = new SmtpClient("mailserver.com");
smtp.Port = 5544; // if port has a specific value; else, remove this line
smtp.EnableSsl = false;
smtp.Credentials = new NetworkCredential("emailAccountName", "emailAccountPassword");
smtp.Send(objEmail);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
RetVal = false;
}
return RetVal;
}

Written by Andre Showairy
Computer Scientist since 1991.
In programming since 1991.
In C++ programming since 1993.
Long experience in VB, C#, VB.NET, ASP.NET, and ADO.NET.
Founder and owner of IT Images - http://www.imagesti.com



5 Steps To Ensuring Your Website Is Secure


Anyone who is doing business over the internet needs to have secure web hosting. There are many security threats, and anytime you're dealing with customer data you need to be sure it's safe from prying eyes. This is especially true if you're using a shared host, where multiple websites are hosted on a single server. If you're considering shared hosting for your business website, check with your hosting company to find out what kind of security they use on their systems.. . .



 


Return to Web-Design-Co's Web Design Index


 

Royal Vegas Casino
free-traffic.info - Get-Paid-More.Net - Traffic Exchange - Travel-A-Z - Dating-A-Z - Get Free Traffic

Casino Italiano - Golden Palace Casino - Online Casino - Casino King - Magic Box Casino - Spin Palace Casino - Roxy Palace Casino - Casino Splendido -

Las Vegas Casino - Video Poker Classic Casino - Blackjack club Casino - Slots Express Casino - City Club Casino - Platinum Play Casino - Sizzling Slots Casino

Commodore Casino -

 
poker time
 
webmasterquest.com free website traffic

Copyright Web-Design-co.com 2002- 2007