aspNetMime Sample Code

The following code example assumes that you are using the @import directive to reference the component from the GAC.  You You can avoid this by simply downloading the trial version of the component and placing it in your /bin folder.

Online Documentation for aspNetEmail can be found at: http://www.aspnetmime.com/documentation.aspx

C# Sample

// NOTE: The line below can be excluded if you reference the assembly in your web.config. See Related Articles
<%@ Assembly name="aspNetMime, Version=2.5.2.0, Culture=neutral, PublicKeyToken=bc571e8da1c1f543" %>

<%@ import Namespace="aspNetMime" %>

<Script runat="server" Language="C#">

    void Page_Load(object sender, System.EventArgs e)
    {

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

          //this creates a MimeMessage from a stream
          aspNetMime.MimeMessage msg = MimeMessage.ParseFile( filename );

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

         

    }

</script>

 

VB.NET Sample

// NOTE: The line below can be excluded if you reference the assembly in your web.config. See Related Articles
<%@ Assembly name="aspNetMime, Version=2.5.2.0, Culture=neutral, PublicKeyToken=bc571e8da1c1f543" %>

<%@ import Namespace="aspNetMime" %>

<Script runat="server" Language="VB">

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)

          'an email on the filesystem
          Dim filename As String =  "testEmail.eml" 
 
           'this creates a MimeMessage from a file
          Dim msg As aspNetMime.MimeMessage =  MimeMessage.ParseFile( filename )
 
          Dim h As Header
          For Each h In msg.Headers
                 Response.Write("Name -- " +  h.Name)
                 Response.Write("Value -- " + h.Value)
                 Response.Write("Complete Value (includes parameters) -- " + h.ValueComplete)
                 Response.Write("The raw header -- " + h.RawValue)
          Next
 

    End Sub

</script>