MailBee.NET Objects 3.1

MailMessage.Clear Method 

Removes the specified elements from the message.

public void Clear(
   MessageElements elements
);

Parameters

elements
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.

Example

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.

[C#]
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");
    }
}
[Visual Basic]
Imports MailBee
Imports MailBee.Pop3Mail
Imports MailBee.Mime

Module Sample
    Sub Main(ByVal args As String())
        ' Download the first mail message from the specified POP3 account.
        Dim msg As MailMessage = 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 Or MessageElements.Recipients)
        msg.SaveMessage("C:\Temp\msg.eml")
    End Sub
End Module

See Also

MailMessage Class | MailBee.Mime Namespace | Reset