Complete .NET Email Bounce
Handling Component
Wednesday, December 13, 2017  
home about us faq contact us
PRODUCT
Overview
FAQ
Licensing
EVALUATION
On-Line Demo
Download
Examples
PURCHASE
Pricing
Buy Now!
SUPPORT
Documentation
Support Form
Online Help
Forums
Email Products
aspNetEmail
aspNetIMAP
aspNetMime
aspNetMX
aspNetPOP3
Networking Products
aspNetDns
aspNetPing
aspNetTraceRoute
aspNetWhois
Documentation and Examples

Documentation
    Online Help
    Downloadable .chm Help File

Support
    Email support@advancedIntellect.com
    Online Support Form
    Telephone Support

Examples

The following example demonstrates parsing a text message into a NDR object

[ C# ]
static void Main(string[] args)
{
	string ndrfile = "c:\\ndr_example.txt";
	NDR ndrMessage = NDR.ParseFile( ndrfile );
	Console.WriteLine( "NDR Type:{0}", ndrMessage.Type );
	Console.WriteLine( "NDR Help Message:{0}", ndrMessage.HelpMessage );
	Console.WriteLine( "NDR Bounced Address:{0}", ndrMessage.BouncedEmailAddress );
	Console.WriteLine( "press enter to contine...");
	Console.ReadLine();
}					
					
					
[ VB.NET ]
Sub Main()
	Dim ndrfile As String = "c:\ndr_example.txt"       
	Dim ndrMessage As NDR = NDR.ParseFile(ndrfile)        
	Console.WriteLine("NDR Type:{0}", ndrMessage.Type)        
	Console.WriteLine("NDR Help Message:{0}", ndrMessage.HelpMessage)
	Console.WriteLine("NDR Bounced Address:{0}", ndrMessage.BouncedEmailAddress)
	Console.WriteLine("press enter to contine...")
	Console.ReadLine()
End Sub					

Process a Directory of NDRs

[ C# ]
static void Main(string[] args)
{
	//create the processing engine
	ProcessingEngine pe = new ProcessingEngine();
	pe.ParseNDRDirectory += new ParseNDRDirectoryEventHandler( OnParseNDRDirectory );
	//process the directory
	string path = "C:\\temp\\Bounces";
	pe.ProcessDirectory( path );
	Console.WriteLine( "done.");
	Console.ReadLine();
	
}
private static void OnParseNDRDirectory( object sender, ParseNDRDirectoryEventArgs e )
{
     
	Console.WriteLine( "----------------" );
	Console.WriteLine( e.Filename ); 
	Console.WriteLine( e.NDR.Type );
	Console.WriteLine( e.NDR.HelpMessage );
	Console.WriteLine( e.NDR.BouncedEmailAddress );
}
[ VB.NET ]
Sub Main(ByVal args() As String)
    'create the processing engine
    Dim pe As New ProcessingEngine()
    AddHandler pe.ParseNDRDirectory, AddressOf OnParseNDRDirectory


    'process the directory
    Dim path As String = "C:\temp\Bounces"
    pe.ProcessDirectory(path)

    Console.WriteLine("done.")
    Console.ReadLine()
End Sub 'Main



Private Sub OnParseNDRDirectory(ByVal sender As Object, ByVal e As ParseNDRDirectoryEventArgs)

    Console.WriteLine("----------------")
    Console.WriteLine(e.Filename)
    Console.WriteLine(e.NDR.Type)
    Console.WriteLine(e.NDR.HelpMessage)
    Console.WriteLine(e.NDR.BouncedEmailAddress)
End Sub 'OnParseNDRDirectory 

The following example demonstrates using aspNetPOP3 to connect to a POP3 mailbox, download the messages, and parse them with ListNanny.

[ C# ]
static void Main(string[] args)
{
	
	POP3 pop = new POP3( "127.0.0.1", "dave@blah.com", "test" );
	pop.Connect();
	int messageCount = pop.MessageCount();
	for( int i=0;i<messageCount;i++)
	{
		string messageText = pop.GetMessageAsText( i );

		NDRType messageType = ProcessMessage( messageText );
	}

	pop.Disconnect();

	Console.WriteLine( "done.");
	Console.ReadLine();

	
}

static NDRType ProcessMessage( string text )
{
	NDR ndrMessage = NDR.Parse( text );

	Console.WriteLine( "NDR Type:{0}", ndrMessage.Type );
	Console.WriteLine( "NDR Help Message:{0}", ndrMessage.HelpMessage );
	Console.WriteLine( "NDR Bounced Address:{0}", ndrMessage.BouncedEmailAddress );

	return ndrMessage.Type;
}
[ VB.NET ]
Sub Main(ByVal args() As String)


    Dim pop As New POP3("127.0.0.1", "dave@blah.com", "test")
    pop.Connect()
    Dim messageCount As Integer = pop.MessageCount()
    Dim i As Integer
    For i = 0 To messageCount - 1
        Dim messageText As String = pop.GetMessageAsText(i)

        Dim messageType As NDRType = ProcessMessage(messageText)
    Next i

    pop.Disconnect()

    Console.WriteLine("done.")
    Console.ReadLine()

End Sub 'Main



Function ProcessMessage(ByVal [text] As String) As NDRType
    Dim ndrMessage As NDR = NDR.Parse([text])

    Console.WriteLine("NDR Type:{0}", ndrMessage.Type)
    Console.WriteLine("NDR Help Message:{0}", ndrMessage.HelpMessage)
    Console.WriteLine("NDR Bounced Address:{0}", ndrMessage.BouncedEmailAddress)

    Return ndrMessage.Type
End Function 'ProcessMessage

Import the NDR Definition file into the NDR object.

[ C# ]
NDR.ImportDefinitionFile( "c:\\ndr.def.xml" );

NDR ndrMessage = NDR.ParseFile( "test.txt" );

Console.WriteLine( ndrMessage.Type );
Console.WriteLine( ndrMessage.BouncedEmailAddress );
[ VB.NET ]
NDR.ImportDefinitionFile("c:\ndr.def.xml")

Dim ndrMessage As NDR = NDR.ParseFile("test.txt")

Console.WriteLine(ndrMessage.Type)
Console.WriteLine(ndrMessage.BouncedEmailAddress)
OTHER PRODUCTS
view +  
    2008 © AdvancedIntellect.
All rights reserved