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


Other Products
 
  "Wow, that really was an quick response. Often when someone tells you they have great support, that's just sales-talk. I'm impressed!"
Anders
citysajten.com
 
More
Testimonials

Access Mime Headers

The following example demonstrates accessing different headers of the aspNetMime message.


[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();

//close the stream
sr.Close();

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

//access different headers
Header h = msg.GetHeader( "Status" );

//check for a status header
if( h != null )
	Console.WriteLine( h.RawValue );

//check for a X-header "X-Organization"
h = msg.GetXHeader( "Organization "); //the GetXHeader() method will find headers that start with X-
if( h!= null )
	Console.WriteLine( h.RawValue );

//check for X-OriginalArrivalTime
h = msg.GetXHeader( "OriginalArrivalTime" );
if( h != null )
	Console.WriteLine( 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() 
 
'close the stream
sr.Close()
 
'this creates a Message from a stream
Dim msg As aspNetMime.MimeMessage =  New aspNetMime.MimeMessage(mytext) 
 
'access different headers
Dim h As Header =  msg.GetHeader("Status") 
 
'check for a status header
If Not h Is Nothing Then
	Console.WriteLine(h.RawValue)
End If
 
'check for a X-header "X-Organization"
h = msg.GetXHeader("Organization ") 'the GetXHeader() method will find headers that start with X-
If Not h Is Nothing Then
	Console.WriteLine(h.RawValue)
End If
 
'check for X-OriginalArrivalTime
h = msg.GetXHeader("OriginalArrivalTime")
If Not h Is Nothing Then
	Console.WriteLine(h.RawValue)
End If
 
Console.WriteLine("done...")
Console.ReadLine()

 

 

 



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