Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
|
Testing for MDN and Parsing a MDN (Message-Delivery-Notification) Email
This example demonstrates how to test for and parse a message-delivery-notification (MDN) email. ' This example demonstrates how to test a Chilkat.Email object to find out ' if it is an MDN (Message Delivery Notification) email. ' For the example, we have already saved a copy of an MDN in mdn.eml. Dim email As New Chilkat.Email() email.UnlockComponent("anything for 30-day trial") email.LoadEml("mdn.eml") ' MDN messages have a content-type of multipart/report Dim hdrFieldValue As String ' The GetHeaderField method returns the full contents of a given header field. ' For MDN messages, it may look like this: ' multipart/report; boundary="_"; report-type=disposition-notification hdrFieldValue = email.GetHeaderField("content-type") If (hdrFieldValue.Contains("multipart/report")) Then MessageBox.Show("Yes! This is an MDN!") End If ' The MDN MIME contains two sub-parts. The first is a human-readable ' text/plain MIME part, and the 2nd has a content type of "message/disposition-notification" ' We can use Chilkat.Mime to parse the MDN: Dim mime As Chilkat.Mime ' Convert the Chilkat.Email object into a Chilkat.Mime object. mime = email.GetMimeObject() ' Unlocking only needs to be called once in a program mime.UnlockComponent("anything for 30-day trial") Dim textPart As Chilkat.Mime Dim dispPart As Chilkat.Mime textPart = mime.GetPart(0) dispPart = mime.GetPart(1) ' Show the human-readable MIME text in the text/plain message part. MessageBox.Show(textPart.GetBodyDecoded()) ' The message/disposition-notification part wraps another MIME message ' that can be parsed with Chilkat.Mime Dim mimeBody As String mimeBody = dispPart.GetBodyDecoded() Dim dispMime As New Chilkat.Mime() dispMime.LoadMime(mimeBody) ' Get these fields: Reporting-UA, Final-Recipient, Original-Message-ID, Disposition ListBox1.Items.Add("Reporting-UA: " + dispMime.GetHeaderField("Reporting-UA")) ListBox1.Items.Add("Final-Recipient: " + dispMime.GetHeaderField("Final-Recipient")) ListBox1.Items.Add("Original-Message-ID: " + dispMime.GetHeaderField("Original-Message-ID")) ListBox1.Items.Add("Disposition: " + dispMime.GetHeaderField("Disposition")) |
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2007 Chilkat Software, Inc. All Rights Reserved.