SocketTools .NET Edition

MailMessage.DecodeText Method (String, String, MimeCharacterSet, MimeEncoding)

Decode a string which was previously encoded using base64 or quoted-printable encoding.

[Visual Basic]
Overloads Public Function DecodeText( _
   ByVal encodedText As String, _
   ByRef messageText As String, _
   ByVal charSet As MimeCharacterSet, _
   ByVal encoding As MimeEncoding _
) As Integer
[C#]
public int DecodeText(
   string encodedText,
   ref string messageText,
   MimeCharacterSet charSet,
   MimeEncoding encoding
);

Parameters

encodedText
A string which contains the encoded text which should be decoded.
messageText
A string variable passed by reference which will contain the decoded text when the method returns.
charSet
A MimeCharacterSet enumeration which specifies the character set to use when decoding the encoded text. If this value does not match the character set used when the text was originally encoded, the resulting output text may be invalid.
encoding
A MimeEncoding enumeration which specifies the content encoding type to use when decoding the text.

Return Value

The number of characters of decoded text. A return value of zero indicates no text has been decoded. If the method fails, it will return -1 and the LastError property can be used to determine the cause of the failure. In most cases where the method fails, it is because an invalid character set or encoding type has been specified.

Remarks

This method provides a means to decode text that was previously encoded using either base64 or quoted-printable encoding. In most cases, it is not necessary to use this method because the message parser will detect which character set and encoding was used, then automatically decode the message text if necessary.

The value of the charSet parameter does not affect the resulting output text, it is only used when decoding the input text. The previous contents of the messageText string will be replaced by the decoded text, and the output string will always be Unicode.

If the charSet parameter is specified as charsetUTF16, the encoding type must be encodingBase64. Other encoding methods are not supported for Unicode strings and will cause the method to fail. In most cases, it is preferable to always use encodingBase64 as the encoding method, with quoted-printable encoding only used for legacy support. If an unsupported encoding type is specified, this method will return -1 and the output text string will be empty. This method cannot be used to decode uuencoded text.

See Also

MailMessage Class | SocketTools Namespace | MailMessage.DecodeText Overload List