Home | Demo | Contact Us | Download | Support | Purchase | Products


Other Products
 
  "Did anyone ever tell you that you're a genius? Your suggestions worked like a charm. Thanks for all of your help."
Bruno
Systems Interactive
 
More
Testimonials

Create an aspNetMime message from text

The following example demonstrates parsing a Mime message from a string.


[C#]

//an email on the filesystem
string filename = "testEmail.eml";

//open the email
StreamReader sr = new StreamReader( filename );

//read the stream into some text
string mytext = sr.ReadToEnd();

//this creates a Message from a stream
aspNetMime.MimeMessage msg = new aspNetMime.MimeMessage( mytext );

//close the stream
sr.Close();

foreach( Header h in msg.Headers )
{
	Console.WriteLine( "Name -- " +  h.Name );
	Console.WriteLine( "Value -- " + h.Value );
	Console.WriteLine( "Complete Value (includes parameters) -- " + h.ValueComplete );
	Console.WriteLine( "The raw header -- " + h.RawValue );
}


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

 

[VB.NET]

'an email on the filesystem
Dim filename As String =  "testEmail.eml" 
 
'open the email
Dim sr As StreamReader =  New StreamReader(filename) 
 
'read the stream into some text
Dim mytext As String =  sr.ReadToEnd() 
 
'this creates a Message from a stream
Dim msg As aspNetMime.MimeMessage =  New aspNetMime.MimeMessage(mytext) 
 
'close the stream
sr.Close()
 
Dim h As Header
For Each h In msg.Headers
	Console.WriteLine("Name -- " +  h.Name)
	Console.WriteLine("Value -- " + h.Value)
	Console.WriteLine("Complete Value (includes parameters) -- " + h.ValueComplete)
	Console.WriteLine("The raw header -- " + h.RawValue)
Next
 
 
Console.WriteLine("done...")
Console.ReadLine()


 

 



The box is not shipped. aspNetMime is a downloadable product.