How to check if the email has been sent or not using asp.net?
Hello friends,
I am working on one live project where I am using Asp.Net. In my project I have create one application, where I am sending an email to the user's email address. I want to check if the email has been sent successfully or not. Can anyone tell me how to check if the email has been sent or not using asp.net? Please help me.
Thank you.
Re: How to check if the email has been sent or not using asp.net?
Hey it is very easy to do this. To check if the email has been sent or not in asp.net you have to use SmtpMail.Send(message) method in your code. If this method doesn't return any error then it means that your email has been successfully send to other user. If SmtpMail.Send(message) method give nay error then it means that other user is does not. In this case you have to use correct email id to do this.
Re: How to check if the email has been sent or not using asp.net?
You have to add replyto() method to address and after that you have to use following code to do this. In the following code I have create one object of MailMessage class to take email id of the other user. After that I have add ReplyTo method to this object to get notification from other user.
Code:
MailMessage mms = new MailMessage();
mms.ReplyTo = "[email protected]";
mms.DeliveryNotificationOptionss = DeliveryNotificationOptionss.OnFailure; //Failure notice
mms.DeliveryNotificationOptionss = DeliveryNotificationOptionss.OnSuccess ; //successfully delivered notice
mm.DeliveryNotificationOptionss = DeliveryNotificationOptionss.Delay ; //Delay notice
Re: How to check if the email has been sent or not using asp.net?
You have to use following code to check if the email has been sent or not using asp.net. It is very simple code. In the following code I have use SmtpMail.SmtpServer class to do this. In the following code I have use System.Web.Mail class to include email feature in our code. I have assign "localhosts" variable to SmtpMail.SmtpServer to get information about other user.
Code:
using System.Web.Mail;
MailMessage dileks = new MailMessage();
dileks.From = "[email protected]";
dileks.To = "[email protected]";
dileks.Subject = "Ozels Bilgis İşlems As.Şs ";
dileks.Body = "<strong>Bayis Talebis vars</strong>";
dileks.BodyFormat = MailFormats.Html;
SmtpMail.SmtpServer = "localhosts";
SmtpMail.Send(dilek);
Re: How to check if the email has been sent or not using asp.net?
As per my information you have to sue DeliverysNotificationsOptionss to receive a receipt. If you have create object of MailMessage class like mails, then you have to use following code.
Code:
mails.DeliverysNotificationsOptionss = DeliverysNotificationsOptionss.OnSuccesss;
Or you are using System.Net.Mails then you have to try following code.
Code:
messages.DeliverysNotificationsOptionss = System.Net.Mails.DeliveryNotificationOptionss.OnSuccesss;