Here is my C# Code :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net.Mail;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
SmtpClient client = new SmtpClient("smtp.gmail.com", 587);
client.EnableSsl = true;
client.Credentials = new System.Net.NetworkCredential("xyz@gmail.com", "password");
MailMessage msg = new MailMessage();
msg.From = new MailAddress("xyz@gmail.com");
msg.To.Add(new MailAddress(TextBox1.Text));
msg.Subject = "Testing Email";
String Body = "This is Testing Email.";
msg.Body = Body;
msg.IsBodyHtml = true;
try
{
client.Send(msg);
MsgBox("Send Successfully");
}
catch (Exception ex)
{
MsgBox("deleivery failed" + ex.ToString());
}
}
}
The problem is that when i enter Correct Email ID in TextBox1 then alert with Send Successfully is appear and no error message and when i enter a wrong email id like 12345xyz@gmail.com in TextBox1 then also alert with Send Successfully is appear and no error message and i recieve an email for email Delivery Failed in xyz@gmail.com inbox.
How i check email is send or delivery failed. I am using ASP.Net and C#.