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


Other Products
 
  "Ahhh ... SO COOL!!! I used the SendMailMergeToMSPickup method and it all worked like a charm. Very nicely done."
Scott McFarland
 
More
Testimonials

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.