Skip to main content
Email Password   helpLost your password?

Introduction

This article provides an advanced MIME editor. You can use it for parsing email messages, changing messages and for creating new email messages. It supports creation of complex messages with nested MIME entities. For more info, see help file: LumiSoft.Net.Mime namespace.

Message examples

Simple message:

//--- Beginning of message
From: sender@domain.com
To: recipient@domain.com
Subject: Message subject.
Content-Type: text/plain

Message body text. Bla blaa
blaa,blaa.
//--- End of message

In simple message, the MainEntity is the whole message.

Message with attachments:

//--- Beginning of message
From: sender@domain.com
To: recipient@domain.com
Subject: Message subject.
Content-Type: multipart/mixed; boundary="multipart_mixed"

--multipart_mixed    /* text entity */
Content-Type: text/plain

Message body text. Bla blaa
blaa,blaa.
--multipart_mixed    /* attachment entity */
Content-Type: application/octet-stream

attachment_data
--multipart_mixed--
//--- End of message

Here MainEntity is the multipart_mixed entity, and the text and attachment entities are child entities of MainEntity.

Using the code

Parsing example:

Mime m = Mime.Parse("message.eml");
// Do your stuff with mime

Creating a new simple message:

Mime m = new Mime();
MimeEntity mainEntity = m.MainEntity;
// Force to create From: header field

mainEntity.From = new AddressList();
mainEntity.From.Add(new MailboxAddress("dispaly name","user@domain.com"));
// Force to create To: header field

mainEntity.To = new AddressList();
mainEntity.To.Add(new MailboxAddress("dispaly name","user@domain.com"));
mainEntity.Subject = "subject";
mainEntity.ContentType = MediaType_enum.Text_plain;
mainEntity.ContentTransferEncoding = ContentTransferEncoding_enum.QuotedPrintable;
mainEntity.DataText = "Message body text.";

m.ToFile("message.eml");

Creating a message with text and attachments:

Mime m = new Mime();
MimeEntity mainEntity = m.MainEntity;
// Force to create From: header field

mainEntity.From = new AddressList();
mainEntity.From.Add(new MailboxAddress("dispaly name","user@domain.com"));
// Force to create To: header field

mainEntity.To = new AddressList();
mainEntity.To.Add(new MailboxAddress("dispaly name","user@domain.com"));
mainEntity.Subject = "subject";
mainEntity.ContentType = MediaType_enum.Multipart_mixed;

MimeEntity textEntity = mainEntity.ChildEntities.Add();
textEntity.ContentType = MediaType_enum.Text_plain;
textEntity.ContentTransferEncoding = ContentTransferEncoding_enum.QuotedPrintable;
textEntity.DataText = "Message body text.";

MimeEntity attachmentEntity = mainEntity.ChildEntities.Add();
attachmentEntity.ContentType = MediaType_enum.Application_octet_stream;
attachmentEntity.ContentDisposition = ContentDisposition_enum.Attachment;
attachmentEntity.ContentTransferEncoding = ContentTransferEncoding_enum.Base64;
attachmentEntity.ContentDisposition_FileName = "yourfile.xxx";
attachmentEntity.DataFromFile("yourfile.xxx");
// or

attachmentEntity.Data = your_attachment_data;
You must Sign In to use this message board.
 
 
Per page   
 FirstPrevNext
GeneralThis is a multi-part message in MIME format. Pin
Eric Johannsen
21:28 24 Oct '09  
GeneralRe: This is a multi-part message in MIME format. Pin
Ivar Lumi
22:54 24 Oct '09  
GeneralRe: This is a multi-part message in MIME format. [modified] Pin
Eric Johannsen
10:18 25 Oct '09  
GeneralRe: This is a multi-part message in MIME format. Pin
Ivar Lumi
5:02 26 Oct '09  
GeneralMail Server Pin
sibi jacob Abraham
22:22 14 Oct '09  
Generalhow to save attachment from mail to disk Pin
ano&gete
3:23 3 Oct '09  
GeneralRe: how to save attachment from mail to disk Pin
Ivar Lumi
20:53 3 Oct '09  
GeneralParsing date error Pin
Elvandar
23:26 1 Oct '09  
GeneralRe: Parsing date error Pin
Ivar Lumi
23:51 1 Oct '09  
NewsRe: Parsing date error [modified] Pin
Elvandar
0:20 2 Oct '09  
GeneralRe: Parsing date error Pin
Ivar Lumi
1:18 2 Oct '09  
GeneralRe: Parsing date error Pin
Elvandar
1:25 2 Oct '09  
Questionlatest version, mime parsing Pin
Member 2743156
0:21 29 Sep '09  
AnswerRe: latest version, mime parsing Pin
Ivar Lumi
0:51 29 Sep '09  
GeneralNice job Pin
Steve Trefethen
22:43 3 Sep '09  
GeneralRe: Nice job Pin
Ivar Lumi
2:21 4 Sep '09  
GeneralWhat about an eml inside an eml? Pin
BroxCJ
2:22 11 Aug '09  
GeneralRe: What about an eml inside an eml? Pin
Ivar Lumi
6:40 11 Aug '09  
GeneralRe: What about an eml inside an eml? Pin
BroxCJ
23:03 11 Aug '09  
GeneralChange from Singlepart to multipart and preserve attachment Pin
Bman28
6:12 16 Jul '09  
GeneralRe: Change from Singlepart to multipart and preserve attachment Pin
Ivar Lumi
8:12 16 Jul '09  
GeneralRe: Change from Singlepart to multipart and preserve attachment Pin
Bman28
9:25 16 Jul '09  
GeneralRe: Change from Singlepart to multipart and preserve attachment Pin
Ivar Lumi
21:29 16 Jul '09  
GeneralCould you please write a simple sample code that reads a eml file and load it on a MailMessage class of .net framework? Pin
evald80
0:46 22 Jun '09  
GeneralRe: Could you please write a simple sample code that reads a eml file and load it on a MailMessage class of .net framework? Pin
Ivar Lumi
4:34 22 Jun '09  


Last Updated 5 Oct 2005 | Advertise | Privacy | Terms of Use | Copyright © CodeProject, 1999-2009