Hi indradeo,
You need to specify the delivery notification options for e-mail.
Refer below code.
Namespaces
C#
using System.Net;
using System.Net.Mail;
VB.Net
Imports System.Net
Imports System.Net.Mail
Code
C#
protected void SendEmail(object sender, EventArgs e)
{
using (MailMessage mm = new MailMessage("sender@gmail.com", "recipient@gmail.com"))
{
mm.Subject = "DataGridView";
mm.Body = "Test Email.";
mm.IsBodyHtml = true;
mm.Priority = MailPriority.High;
mm.DeliveryNotificationOptions = DeliveryNotificationOptions.OnSuccess;
mm.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
NetworkCredential NetworkCred = new NetworkCredential(mm.From.Address, "xxxxxx");
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.EnableSsl = true;
smtp.UseDefaultCredentials = true;
smtp.Credentials = NetworkCred;
smtp.Port = 587;
smtp.Send(mm);
}
}
VB.Net
Protected Sub SendEmail(ByVal sender As Object, ByVal e As EventArgs)
Using mm As MailMessage = New MailMessage("sender@gmail.com", "recipient@gmail.com")
mm.Subject = "DataGridView"
mm.Body = "Test Email."
mm.IsBodyHtml = True
mm.Priority = MailPriority.High
mm.DeliveryNotificationOptions = DeliveryNotificationOptions.OnSuccess
mm.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure
Dim NetworkCred As NetworkCredential = New NetworkCredential(mm.From.Address, "xxxxxx")
Dim smtp As SmtpClient = New SmtpClient()
smtp.Host = "smtp.gmail.com"
smtp.EnableSsl = True
smtp.UseDefaultCredentials = True
smtp.Credentials = NetworkCred
smtp.Port = 587
smtp.Send(mm)
End Using
End Sub
For more details refer below link.
Delivery Notification Options