how to send mail in asp.net by server ip

Posted by Shanky11 under ASP.NET on 7/25/2013 | Points: 10 | Views : 905 | Status : [Member] | Replies : 3
i have created a website
in query form i am sending the details to mail id
this is demo code...i am using like this no error is coming lable is showing the message
but the mail is not going
what else can i do????
MailMessage mail = new MailMessage();
mail.To.Add("bis@gmail.com");
mail.From = new MailAddress("demo@bhavyainfosoft.com");
mail.Subject = "Test mail";
mail.Body = TextBox2.Text;
mail.IsBodyHtml = true;
SmtpClient client = new SmtpClient();
client.Credentials = new System.Net.NetworkCredential("demo@bhavyainfosoft.com", "sdawqe2");
client.Host ="66.198.252.156";
client.EnableSsl = false;
client.Send(mail);
lblmessage.Visible = true;
lblmessage.Text = "Mail sent successfully.";




Responses

Posted by: Jitendrasoft09 on: 7/25/2013 [Member] [MVP] Starter | Points: 25

Up
0
Down
Hi Shanky,

Make sure you have put your code inside try and catch block. Modify your code as below is mentioned.

SmtpClient smtp = new SmtpClient();

smtp.Port = 587;
smtp.EnableSsl = true;
smtp.Credentials = new NetworkCredential("<email_from>", "password");
smtp.Host = "smtp.gmail.com";


Refer below link for more information-
http://stackoverflow.com/questions/11844428/sending-mails-with-smtpclient

Hope you are clear.

Jitendra Kumar
If my post helps you, plz mark as an answer.

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Raj.Trivedi on: 7/26/2013 [Member] [MVP] Starter | Points: 25

Up
0
Down
Hello shanky

The host has to be in smtp format

it should have smtp.domian.com

You cannot have an IP address in that place.

That is the issue

Regard's
Raj.Trivedi
"Sharing is Caring"
Please mark as answer if your Query is resolved

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: aswinialuri-19361 on: 7/30/2013 [Member] Starter | Points: 25

Up
0
Down
hi
refer this link it might be help ful to you
http://forums.asp.net/t/1726456.aspx/1


Mark as Answer if it helps you
Thanks&Regards
Aswini Aluri

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response