This is a C# source code that reads a signed MDN. The complete program
can be downloaded at EDIINT AS2.
A detailed explanation of the algorithm can be read at "Creating
an AS2 client in stages".
private void ReadMdnSignedMessage(ref mailMessage oMDN) { // Algotrithm to read the message in the MDN mailMessages oMdnMsgs = oMDN.GetMessages(); int nMdnResult = -1; string sErrorMsg = ""; string sRecvMicFldValue = ""; string sMicValue = ""; string sMicAlg = ""; for (int ii = 1; ii <= oMdnMsgs.Count; ii++) { mailMessage oMdnMsg = oMdnMsgs.GetMessageContent(ii); mailContentType oContentType = oMdnMsg.GetContentType(); if (oContentType.MediaType == "message" && oContentType.SubType == "disposition-notification") { mailMessages oSubMessages = oMdnMsg.GetMessages(); mailMessage oDisposition = oSubMessages.GetMessageContent(1); if (oDisposition != null) { mailHeaders oHeaders = oDisposition.GetHeaders(); string sHeaders = ""; for (int i = 1; i <= oHeaders.Count; i++) { mailHeader oHeader = oHeaders.GetHeaderByIndex(i); sHeaders = sHeaders + oHeader.Name + " : " + oHeader.Value + "\r\n"; if (oHeader.Name.ToLower() == "disposition") { nMdnResult = 0; //MessageBox.Show oHeader.Value } else if (oHeader.Name.ToLower() == "warning") { nMdnResult = 1; sErrorMsg = sErrorMsg + oHeader.Value + "\r\n"; } else if (oHeader.Name.ToLower() == "error") { nMdnResult = 2; sErrorMsg = sErrorMsg + oHeader.Value + "\r\n"; } if (oHeader.Name == "Received-Content-MIC") { sRecvMicFldValue = oHeader.Value; int lPos; lPos = sRecvMicFldValue.IndexOf(","); if (lPos == 0 && sRecvMicFldValue.Length > 0) { nMdnResult = 3; } else { sMicValue = sRecvMicFldValue.Substring(0, lPos); sMicAlg = sRecvMicFldValue.Substring(lPos + 1); // Compare the MIC of the subject document to MIC received by received. string sSubjMicValue = txtMIC.Text; if (sMicValue != sSubjMicValue) { nMdnResult = 4; } } //lPos == 0 && Len(sRecvMicFldValue) > 0 } } // For Each oHeader In oHeaders } // if (oDisposition) } // if (oContentType.MediaType && oContentType.SubType) } // for ii if (nMdnResult == 0) { MessageBox.Show("Successfully sent.", "MDN Message"); } else if (nMdnResult == 1) { MessageBox.Show("The message was successfully sent but there were warnings."); MessageBox.Show(sErrorMsg, "MDN Warning"); } else if (nMdnResult == 2) { MessageBox.Show("An error occurred during transmission"); MessageBox.Show(sErrorMsg, "MDN Error"); } else if (nMdnResult == 3) { MessageBox.Show("Invalid Received-Content-MIC field value"); } else if (nMdnResult == 4) { MessageBox.Show("Recipient received invalid document. Subject MIC=" + txtMIC.Text + ", Recv MIC=" + sMicValue); } else { MessageBox.Show("MDN format not recognized"); } //if (nMdnResult) }