MessagePart

Overview

The MessagePart class is used by the MimeMessage class to describe the whole MIME message tree.

MIME messages may contain large tree structures, and the MessagePart represents a node of this structure. It may be either be a leaf in the structure or an internal node with links to other MessagePart instances. The root of the message tree is an MimeMessage instance.

Note: Please note that properies representing header values, like ContentType and the Header collection itself are not syncronised automatically, so direct changes to any for these properties will result in differencies between message headers collection and properties intended to represent values of these headers. It is not recommended to direcly set any of this class' properties.

There is no need to instantiate this class directly.

For internal use only.

Location

  • Reference:
    • RemObjects.InternetPack.dll  .NET, .NET Core 5.0, .NET Standard 2.0
    • RemObjects.InternetPack.fx  Island
    • libRemObjects.InternetPack.fx  Toffee
  • Namespace: RemObjects.InternetPack.Messages.Mime


 

constructor

Creates a new instance of the MessagePart class.

 

constructor(rawBody: array of Byte; headers: MessageHeader)

 

MessagePart(Byte[] rawBody, MessageHeader headers)

 

init(_ rawBody: Byte..., _ headers: MessageHeader)

 

Sub New(rawBody As Byte(), headers As MessageHeader)

Parameters:

  • rawBody: Raw message part body.
  • headers: Collection of message headers.

Body  virtual

Gets or sets the parsed body of the current MessagePart.

Value if is property is null for mult-part MIME messages. Use the IsMultiPart to check if current MessagePart instance represents a multi-part MIME message.

 

property Body: array of Byte read write;

 

Byte[] Body { get; set; }

 

var Body: Byte... { get{} set{} }

 

Property Body() As Byte()

BodyEncoding  virtual

Gets or sets encoding used to parse the message body.

The value of this property equals to the charset part of the Content-Type message header.

 

property BodyEncoding: Encoding read write;

 

Encoding BodyEncoding { get; set; }

 

var BodyEncoding: Encoding { get{} set{} }

 

Property BodyEncoding() As Encoding

ContentDescription  virtual

Gets a human-readable body description.

The value of this property equals to the Content-Description message header value.

 

property ContentDescription: String read write;

 

String ContentDescription { get; set; }

 

var ContentDescription: String { get{} set{} }

 

Property ContentDescription() As String

ContentDisposition  virtual

Gets disposition of the current MessagePart instance.

In case of an email message this property defines if the current MessagePart represents information to be displayed, like message body, or it represents and attachment.

The value of this property correspnds to the Content-Disposition message header value.

 

property ContentDisposition: ContentDisposition read write;

 

ContentDisposition ContentDisposition { get; set; }

 

var ContentDisposition: ContentDisposition { get{} set{} }

 

Property ContentDisposition() As ContentDisposition

ContentId  virtual

Gets ID of the current content part, like an attached image.

The value of this property correspnds to the Content-ID message header value.

 

property ContentId: String read write;

 

String ContentId { get; set; }

 

var ContentId: String { get{} set{} }

 

Property ContentId() As String

ContentTransferEncoding  virtual

Gets encoding used to encode and transfer data.

The value of this property correspnds to the Content-Transfer-Encoding message header value. If no such header was set then default value SevenBit is used.

 

property ContentTransferEncoding: ContentTransferEncoding read write;

 

ContentTransferEncoding ContentTransferEncoding { get; set; }

 

var ContentTransferEncoding: ContentTransferEncoding { get{} set{} }

 

Property ContentTransferEncoding() As ContentTransferEncoding

ContentType  virtual

Gets or sets content type.

The value of this property correspnds to the Content-Type message header value. If no such header was set then default value application/atom+xml is used.

 

property ContentType: ContentType read write;

 

ContentType ContentType { get; set; }

 

var ContentType: ContentType { get{} set{} }

 

Property ContentType() As ContentType

FileName  virtual

Gets or sets attachment file name.

The value of this property correspnds to the Content-Disposition message header value.

 

property FileName: String read write;

 

String FileName { get; set; }

 

