Hello sir,
protected void ButtonSubmit_Click(object sender, EventArgs e)
{
MailMessage mail = new MailMessage();
mail.From = new MailAddress(TextBoxEmail.Text, TextBoxCompanyName.Text);
mail.To.Add(new MailAddress("indra.rikkala@achirconsultancy.com"));
mail.Subject = TextBoxSubject.Text;
mail.Body = TextBoxMessage.Text;
SmtpClient client
= new SmtpClient("smtp.achirconsultancy.com");
client.Credentials = new System.Net.NetworkCredential("indra.rikkala@achirconsultancy.com", "zzzzzzzz");
try
{
client.Port = 25;
client.Send(mail);
}
catch (Exception ex)
{
Labeltext.Text = " Error occured. Sorry for the inconvinence";
return;
}
Labeltext.Text = "Your message has been successfully sent. Thank you";
}
Thanks a lot for helping me on "unable to send email in Asp.net" question
I have one last question can you please give me clarification on this topic.
I hosted my site in Discountasp.net.
Well, the problem in this code is port number.
If I change my port number from 25 to 587 it's working. Why so???
If it is 25 it is unable to communicate with the server.
And one more thing is it's working only if I supply the emails(both TO and FROM) of same domain(the domain I am working for). Can't I send mail to another person outside of my domain?
Lot of articles on this topic didn't mention to give username and password details in network credential section. Is that optional????
At network credential section in web.config file which username password details I have to supply? Is it the control panel of that domain? or just from address(email) username and password?
Sorry to ask these many questions but answers to these questions certainly give me what exactly I am doing.
Thanks for sharing your wisdom.