About Mail
-
Hi every one I am a beginner in ASP.NET I am working on sending Email, but unable to get it... I am screwed up........., i have tried many codes in google but i am confused. Please any one can give me steps to follow from beginning to end. :|
Hi kiranreddy, Try this:
using System.Net.Mail;
protected void btnSendMessage_Click(object sender, EventArgs e)
{
SmtpClient smtpClient = new SmtpClient();
MailMessage message = new MailMessage();try
{MailAddress fromAdress = new MailAddress("YourSenderEmail", "NameThatSendTheMessage"); smtpClient.Host = "YoursmptClientHost"; smtpClient.Port = 25; //Which port the smtpClient sends on message.From = fromAdress; message.To.Add("MailAdressToWhoShouldRecieveTheMail"); message.Subject = "The message subject"; message.IsBodyHtml = false; message.Body = "The message went here"; smtpClient.Send(message); lblSendOk.Visible = true; } catch (Exception ex) { //Here I show an error, if any lblSendError.Visible = true; lblSendError.Text = lblSendError.Text + " .<br />" + ex.Message; }
}
If you have any trouble with the above code, you have to tell what exactly the error gives and copy your code, so we can see, if you have done anything else. Kind regards, simsen :-)
-
Hi every one I am a beginner in ASP.NET I am working on sending Email, but unable to get it... I am screwed up........., i have tried many codes in google but i am confused. Please any one can give me steps to follow from beginning to end. :|
you have to use System.Net namesapce and use MailMessage Class.
cheers, Abhijit