473,484 Members | 1,653 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

I want send Info on particular E-Mail ID when click on send button on form in ASP .Ne

1 New Member
I want send Info on particular E-Mail ID when click on send button on form in ASP .Net [in C#] .
Nov 29 '12 #1
2 3119
VanessaMeacham
31 New Member
HI ! i am not sure that it will help you perfectly but i tried for little-bit help you.

Expand|Select|Wrap|Line Numbers
  1. protected void SendMail()
  2. {
  3.     // Gmail Address from where you send the mail
  4.     var fromAddress = "Gmail@gmail.com";
  5.     // any address where the email will be sending
  6.     var toAddress = YourEmail.Text.ToString(); 
  7.     //Password of your gmail address
  8.     const string fromPassword = "Password";
  9.      // Passing the values and make a email formate to display
  10.     string subject = YourSubject.Text.ToString();
  11.     string body = "From: " + YourName.Text + "\n";
  12.     body += "Email: " + YourEmail.Text + "\n";
  13.     body += "Subject: " + YourSubject.Text + "\n";
  14.     body += "Question: \n" + Comments.Text + "\n";
  15.     // smtp settings
  16.     var smtp = new System.Net.Mail.SmtpClient();
  17.     {
  18.         smtp.Host = "smtp.gmail.com";
  19.         smtp.Port = 587;
  20.         smtp.EnableSsl = true;
  21.         smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
  22.         smtp.Credentials = new NetworkCredential(fromAddress, fromPassword);
  23.         smtp.Timeout = 20000;
  24.     }
  25.     // Passing values to smtp object
  26.     smtp.Send(fromAddress, toAddress, subject, body);
  27. }
  28.  
  29. protected void Button1_Click(object sender, EventArgs e)
  30. {
  31.     try
  32.     {
  33.         //here on button click what will done 
  34.         SendMail();
  35.         DisplayMessage.Text = "Your Comments after sending the mail";
  36.         DisplayMessage.Visible = true;
  37.         YourSubject.Text = "";
  38.         YourEmail.Text = "";
  39.         YourName.Text = "";
  40.         Comments.Text = "";
  41.     }
  42.     catch (Exception) { }
  43. }
Nov 29 '12 #2
Frinavale
9,735 Recognized Expert Moderator Expert
There is an insight here on Bytes titled: Quick Reference on how to send an email using .NET that will get you pointed in the right direction.


-Frinny
Dec 4 '12 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

9
3578
by: msnews.microsoft.com | last post by:
Hello! I'm Jim by asp How can show "abc" in textbox when click one botton?
5
3592
by: me | last post by:
I have a Class Library that contains a Form and several helper classes. A thread gets created that performs processing of data behind the scenes and the Form never gets displayed (it is for debug...
5
3869
by: Matt | last post by:
I want to write a generic clearForm function to clear the form when the user click CLEAR button. Here's my attempts, because I want to take care all html controls. I think I need to test if the...
5
2703
by: sifar | last post by:
Hi, This is my first post to this Group. A] I am trying to create a escalation page which will mail an escalation report of a faulty product. Items needed on Page: -----------------------
2
1777
by: subba_reddy | last post by:
Hi, I have iFrame and command button(webser control) in my aspx page, I want to populate the iframe with someohter page when I click on command button . - SUBBA
0
1072
by: jags_32 | last post by:
We are trying to automate notification by email when a SQL Server goes down, no matter how the Alert is configured, it does not seem to work. We do see the message in the event log but the alert is...
0
2616
by: ayneekeaw | last post by:
When I click the update button/link at the Gridview to update the data from drop down list into the SQL. The selected value of drop down list change to default value. How can I fix this problem
4
3000
by: FNA access | last post by:
I have read through many posts that are relevant to my topic and have not had any success. I want to click a button on my form and send an email to a list of people I have stored in a table with...
8
2449
by: wish | last post by:
Dear all, I would to ask that why the user always faced the different page when user click the back button instead back to page2.php but it go to page5.php..I remember in asp, we use the...
1
2538
by: Adam Docrat | last post by:
Hi there, I have created an MS Access database for use as a "helpdesk" system for the company that I work for. Records are detailed as "requests" and the status of the requests are changed as...
0
7083
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7106
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6815
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7226
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5407
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4848
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4531
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3047
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1362
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.