Creating a simple email form content using Asp.net
The article is about asp.net postback feature for email form content. You should have a form with theattribute and server controls.
Initially your button server control should have the attribute OnClick. The OnClick value will be alike to the Sub control that sends the email. The value selected for OnClick attribute is is. In coding part at the top of the page import the right Namespace in order that the right classes will load with the page.
Themust follow the selection and have the same name be supposed to start in this way:
After that we define the total message as one variable
Also in support of all line the message start should be named
with the variables followed by
Here is the code that works and its description for your clear and perfect understanding.
Here the call on variable is included for your understanding.
Now you can start to put the codes together.
vbcrlf is to create a new line in the email. Text should be added inside the quotation marks and a space between the text and & and also space at the start of vbcrlf code.This makes as one absolute line in your email message.
Next line of code is to display the text and the value of the item from the form. It should be separated by spaces and the item is listed in “contactname” Text from the form.
In the place of Text, it has .SelectedValue code. This takes the place of the .Text as soon as you have a multiple choice or drop-down server control selection, in the case of a group of radio buttons. This helps in identifying the selected value from that group.
Additional Tip: We have another case and it has .SelectedIndex. It gives a number as a replacement for value. If we have a list of four possible selection, and chosen the second one, the .SelectedIndex will return the number 2 instead of the text for that selection. This will be helpful if you are querying a database.
This piece of code adds few more variables. The System.Web.Mail class imported into the file should be proficient to identify them correctly.
« add your email address, I have added an example.
« email address can be specified in quotes or can be included with the declaration for the server control which passes along the address.
« your smtp server address. You have this to send the message.
« tells the Sub to send the message.
A redirect can be done to another page, which tells the form mailer was a success before you end the Sub:
and of course, you have to end the Sub properly:
Now you can send a email form content using asp.net. Hope this article would have given a better idea.
Write us about your comments and feedback.