Home   Buy Now   Products   Downloads   Support   Resellers   Jobs   Contact   Site Map   Search
Home   Buy Now   Download   Support  
Email Component, SMTP Component, POP3 Component, IMAP Component, bulk mail

Home
Purchase
Upgrade
 
Products
Downloads
 
Support
 Samples
 KB
 Forum
 
Newsletter
 
Customers
 Current List
 Comments
 
Resellers
Jobs
Contact Us
EasyMail.Net Verify Sample Code

Sample Code

Check out the sample code below to see just how easy it is to use the Parse component of EasyMail .Net Edition to parse MIME messages.  But don't let the ease of use fool you; the Parse component exposes every part of the message and contains many feature rich methods to help you easily get the message data into your application.  The sample code on this page demonstrates the most basic features of  the Parse component.  Be sure to click on the "Other Samples" tab to find more advanced samples.

C#   VB.Net   Delphi   Other Samples    
Sample Notes
This sample reads a message from disk as stream, parses it, displays the message subject, first body part and then the filename of each attachment. This is a very simple 'boiled down' example, but it clearly shows you how things are done. If you are downloading a message with the POP3 or IMAP4 components, you can pass the downloaded stream right into the parse method, or even into the EMailMessage class constructor to easily parse downloaded messages in memory.

// create a new EmailMessage object and have  
// it parse message data from a stream
FileStream fileStream = File.OpenRead("c:\\msg.eml");
EmailMessage msg = new EmailMessage(fileStream);

// write out the subject and the first body part
// which is usually plain text
Console.WriteLine(msg.Subject);
Console.WriteLine(msg.BodyParts[1].BodyText);

// write out the name of each attachment
AttachmentCollection attachments = msg.Attachments;
foreach (Attachment attachment in attachments)
{
   // write out attachment file name
   Console.WriteLine(attachment.Filename);

   // attachments can also be saved directly to
   // a file.  Streams are supported too.
   attachment.Save("c:\\attachment.dat", true);
}

Copy and paste this code to get a jump start!

 



 

 Product Home
 Features
 What's New in 3.0
 Features Added in 2.x
 System.Web.Mail Comparison
 SMTP Component
 POP3 Component
 IMAP4 Component
 Parse Component
 Detailed Features
 Sample Code
 SSL Plug-in
 S/MIME Plug-in
 Documentation
 Pricing / Licensing

©2012Quiksoft Corporation. All rights reserved. Terms of Use, Privacy Statement, Trademarks