MailMessageClear Method
Removes the specified elements from the message.

Namespace: MailBee.Mime
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 12.4 build 677 for .NET 4.5
Syntax
public void Clear(
	MessageElements elements
)

Parameters

elements
Type: MailBee.MimeMessageElements
A set of MessageElements flags specifying which elements should be removed from the message.
Remarks

To clear the entire message (i.e. to reset all its properties to default values), the developer should use Reset method.

To clear raw body of the message, you can use Msg.Clear(MessageElements.RawBody) call. This is useful if you already received an e-mail and parsed it. If you have no plans to further access the raw data of the e-mail (e.g. write the e-mail into .EML file), you do not need the raw body data (which might be very large), and can free it. However, if you then call and method or property which operates on the raw body (such as Size property), the message will be rebuilt and the raw body regenerated. Be sure to call all such properties and methods BEFORE clearing the raw body.

Another purpose of Msg.Clear(MessageElements.RawBody) is after sending a very large e-mail. For instance, you're sending multiple very large e-mails and want to have as much free memory as possible before every e-mail gets built to avoid out-of-memory issues. You can use Reset method and then call Collect(Int32) (GC.Collect) but this will also remove all the attachments and other parts of the message. In case if you want to send the same attachments in multiple e-mails, this would degrade performance. With Msg.Clear(MessageElements.RawBody) you can preserve the attachments already loaded and free only the generated raw message data.

Examples
This sample downloads the message from the specified POP3 account, removes all message attachments and recipients (other data is not removed), and saves this message to disk.
using MailBee;
using MailBee.Pop3Mail;
using MailBee.Mime;

class Sample
{
    static void Main(string[] args)
    {
        // Download the first mail message from the specified POP3 account.
        MailMessage msg = Pop3.QuickDownloadMessage("pop.mail.com", "kathy", "password", 1);

        // Remove all attachments and recipients from the message and save this message to disk.
        msg.Clear(MessageElements.Attachments | MessageElements.Recipients);
        msg.SaveMessage(@"C:\Temp\msg.eml");
    }
}
See Also