IMime Part Interface
An interface for a leaf-node MIME part that contains content such as the message body text or an attachment.
Definition
Namespace: MimeKit
Assembly: MimeKit.Core (in MimeKit.Core.dll) Version: 5.0.0
Assembly: MimeKit.Core (in MimeKit.Core.dll) Version: 5.0.0
C#
public interface IMimePart : IMimeEntity,
IDisposable- Implements
- IMimeEntity, IDisposable
Remarks
A leaf-node MIME part that contains content such as the message body text or an attachment.
Example
C#
foreach (var attachment in message.Attachments) {
if (attachment is MessagePart) {
var fileName = attachment.ContentDisposition?.FileName ?? attachment.ContentType.Name;
var rfc822 = (MessagePart) attachment;
if (string.IsNullOrEmpty (fileName))
fileName = "attached-message.eml";
// make sure that the filename value does not contain a full path or invalid path characters
fileName = Path.GetFileName (fileName);
using (var stream = File.Create (fileName))
rfc822.Message.WriteTo (stream);
} else {
var part = (MimePart) attachment;
var fileName = part.FileName;
if (string.IsNullOrEmpty (fileName))
fileName = "untitled.dat";
// make sure that the filename value does not contain a full path or invalid path characters
fileName = Path.GetFileName (fileName);
using (var stream = File.Create (fileName))
part.Content.DecodeTo (stream);
}
}
Properties
| Content | Get or set the MIME content. |
| ContentBase |
Get or set the base content URI.
(Inherited from IMimeEntity) |
| ContentDescription | Get or set the description of the content if available. |
| ContentDisposition |
Get or set the content disposition.
(Inherited from IMimeEntity) |
| ContentDuration | Get or set the duration of the content if available. |
| ContentId |
Get or set the Content-Id.
(Inherited from IMimeEntity) |
| ContentLocation |
Get or set the content location.
(Inherited from IMimeEntity) |
| ContentMd5 | Get or set the md5sum of the content. |
| ContentTransferEncoding | Get or set the content transfer encoding. |
| ContentType |
Get the type of the content.
(Inherited from IMimeEntity) |
| FileName | Get or set the name of the file. |
| Headers |
Get the list of headers.
(Inherited from IMimeEntity) |
| IsAttachment |
Get a value indicating whether this entity is an attachment.
(Inherited from IMimeEntity) |
Methods
| Accept |
Dispatches to the specific visit method for this MIME entity.
(Inherited from IMimeEntity) |
| ComputeContentMd5 | Compute the MD5 checksum of the content. |
| Dispose | Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. (Inherited from IDisposable) |
| GetBestEncoding(EncodingConstraint, CancellationToken) | Calculate the most efficient content encoding given the specified constraint. |
| GetBestEncoding(EncodingConstraint, Int32, CancellationToken) | Calculate the most efficient content encoding given the specified constraint. |
| Prepare |
Prepare the MIME entity for transport using the specified encoding constraints.
(Inherited from IMimeEntity) |
| VerifyContentMd5 | Verify the Content-Md5 value against an independently computed md5sum. |
| WriteTo(Stream, CancellationToken) |
Write the IMimeEntity to the specified output stream.
(Inherited from IMimeEntity) |
| WriteTo(String, CancellationToken) |
Write the IMimeEntity to the specified file.
(Inherited from IMimeEntity) |
| WriteTo(FormatOptions, Stream, CancellationToken) |
Write the IMimeEntity to the specified output stream.
(Inherited from IMimeEntity) |
| WriteTo(FormatOptions, String, CancellationToken) |
Write the IMimeEntity to the specified file.
(Inherited from IMimeEntity) |
| WriteTo(Stream, Boolean, CancellationToken) |
Write the IMimeEntity to the specified output stream.
(Inherited from IMimeEntity) |
| WriteTo(String, Boolean, CancellationToken) |
Write the IMimeEntity to the specified file.
(Inherited from IMimeEntity) |
| WriteTo(FormatOptions, Stream, Boolean, CancellationToken) |
Write the IMimeEntity to the specified output stream.
(Inherited from IMimeEntity) |
| WriteTo(FormatOptions, String, Boolean, CancellationToken) |
Write the IMimeEntity to the specified file.
(Inherited from IMimeEntity) |
| WriteToAsync(Stream, CancellationToken) |
Asynchronously write the IMimeEntity to the specified output stream.
(Inherited from IMimeEntity) |
| WriteToAsync(String, CancellationToken) |
Asynchronously write the IMimeEntity to the specified file.
(Inherited from IMimeEntity) |
| WriteToAsync(FormatOptions, Stream, CancellationToken) |
Asynchronously write the IMimeEntity to the specified output stream.
(Inherited from IMimeEntity) |
| WriteToAsync(FormatOptions, String, CancellationToken) |
Asynchronously write the IMimeEntity to the specified file.
(Inherited from IMimeEntity) |
| WriteToAsync(Stream, Boolean, CancellationToken) |
Asynchronously write the IMimeEntity to the specified output stream.
(Inherited from IMimeEntity) |
| WriteToAsync(String, Boolean, CancellationToken) |
Asynchronously write the IMimeEntity to the specified file.
(Inherited from IMimeEntity) |
| WriteToAsync(FormatOptions, Stream, Boolean, CancellationToken) |
Asynchronously write the IMimeEntity to the specified output stream.
(Inherited from IMimeEntity) |
| WriteToAsync(FormatOptions, String, Boolean, CancellationToken) |
Asynchronously write the IMimeEntity to the specified file.
(Inherited from IMimeEntity) |