Question:
how to send email in asp.net usin c#.net?
?
2010-02-18 22:57:37 UTC
hello, all

i have query regarding how to send mail in asp.net using C#.net

for that i have use the following code

but still not able to send

please give me your valuable suggestion


System;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Net.Mail;

public partial class _Default : System.Web.UI.Page
{
#region "Send email"
protected void btnSendmail_Click(object sender, EventArgs e)
{
// System.Web.Mail.SmtpMail.SmtpServer is obsolete in 2.0
// System.Net.Mail.SmtpClient is the alternate class for this in 2.0
SmtpClient smtpClient = new SmtpClient();
MailMessage message = new MailMessage();

try
{
MailAddress fromAddress = new MailAddress(txtEmail.Text, txtName.Text);

// You can specify the host name or ipaddress of your server
// Default in IIS will be localhost
smtpClient.Host = "localhost";

//Default port will be 25
smtpClient.Port = 25;

//From address will be given as a MailAddress Object
message.From = fromAddress;

// To address collection of MailAddress
message.To.Add("john_begginer@yahoo.co.in");
message.Subject = "Feedback";

// CC and BCC optional
// MailAddressCollection class is used to send the email to various users
// You can specify Address as new MailAddress("admin1@yoursite.com")
// message.CC.Add("");
// message.CC.Add("");

// You can specify Address directly as string
//message.Bcc.Add(new MailAddress(""));
//message.Bcc.Add(new MailAddress(""));

//Body can be Html or text format
//Specify true if it is html message
message.IsBodyHtml = false;

// Message body content
message.Body = txtMessage.Text;

// Send SMTP mail
smtpClient.Send(message);

lblStatus.Text = "Email successfully sent.";
}
catch (Exception ex)
{
lblStatus.Text = "Send Email Failed.
" + ex.Message;
}
}
#endregion

#region "Reset"
protected void btnReset_Click(object sender, EventArgs e)
{
txtName.Text = "";
txtMessage.Text = "";
txtEmail.Text = "";
}
#endregion
}


actually i have also try this i seen the web site which is given below



http://www.ehow.com/how_4489548_set-...r-windows.html

and also


http://support.microsoft.com/kb/304897

but still the result is same :(
Four answers:
2010-02-18 23:13:56 UTC
refer this blog might it helps you.



http://www.eppleblogs.com/net-c-send-email-program.html
2016-11-07 13:14:01 UTC
till the e mail I acquire is a hate mail(which i positioned into trash bin), I constantly respond. If i do no longer respond, it potential i've got the two missed it(as a results of fact i'm getting extra effective than one hundred emails on an usual basis from Yahoo! solutions, so each each now and then i could omit an e mail from somebody) or that i'm out of city
sizwe ndlovu
2014-04-20 16:57:12 UTC
try this one http://sizwendlovu.blogspot.com/2014/03/sending-email-with-asp.html
2010-02-18 23:43:27 UTC
you can learn this from this website...

http://www.aspnettutorials.com/tutorials/email/email-aspnet2-csharp.aspx


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...