Introduction
Well the purpose of the user control is quite simple. I have seen a series of
publications all over the net for sending Emails using ASP.Net. I would have
loved to find a user control that I could just drop on my page, enter minimum
required fields and have the control do the rest of it for me.
That's what I finally feel I achieved with this user control. Now you can judge
it and if you like it, you are free to use it, modify it.
Background
I tried to keep this as simple as possible but if you are trying to recreate
what I did, you will need some basic experience in AJAX Extensions. You will
obviously need to know what SMTP servers and ports mean.
The user control assumes that you will be adding this control on your website
and the sole purpose is to receive emails from visitors. So the control will be
using your credentials (email ID and password) to authenticate the sender of the
email. For this reason, I removed the capability to attach files to the email.
Note: I do not recommend allowing others to send emails from your site
using this user control. The change that need to be done to allow this is quite
simple but the implications are numerous and generally not advisable.
Using the code
To use this user control you will have to perform the following simple steps.
- Set up your project to use the control
- Register the user control on your web form
- Add the user control to your web form and configure it
- Set up your project to use the control
First step is to create a folder called 'Controls' in your website. Copy the included ".ascx" control to this folder. Also add the "AjaxControlToolkit.dll" file to the 'bin' directory to be able to use the validators.
- Register the user control on your web form
Then you need to add the reference to the User control on your page using the following piece of code:
<%@Register src="Controls/EmailControl.ascx"tagname="EmailControl"tagprefix="uc1"%>
- Add the use Control to your web form and configure it.
Join the conversation! Your thoughts help the community grow.