var FileName: String { get{} set{} }

 

Property FileName() As String

GetBodyAsText  virtual

Returns text representation of the MessagePart's body.

 

method GetBodyAsText: String

 

String GetBodyAsText()

 

func GetBodyAsText() -> String

 

Function GetBodyAsText() As String

Gets collection of all header values.

 

property Header: MessageHeader read write;

 

MessageHeader Header { get; set; }

 

var Header: MessageHeader { get{} set{} }

 

Property Header() As MessageHeader

IsAttachment  virtual

Gets a flag indicating whether the current MessagePart instance represents an message attachment.

A MessagePart is considered to be an attachment, if

  • it is not holding text and is not a multi-part MIME message;

or

  • it has a Content-Disposition header that says it is an attachment.

 

property IsAttachment: Boolean read;

 

Boolean IsAttachment { get; }

 

var IsAttachment: Boolean { get{} }

 

ReadOnly Property IsAttachment() As Boolean

IsMultiPart  virtual

Gets a flag indicating whether the current MessagePart instance is a multi-part MIME message.

The MessagePart is considered to be a multi-part message if its ContentType media type header value begins with multipart/.

 

property IsMultiPart: Boolean read;

 

Boolean IsMultiPart { get; }

 

var IsMultiPart: Boolean { get{} }

 

ReadOnly Property IsMultiPart() As Boolean

IsText  virtual

Gets a flag indicating whether the current MessagePart instance holds message text.

 

property IsText: Boolean read;

 

Boolean IsText { get; }

 

var IsText: Boolean { get{} }

 

ReadOnly Property IsText() As Boolean

MessageParts  virtual

Gets a list of MessagePart instances contained in the current MessagePart instance.

For non-multipart message parts this property contains null.

 

property MessageParts: List<MessagePart> read write;

 

List<MessagePart> MessageParts { get; set; }

 

var MessageParts: List<MessagePart> { get{} set{} }

 

Property MessageParts() As List<MessagePart>

ToHttpResponseBody  virtual

Fills provided StringBuilder instance with serialized MessagePart contents.

For multi-part messages all MessagePart contained in the current instance are serialized too.

 

method ToHttpResponseBody(builder: StringBuilder)

 

void ToHttpResponseBody(StringBuilder builder)

 

func ToHttpResponseBody(_ builder: StringBuilder)

 

Sub ToHttpResponseBody(builder As StringBuilder)

Parameters:

  • builder: StringBuilder instance that will contain serialized MessagePart contents.

 

Body  virtual

Gets or sets the parsed body of the current MessagePart.

Value if is property is null for mult-part MIME messages. Use the IsMultiPart to check if current MessagePart instance represents a multi-part MIME message.

 

property Body: array of Byte read write;

 

Byte[] Body { get; set; }

 

var Body: Byte... { get{} set{} }

 

Property Body() As Byte()

BodyEncoding  virtual

Gets or sets encoding used to parse the message body.

The value of this property equals to the charset part of the Content-Type message header.

 

property BodyEncoding: Encoding read write;

 

Encoding BodyEncoding { get; set; }

 

var BodyEncoding: Encoding { get{} set{} }

 

Property BodyEncoding() As Encoding

ContentDescription  virtual

Gets a human-readable body description.

The value of this property equals to the Content-Description message header value.

 

property ContentDescription: String read write;

 

String ContentDescription { get; set; }

 

var ContentDescription: String { get{} set{} }

 

Property ContentDescription() As String

ContentDisposition  virtual

Gets disposition of the current MessagePart instance.

In case of an email message this property defines if the current MessagePart represents information to be displayed, like message body, or it represents and attachment.

The value of this property correspnds to the Content-Disposition message header value.

 

property ContentDisposition: ContentDisposition read write;

 

ContentDisposition ContentDisposition { get; set; }

 

var ContentDisposition: ContentDisposition { get{} set{} }

 

Property ContentDisposition() As ContentDisposition

ContentId  virtual

Gets ID of the current content part, like an attached image.

The value of this property correspnds to the Content-ID message header value.

 

