ContentTypeParameters Property

Get the list of parameters on the ContentType.

Definition

Namespace: MimeKit
Assembly: MimeKit.Core (in MimeKit.Core.dll) Version: 5.0.0
C#
public ParameterList Parameters { get; }

Property Value

ParameterList
The parameters.

Remarks

In addition to the media type and subtype, the Content-Type header may also contain parameters to provide further hints to the receiving client as to how to process or display the content.

Example

C#
                    public static MimePart CreateCsvAttachment (string fileName, Stream content)
{
    var contentType = new ContentType ("text", "csv") {
        // The Charset, Name, Format and Boundary properties are shortcuts for getting
        // and setting the corresponding parameters.
        Charset = "utf-8",
        Name = Path.GetFileName (fileName)
    };

    // Any other parameter can be accessed via the Parameters collection.
    contentType.Parameters.Add ("header", "present");

    // Parameters with non-ASCII values will be encoded automatically, using the rfc2231
    // encoding by default. The FormatOptions.ParameterEncodingMethod property can be used
    // to control this.
    return new MimePart (contentType) {
        Content = new MimeContent (content),
        ContentDisposition = new ContentDisposition (ContentDisposition.Attachment),
        ContentTransferEncoding = ContentEncoding.Base64,
        FileName = Path.GetFileName (fileName)
    };
}
                  

See Also