Mime MessagePrepare Method
Prepare the message for transport using the specified encoding constraints.
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 virtual void Prepare(
EncodingConstraint constraint,
int maxLineLength = 78
)Parameters
- constraint EncodingConstraint
- The encoding constraint.
- maxLineLength Int32 (Optional)
- The maximum allowable length for a line (not counting the CRLF). Must be between 60 and 998 (inclusive).
Implements
IMimeMessagePrepare(EncodingConstraint, Int32)Remarks
Prepares the message for transport using the specified encoding constraints.
Example
C#
public static void PrepareForSending (MimeMessage message)
{
// Before sending a message via a transport that only supports 7-bit data and lines
// no longer than 998 characters, make sure that each MIME part has an appropriate
// Content-Transfer-Encoding. SmtpClient in MailKit does this automatically based on
// the extensions supported by the SMTP server.
message.Prepare (EncodingConstraint.SevenBit);
// Prepare() also verifies that the line lengths are within the limit, so it is
// equally useful for other transports that have line-length restrictions.
message.Prepare (EncodingConstraint.EightBit, 78);
}
Exceptions
| ArgumentOutOfRangeException |
maxLineLength is not between 60 and 998 (inclusive). -or- constraint is not a valid value. |