3 Replies - 3930 Views - Last Post: 17 September 2012 - 01:54 AM Rate Topic: -----

#1 udusat  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 17-August 12

How to send Email Using Asp.net

Posted 17 August 2012 - 10:13 PM

Hi Expert,

I am new to asp.net and c#.

I am working on website Nridubai.
It was designed in asp. and now i am converting it into asp.net.

Most of the conversion is done.
Now I am working on contact forms.When user submit any form,i am trying to generate auto email for both client and admin.

So please tell me how to send email using asp.net.
Thanks in advance.

Is This A Good Question/Topic? 0
  • +

Replies To: How to send Email Using Asp.net

#2 Nakor  Icon User is offline

  • Professional Lurker
  • member icon

Reputation: 445
  • View blog
  • Posts: 1,501
  • Joined: 28-April 09

Re: How to send Email Using Asp.net

Posted 18 August 2012 - 05:15 AM

There's already quite a few topics related to sending emails in asp.net. There's a search feature at the top of the page so you can look for answers to your questions and see if it may already be answered.

Anyway, here's one of the links that comes up, see if it helps.
Was This Post Helpful? 1
  • +
  • -

#3 udusat  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 17-August 12

Re: How to send Email Using Asp.net

Posted 19 August 2012 - 10:17 PM

View PostNakor, on 18 August 2012 - 05:15 AM, said:

There's already quite a few topics related to sending emails in asp.net. There's a search feature at the top of the page so you can look for answers to your questions and see if it may already be answered.

Anyway, here's one of the links that comes up, see if it helps.


Thanks for replying me.

View Postudusat, on 19 August 2012 - 10:13 PM, said:

View PostNakor, on 18 August 2012 - 05:15 AM, said:

There's already quite a few topics related to sending emails in asp.net. There's a search feature at the top of the page so you can look for answers to your questions and see if it may already be answered.

Anyway, here's one of the links that comes up, see if it helps.


Thanks for replying me.

Following code was working for me
protected void SendMail()
{
// Gmail Address from where you send the mail
var fromAddress = "Gmail@gmail.com";
// any address where the email will be sending
var toAddress = YourEmail.Text.ToString();
//Password of your gmail address
const string fromPassword = "Password";
// Passing the values and make a email formate to display
string subject = YourSubject.Text.ToString();
string body = "From: " + YourName.Text + "\n";
body += "Email: " + YourEmail.Text + "\n";
body += "Subject: " + YourSubject.Text + "\n";
body += "Question: \n" + Comments.Text + "\n";
// smtp settings
var smtp = new System.Net.Mail.SmtpClient();
{
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.EnableSsl = true;
smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
smtp.Credentials = new NetworkCredential(fromAddress, fromPassword);
smtp.Timeout = 20000;
}
// Passing values to smtp object
smtp.Send(fromAddress, toAddress, subject, body);
}

protected void Button1_Click(object sender, EventArgs e)
{
try
{
//here on button click what will done
SendMail();
DisplayMessage.Text = "Your Comments after sending the mail";
DisplayMessage.Visible = true;
YourSubject.Text = "";
YourEmail.Text = "";
YourName.Text = "";
Comments.Text = "";
}
catch (Exception) { }
}
Was This Post Helpful? 0
  • +
  • -

#4 annaharris  Icon User is offline

  • New D.I.C Head

Reputation: -4
  • View blog
  • Posts: 38
  • Joined: 03-May 12

Re: How to send Email Using Asp.net

Posted 17 September 2012 - 01:54 AM

The .NET Framework supplies a SMTP class that enables you to send a simple e-mail message. If you have to send an e-mail with added functionality, you have to make use of the MailMessage class.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1