Click here to Skip to main content
15,884,629 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Currently my application has ability to process incoming emails and bounce then back if it does not match with given criteria in code. However, I want to add up another type of email to Process which are NDR "Non-Delivery Reports" from Microsoft Exchange Server. So my application do not responsd/Bounce back NDR to exchange server which cause a loop between my Mailbox and Exchange Server. Following method triggers when Invalid doesn't have a specific

C#
private static void ProcessInvidMsgWithoutNo(string sMsgFrom, string sFromEmail, EmailMsg sMsgReceived, EmailMessage message)
    {
        EmailMsg.MoveToInvalid(message);

        sMsgReceived.IsValid = false;
        SaveMsgReceived(sMsgReceived, 0, string.Empty);

        if (!sFromEmail.Equals(string.Empty))
        {
            ResponseForInvidMsg(sFromEmail);
        }
        else
        {
            curLog.WriteLog(string.Format(CultureInfo.CurrentCulture, MsgEMChecker27, sMsgFrom));
        }
    }


Following Method triggers to respond incoming Invalid message as stated above.

C#
private static void ResponseForInvidMsg(string sFromEmail)
    {
        string tErrSubjectMsg = String.Format(CultureInfo.CurrentCulture, "{0}\\Resource\\MsgErrorSubjectAck.html", Entity.GetSetting("DocRootDir"));

        StringBuilder htmlText = new StringBuilder();
        FileStream fsFile = new FileStream(tErrSubjectMsg, FileMode.Open);

        if (fsFile != null)
        {
            StreamReader reader = new StreamReader(fsFile, Encoding.Default);

            string text;
            do
            {
                text = reader.ReadLine();
                if ((text != null) && (text != ""))
                    htmlText.Append(text + "\n");
            } while (text != null);

            reader.Close();
            fsFile.Close();
            fsFile = null;
        }
        else
            htmlText.Append("hello");

        string tToCustomerSubject = ReplyForInvalid;
        string tMessage = htmlText.ToString();

        EmailMsg emTo = new EmailMsg(string.Empty, sFromEmail, tToCustomerSubject, tMessage);
        emTo.MsgType = EmailMsg.TypeSentCustomer;
        emTo.Send(false); //Not save but CC to generic email box
    }


What I have tried:

I have tried looking into report.ipm.note.ndr but not sure how it embed in my current code. Is there any way that my code should not respond to Exchange Server NDR but able to receive them only. Thanks
Posted
Updated 10-Jul-19 22:52pm

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900