Load() 공개 정적인 메소드

Load a MimeMessage from the specified stream.
Loads a MimeMessage from the given stream, using the specified ParserOptions.
/// is null. /// -or- /// is null. /// /// The operation was canceled via the cancellation token. /// /// There was an error parsing the entity. /// /// An I/O error occurred. ///
public static Load ( ParserOptions options, Stream stream, CancellationToken cancellationToken = default(CancellationToken) ) : MimeMessage
options ParserOptions The parser options.
stream Stream The stream.
cancellationToken System.Threading.CancellationToken A cancellation token.
리턴 MimeMessage
예제 #1
0
        MimeEntity CreateAttachment(ContentType contentType, string path, Stream stream)
        {
            var        fileName = GetFileName(path);
            MimeEntity attachment;

            if (contentType.IsMimeType("message", "rfc822"))
            {
                var message = MimeMessage.Load(stream);

                attachment = new MessagePart {
                    Message = message
                };
            }
            else
            {
                MimePart part;

                if (contentType.IsMimeType("text", "*"))
                {
                    // TODO: should we try to auto-detect charsets if no charset parameter is specified?
                    part = new TextPart(contentType);
                }
                else
                {
                    part = new MimePart(contentType);
                }

                LoadContent(part, stream);
                attachment = part;
            }

            attachment.ContentDisposition          = new ContentDisposition(linked ? ContentDisposition.Inline : ContentDisposition.Attachment);
            attachment.ContentDisposition.FileName = fileName;
            attachment.ContentType.Name            = fileName;

            if (linked)
            {
                attachment.ContentLocation = new Uri(fileName, UriKind.Relative);
            }

            return(attachment);
        }