property ContentId: String read write;

 

String ContentId { get; set; }

 

var ContentId: String { get{} set{} }

 

Property ContentId() As String

ContentTransferEncoding  virtual

Gets encoding used to encode and transfer data.

The value of this property correspnds to the Content-Transfer-Encoding message header value. If no such header was set then default value SevenBit is used.

 

property ContentTransferEncoding: ContentTransferEncoding read write;

 

ContentTransferEncoding ContentTransferEncoding { get; set; }

 

var ContentTransferEncoding: ContentTransferEncoding { get{} set{} }

 

Property ContentTransferEncoding() As ContentTransferEncoding

ContentType  virtual

Gets or sets content type.

The value of this property correspnds to the Content-Type message header value. If no such header was set then default value application/atom+xml is used.

 

property ContentType: ContentType read write;

 

ContentType ContentType { get; set; }

 

var ContentType: ContentType { get{} set{} }

 

Property ContentType() As ContentType

FileName  virtual

Gets or sets attachment file name.

The value of this property correspnds to the Content-Disposition message header value.

 

property FileName: String read write;

 

String FileName { get; set; }

 

var FileName: String { get{} set{} }

 

Property FileName() As String

Gets collection of all header values.

 

property Header: MessageHeader read write;

 

MessageHeader Header { get; set; }

 

var Header: MessageHeader { get{} set{} }

 

Property Header() As MessageHeader

IsAttachment  virtual

Gets a flag indicating whether the current MessagePart instance represents an message attachment.

A MessagePart is considered to be an attachment, if

  • it is not holding text and is not a multi-part MIME message;

or

  • it has a Content-Disposition header that says it is an attachment.

 

property IsAttachment: Boolean read;

 

Boolean IsAttachment { get; }

 

var IsAttachment: Boolean { get{} }

 

ReadOnly Property IsAttachment() As Boolean

IsMultiPart  virtual

Gets a flag indicating whether the current MessagePart instance is a multi-part MIME message.

The MessagePart is considered to be a multi-part message if its ContentType media type header value begins with multipart/.

 

property IsMultiPart: Boolean read;

 

Boolean IsMultiPart { get; }

 

var IsMultiPart: Boolean { get{} }

 

ReadOnly Property IsMultiPart() As Boolean

IsText  virtual

Gets a flag indicating whether the current MessagePart instance holds message text.

 

property IsText: Boolean read;

 

Boolean IsText { get; }

 

var IsText: Boolean { get{} }

 

ReadOnly Property IsText() As Boolean

MessageParts  virtual

Gets a list of MessagePart instances contained in the current MessagePart instance.

For non-multipart message parts this property contains null.

 

property MessageParts: List<MessagePart> read write;

 

List<MessagePart> MessageParts { get; set; }

 

var MessageParts: List<MessagePart> { get{} set{} }

 

Property MessageParts() As List<MessagePart>

 

constructor

Creates a new instance of the MessagePart class.

 

constructor(rawBody: array of Byte; headers: MessageHeader)

 

MessagePart(Byte[] rawBody, MessageHeader headers)

 

init(_ rawBody: Byte..., _ headers: MessageHeader)

 

Sub New(rawBody As Byte(), headers As MessageHeader)

Parameters:

  • rawBody: Raw message part body.
  • headers: Collection of message headers.

GetBodyAsText  virtual

Returns text representation of the MessagePart's body.

 

method GetBodyAsText: String

 

String GetBodyAsText()

 

func GetBodyAsText() -> String

 

Function GetBodyAsText() As String

ToHttpResponseBody  virtual

Fills provided StringBuilder instance with serialized MessagePart contents.

For multi-part messages all MessagePart contained in the current instance are serialized too.

 

method ToHttpResponseBody(builder: StringBuilder)

 

void ToHttpResponseBody(StringBuilder builder)

 

func ToHttpResponseBody(_ builder: StringBuilder)

 

Sub ToHttpResponseBody(builder As StringBuilder)

Parameters:

  • builder: StringBuilder instance that will contain serialized MessagePart contents.