Add watermarks to email attachments

The API allows you to add watermark to all the attachments of supported types in an email message as shown in the following code sample.


TextWatermark watermark = new TextWatermark("Test watermark", new Font("Arial", 19));
EmailLoadOptions loadOptions = new EmailLoadOptions();
// Specify an absolute or relative path to your document. Ex: @"C:\Docs\message.msg"
using (Watermarker watermarker = new Watermarker("message.msg", loadOptions))
    EmailContent content = watermarker.GetContent<EmailContent>();
    foreach (EmailAttachment attachment in content.Attachments)
        // Check if the attached file is supported by GroupDocs.Watermark
        IDocumentInfo info = attachment.GetDocumentInfo();
        if (info.FileType != FileType.Unknown && !info.IsEncrypted)
            // Load the attached document
            using (Watermarker attachedWatermarker = attachment.CreateWatermarker())
                // Add wateramrk

                // Save changes in the attached file

    // Save changes

Advanced use cases