MailMessageAppendPartialMessage Method |
Namespace: MailBee.Mime
Exception | Condition |
---|---|
MailBeeInvalidArgumentException | nextPart is a null reference (Nothing in Visual Basic) or not a partial message. |
MailBeeInvalidStateException | The message is not partial, so another partial message can't be added to it. |
Some mail client programs can split large messages into a number of smaller messages before sending and then send these smaller e-mails separately. This technique was used to overcome limitations of maximum size of a message which existed on some mail servers. Nowadays, this practice is not used but MailBee is still capable of parsing such messages. To assembly a message from its parts (they have message/partial in their ContentType), you should get the first part (having PartIndex set to 1), and append the remaining messages in the correct order (with PartIndex set to 2, 3, etc) using AppendPartialMessage(MailMessage) until it returns true. AppendPartialMessage(MailMessage) returns true when you append a message having PartIndex equal to PartCount.
Use PartCount property to determine if the mail message is split (and so it's needed to get the remaining parts and join them with AppendPartialMessage(MailMessage) method).
Use PartIndex property to obtain the index of the message so that you would be able to pass the messages to be appended by AppendPartialMessage(MailMessage) method in proper order (from 1 to PartCount).
using MailBee; using MailBee.Mime; class Sample { static void Main(string[] args) { MailMessage newMsg = new MailMessage(); MailMessage partialMsg = new MailMessage(); newMsg.LoadMessage(@"C:\Docs\splitmail\1of4.eml"); // Append 3 partial messages that are loaded from disk. for (int i = 2; i <= 4; i++) { partialMsg.LoadMessage(string.Format(@"C:\Docs\splitmail\{0}of4.eml", i)); newMsg.AppendPartialMessage(partialMsg); } // Save the entire message to disk. newMsg.SaveMessage(@"C:\Temp\entire.eml"); } }