Click here to Skip to main content
15,892,161 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi guys!
I would like to know on how to send an email by clicking a button in my web page?
The user will input his/her email in the text box and s/he will will press the SEND button. Then the message s/he will get will the system generated ID and some instructions to follow for him/her to continue using the system.

Thanks :)
Posted
Comments
[no name] 27-Aug-14 2:33am    
4 nice suggestion are following below but
Have u not find ur ans yet??

 
Share this answer
 
Comments
DarkDreamer08 27-Aug-14 2:20am    
It does not work.
There are a lot of articles about this subject, here are two of them:
Send Mail / Contact Form using ASP.NET and C#[^]
http://weblogs.asp.net/scottgu/432854[^]
 
Share this answer
 
Comments
DarkDreamer08 27-Aug-14 2:21am    
the first link you gave does not work :(
Raul Iloc 27-Aug-14 2:24am    
The articles from the links should be used by you as starting point for solving your problem, but you should adapt and customize the provided source code for your context. For example in the 2nd article there are details about the SMTP settings that you must set up in your web.config in order to can send emails.
DarkDreamer08 27-Aug-14 2:31am    
i will read it :) thank you. After I do it, I will mark it as an ANSWER :) Thanks Buddy!
DarkDreamer08 27-Aug-14 5:00am    
Question, What is the purpose of the smtp.Host. Is it the host on what email account am I using or the email account where I will send the message?
DarkDreamer08 27-Aug-14 2:53am    
Buddy! It works fine now. But I have a problem. Google told me that the email that I sent the message failed because the DOMAIN is not found. What will I do? for example is that I sent the message to her outlook account. That's the time Google told me that the sending of message failed.
All you need can be found in .NET FCL. Please start here:
http://msdn.microsoft.com/en-us/library/system.net.mail.smtpclient%28v=vs.110%29.aspx[^],
http://msdn.microsoft.com/en-us/library/system.net.mail.mailmessage%28v=vs.110%29.aspx[^].

I hope your ASP.NET hosting provides you with the access to a SMTP server; I never heard of hosting packages without this feature.

Now, you need to pay special attention if you want to send mail based in input data taken from UI. It's way to easy to open up a vulnerability which would allow someone to turn you host system a spam-sending zombie, or something like that. You need to prevent it. Please see my past answer: unable to send mail , it showing the error in below code .[^].

—SA
 
Share this answer
 
Comments
DarkDreamer08 27-Aug-14 22:54pm    
Please help me out here http://www.codeproject.com/Questions/812400/How-to-send-email-using-ASP-NET.
Sergey Alexandrovich Kryukov 27-Aug-14 23:37pm    
I added a short answer.
—SA
Try this..
HTML
using System.Net;
using System.Net.Mail;

string to = strSidMail;
string from = "rajeeshmenoth@wordpress.com";
MailMessage message = new MailMessage(from, to);
message.Subject = txt_subject.text;
message.Body = mailbody;
message.BodyEncoding = Encoding.UTF8;
message.IsBodyHtml = true;
SmtpClient client = new SmtpClient("smtp.gmail.com", 587);
System.Net.NetworkCredential basicCredential1 = new
System.Net.NetworkCredential("yourgmail id", "Password");
client.EnableSsl = true;
client.UseDefaultCredentials = false;
client.Credentials = basicCredential1;
try
{
client.Send(message);
}
catch (Exception ex)
{
throw ex;
}
 
Share this answer
 
Comments
DarkDreamer08 27-Aug-14 2:23am    
i tried that but there were errors. Some are those Encoding,mailbody. there were red lines indicaing that there is something wrong with those line :(
[no name] 27-Aug-14 6:31am    
u can create a string like mailbody.... eg: string mailbody = "hai"; then assign the mail body to message.body place

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900