• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 302
  • Last Modified:

mail validate

Dear Team,

I m sending mail after my insert query but i want to delete my inserted record if my mail will not send.
How can i check my main delivered to receipent.

Please let me know.
0
virafh
Asked:
virafh
1 Solution
 
vsudipCommented:
0
 
robastaCommented:
There's no way to be 100% sure that a mail message has been received when sent via SmtpClient due to the way email works. The fact that SmtpClient doesn't throw an exception essentially means that you've done everything right, but a failure can happen further down the line, for example:

The receiving mail server could reject the mail
An intermediate mail server could reject the mail
The server that SmtpClient is transmitting mail through could decide to refuse to transmit the mail

use a try-catch like:

try
{
smtpClient.Send(emailMessage);
}
catch(Exception ex)
{
 // did not send (delete record) >> delete my inserted record if my mail will not send
}


see discussion here:
http://stackoverflow.com/questions/4973725/how-to-check-mailmessage-was-delivered-in-net
0
 
virafhAuthor Commented:
Dear robasta:

Thanks for ur response i am already using the try catch it is working fine.

But suppose someone typing abc@abc.com than try catch statement will validate this id.

I want if any user put any dummy id on that time our code validate.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
robastaCommented:
see here: http://www.codeproject.com/KB/validation/Valid_Email_Addresses.aspx

under: Validating via SMTP Handshakes

there is some sample code
0
 
virafhAuthor Commented:
thanks robasta i think your provided code will work for me
0
 
Amandeep Singh BhullarCommented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now