Please click on the link with question to see the answer:
Q: Is it possible to parse a message, update it and then save it back to disk and/or email it?
A: Yes - this is available in the fully functional (non-trial) version of the component.
Q: Need more information about licensing. For Development license, Server license or Side license?
A: There are 2 types of licenses: binary and source-code. Price depend on number of developers and support time.
The license allows to install component on any amount of servers where you need to host your products. You can not resell component or distribute it further.
More details about licensing...
Q: Can the component re-encode (into MHTML) outgoing mail (with embedded and external attachments).
Q: How can I skip all attachments? I am only interested in the visible text...
A: Please use sample code below that demonstrating how to do this:
public void test_temp() {
string mimeMsg = "paste you mime message here!";
Stream mimeMsgStream = new MemoryStream( Encoding.ASCII.GetBytes(mimeMsg) );
WriteTextBodies( new MimeMessage(mimeMsgStream) );
}
public void WriteTextBodies(MimeMessage msg) {
WriteTextBodiesRecursive(msg);
}
protected void WriteTextBodiesRecursive(Entity e) {
if (e.Body is Multipart) {
Multipart multipart =(Multipart) e.Body;
IList parts = multipart.BodyParts;
for (int i=0; i < parts.Count; i++) {
WriteTextBodiesRecursive( (Entity)parts[i] );
}
} else if (e.Body is MimeMessage) {
WriteTextBodiesRecursive( (MimeMessage)e.Body );
} else {
IBody b = e.Body;
if (b is ITextBody) {
Console.WriteLine("-----textbody---\r\n{0}\r\n\r\n", ((ITextBody)b).Reader.ReadToEnd() );
}
}
}
Q: Does the library support "multipart/x-mixed-replace" content type?
I want to parse infinite MIME stream and catch events
when new part of "multipart/x-mixed-replace" multipart body is received.
A: Yes, Mime4Net supports "multipart/x-mixed-replace". Please look at
sample that illustrates how M4N can be used
for parsing infinite MIME streams.
Q: Does the library compile and function 100% if compiled against Mono 1.0+?
If not, do you have a Linux version in C/C++?
A: Mime4Net version for .Net 1.1 works fine under Mono. Mime4Net is 100% written on C#
Q: Are there any utilities to parse the "From" field to extract eg the ip address?
A: See Mailbox structure for details.
Q: Do we need to specifically dispose of any objects to avoid memory leaks?
A: No, just make sure that all references to MimeMessage structure are released.
Q: How do I find the text/plain message and the Header Data such as From/To etc?.
A: You can work directly with MimeMessage structure. Following code illustrates how you can work with structured header data:
MimeMessage msg = new MimeMessage(msgStream);
MimeField fromFld = message.Header.GetField(MimeField.From);
if (fromFld is MailboxListField) {
// write first email domain
Console.WriteLine( ((MailboxListField)fromFld).MailboxList[0].Domain);
}
Q: How can I iterate through header fields looking for eg IsFrom or specific name and then use the field body?
A: You can access any field directly thought Header.GetField method.
Q: If I want to read the attachment, is the decoding (eg from base 64) carried out for me or will I have to do this? Similarly,
when reading the body will the reader take into account the specified encoding?
A: Yes, M4N automatically wraps output stream with base64 or quoted-printable decoding filters according to encoding specified for this part inside MIME message.
Q: Is there a way to override the charset of a MimeMessage (particularly the HTML and text parts) with an arbitrary charset?
A: Yes, there is a way to change default charset (is taken from 'Content-Type' header). To do this
1. 'Content-Type' header in the body part with text body should be changed to new one
2. Current text body context should be copied into Stream with new encoding
3. Old body part body should be replaced with new one (using new Stream and new encoding)
Following code illustrates these steps:
MimeMessage m;
// lets assume that we wanna change charset in first text part of multipart message
BodyPart bp = ((Multipart)m.Body).BodyParts[0] as BodyPart;
bp.Header.ChangeField(MimeField.ContentType, MimeField.Parse(MimeField.ContentType, "text/html; charset=koi8-r") );
string bodyContent = ((ITextBody)bp.Body).Reader.ReadToEnd();
MemoryStream bodyStream = new MemoryStream();
StreamWriter bodyStreamWr = new StreamWriter(bodyStream, bp.CurrentEncoding);
bodyStreamWr.Write(bodyContent);
bp.Body = new MemoryTextBody(bodyStream, bp.Charset);