Search code examples
c#.netxmlmultipartmimekit

Only using Multipart & MimePart in .Net MimeKit


I just started using this.

  1. Multipart objMP = new Multipart("related", {"What kind of array goes here?"});

  2. Is there a way I can write to the mimepart from a string instead of from a stream?


Solution

  • Use this API instead: Multipart .ctor (String subtype)

    Or, if you want to create a multipart/related part, you can also use MultipartRelated .ctor ()

    To answer your first question, though...

    1- Multipart objMP = new Multipart("related", {"What kind of array goes here?"});

    The .ctor that you are trying to figure out how to use is meant to be used like this:

    new Multipart ("related",
        new Header ("X-Custom-Header", "value"),
        new TextPart ("plain") {
            Text = "This is some text content."
        },
        new MimePart ("application", "octet-stream") {
            FileName = "attachment.pdf",
            ContentTransferEncoding = ContentEncoding.Base64,
            Content = new MimeContent (dataStream)
        });