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


Other Products
 
  "Joe spoke very highly of the quality of your product and support, and I'm pleased to concur. Thanks for all the help!"
D.J.
Dell
 
More
Testimonials
aspNetEmail
Voted Number 1 ASP.NET Email Control
Voted Best Email Control


aspNetEmail
Runner Up ASP.NET Email Control
Voted Runner Up Email Control


aspNetEmail
Voted Number 1 ASP.NET Email Control
Voted Best Email Control


aspNetEmail
Voted Number 1 ASP.NET Email Control
Voted Best Email Control


aspNetEmail
Voted Number 1 ASP.NET Email Control
Voted Best Email Control


aspNetTraceRoute
Voted Runner Up Networking Control
Runner Up - Networking Control

Loop through Attachments and Embedded Parts

The following example demonstrates looping through the attachments and embedded parts that may be part of a mime 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( myte

//get the attachments and loop through them
MimePartCollection attachments = msg.Attachments;
foreach( MimePart attachment in attachments )
{
	Console.WriteLine( attachment.AttachmentName() );
}

//now loop through any embedded images or objects
MimePartCollection embeddedParts = msg.EmbeddedParts;
foreach( MimePart part in embeddedParts )
{
	Console.WriteLine( part.EmbeddedName() );
}

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
aspNetMime.MimeMessage msg = New aspNetMime.MimeMessage(mytext)
 
'get the attachments and loop through them
Dim attachments As MimePartCollection =  msg.Attachments 
Dim attachment As MimePart
For Each attachment In attachments
	Console.WriteLine(attachment.AttachmentName())
Next
 
'now loop through any embedded images or objects
Dim embeddedParts As MimePartCollection =  msg.EmbeddedParts 
Dim part As MimePart
For Each part In embeddedParts
	Console.WriteLine(part.EmbeddedName())
Next
 
Console.WriteLine("done...")
Console.ReadLine()


 

 

 



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