How i can display the message based on the Mail Sending

Posted by Kondapallisrinivas under ASP.NET on 10/9/2012 | Points: 10 | Views : 828 | Status : [Member] | Replies : 2
Hello All

I add mail sending feature for my project by taking help from the article(http://www.dotnetfunda.com/articles/article747-how-to-send-an-e-mail-using-gmail-in-aspnet.aspx )...As of now every thing is okay.

But now i am trying if the message has been sucessfully sent then i want to dispaly the label text as Message sent sucessfully. And if it fails then it has to be display as message sending failed.

So please suggest how i can achive this

Thanks in advance

Regards
Kondapalli Srinivas




Responses

Posted by: Samanthajyesta on: 10/19/2012 [Member] Starter | Points: 25

Up
0
Down
Hi,
Simply keep a label under send button with the message sent text and add this code in try block ,after send mail code.

Regards,
Sam

http://www.dotnetfunda.com

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

Posted by: Vasanthmvp on: 10/19/2012 [Member] Starter | Points: 25

Up
0
Down
Hi,
Send() method is of void return type. so we can't get a value based on which we would acknowledge whether a mail has been successfully sent or not.
One way to do this is, include the mail sending part in try block..
If any exception raises.. display sending failed message. Not only one exception that may raise like
1. Mail ID doesn't exists
2. Network Failure / Error
3. If user sending large size files, it takes time.. during which a user may refresh or perform any other event.
Hence, its good to include it in a catch block itself.

If i am wrong, plz correct me.
Regards,

Awesome Coding !! :)

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

Login to post response