Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6971675
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:52:15+00:00 2026-05-27T16:52:15+00:00

I am looking to have C# connect to an e-mail account and process undelivered

  • 0

I am looking to have C# connect to an e-mail account and process undelivered mail or failures. And I would like the failed address or the original e-mail to be written to a text file.

I’m sure I could figure out how to identify failed message. Example: WHERE subject CONTAINS ‘failure’, ‘returned’, etc.

What I do not know how to do is collect the failed address from the e-mail.

I was using a program called popmonger for a client at one point, but now it is collecting the wrong e-mail addresses. It is collecting mailer-daemon@gateway03.websitewelcome.com as an example instead of the original or failed e-mail. I thought it might be easier if I wrote a C# service.

The e-mail account I am connecting to is at hostgator. Does anyone know where to start on this?

Thanks,

Jake

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T16:52:15+00:00Added an answer on May 27, 2026 at 4:52 pm

    Since the mail client being used is called popmonger, it sounds like you will be dealing with POP3 protocol and although .Net provides a way to send email via SMTP easily, it doesn’t really do the same justice when checking emails.

    You will have to use a 3rd party DLL that has a POP3 client to retrieve the emails. Most importantly you will need to inspect one of the failure email notifications to see what what your application will be expecting. There should be something common in the subject, body, originator address, etc. to tip off which emails are failure notifications. Then you need to see where in the body of the email it specifies the error information you need to retrieve to write to the text file. Basically your steps should go something like this:

    • Check for and retrieve email messages
    • Add each failure email object to a collection (List<T> works just fine)
    • Read/parse each email to extract the information you need
    • Write the extracted data to a file
    • As long as everything goes well and you get no exceptions, delete the email from the POP server with your POP client object (that way you don’t read the same failure notices every time and fill your text file with redundant data)

    I’ve used a POP3 class from this codeproject article and it does include code for attachments but I never use it for attachments because it’s a bit buggy with them. For reading email body text, it hasn’t failed me yet (knocking on wood).

    Once you have the failure notice you can extract the failed address per your prescribed format with a simple regular expression pattern and matching it. Let’s assume the body text is already retrieved from the server and you stored it in a stringed named bodyText

    using System.Text.RegularExpressions;
    // ...
    
    string failedAddressPattern = @"The mail system <(?<address>.+)>";
    string capturedAddress = null;
    Match match = Regex.Match(bodyText, failedAddressPattern, RegexOptions.IgnoreCase);
    
    if(match.Groups["address"].Success)
    {
        capturedAddress = match.Groups["address"].Value.Trim();
    }
    
    if(capturedAddress == null)
    {
        // do some form of debug logging here because the pattern no longer works, etc.
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been looking into android development for some time and would really like
I have a business object that I would like to connect to my UI
Im looking to have a common parent function like so void main (param 1,
I have a text field and am looking to have if be valid for
I have this input text and an input button...I am looking to have them
I have been looking around at different ways to connect to URLs and there
I have been looking for hours on how to connect to my local SQL
Looking to connect my online shopping cart to my Quickbooks Online Plus account. I
I am looking for a Django application to implement Facebook-connect, and I have found
I would like to display the body contents of an email. I have tried

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.