Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium



Posted on 2012-08-23
Medium Priority
Last Modified: 2012-09-09

Is there a way of knowing if an email or text that is sent via an asp.net 4 website is bounced or not?

Basically we want to send the email and if it bounces or isn't being delivered then somehow in code we can find this out and automae letting the user know.

Is this possible?

C# ideally.
Question by:scm0sml
  • 2
LVL 19

Assisted Solution

Bardobrave earned 200 total points
ID: 38324558
Actually it depends on the way you are sending the email.

However, most email libraries have some sort of error control. It could be a return value or just the throwing of an exception. You can check the result of the send method execution to see if it has been succesful or if it returns an error value or an exception (wich usually includes info about the error produced).

Check SmtpClient class documentation, as an example, for further info:
LVL 33

Accepted Solution

Todd Gerbert earned 1800 total points
ID: 38330607
Generally, I think, the Send method (assuming you're using SmtpClient, or something similar) almost always returns success except in cases where there's an immediate failure, such as a malformed recipient address like "user@missingdotcom", or an inaccessible SMTP server.

In most cases it's up to the recipients server to generate an error (if there's no such user, e.g.), and send you a return e-mail message with a Non-Delivery Report (NDR).

I've never attempted to do so, but I imagine it might be possible to attach a custom header to the message that uniquely identifies that message, like a GUID. The address you're using as the "From" field for the message would need to be valid, and able to receive mail. You'd store some information in a database, like the recipients e-mail address, along with the GUID. Periodically you would check the sender's mailbox for NDR's, and if one is found with the custom header you added to the out-going message you can compare that GUID to ones that you previously stored in a database.

Or, I supposed you could simply check the "To" headers in any NDR's you've received as an alternative to the GUID-tracking method.
LVL 33

Expert Comment

by:Todd Gerbert
ID: 38330613
...keep in mind that it may be days before receive any errors.

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Loops Section Overview
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses
Course of the Month13 days, 17 hours left to enroll

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question