CkMime C++ Class Reference (Visual C++)

CkMime

Chilkat MIME allows you to easily create and manipulate MIME and S/MIME messages from within your applications.

Properties

void get_Boundary(CkString &str);
void put_Boundary(const char *newVal);

The boundary string to be used if this is a multipart message. By default, the boundary is automatically generated to be a unique and random string, so explicitly setting the boundary is not necessary.

void get_Charset(CkString &sb);
void put_Charset(const char *newVal);

The charset, such as "ISO-8859-1" or "utf-8"

void get_ContentType(CkString &str);
void put_ContentType(const char *newVal);

The MIME content type, such as "text/plain", "text/html", "multipart/alternative", "multipart/mixed", etc.

void get_Disposition(CkString &str);
void put_Disposition(const char *newVal);

The content disposition, which can be "attachment", "inline", etc.

void get_Encoding(CkString &str);
void put_Encoding(const char *newVal);

A content encoding such as "base64", "quoted-printable", "7bit", "8bit", etc.

void get_Filename(CkString &str);
void put_Filename(const char *newVal);

The filename when the content disposition is "attachment".

void LastErrorHtml(CkString &str);

Error information in HTML format for the last method called.

void LastErrorText(CkString &str);

Error information in plain-text format for the last method called.

void LastErrorXml(CkString &str);

Error information in XML format for the last method called.

void get_Micalg(CkString &str);
void put_Micalg(const char *newVal);

The MIC algorithm, such as "SHA1" when the content type is multipart/signed. Properties such as this are rarely set manually, as Chilkat MIME automatically sets it to the correct value when creating a signed message.

void get_Name(CkString &str);
void put_Name(const char *newVal);

The name attribute of the content-type header field.

long get_NumEncryptCerts(void);

The number of certificates use for encryption. This property is set after UnwrapSecurity is called.

long get_NumHeaderFields(void);

The number of header fields. Header field names and values can be retrieved by index (starting at 0) by calling GetHeaderFieldName and GetHeaderFieldValue.

long get_NumParts(void);

The number of sub-parts contained within this message. Each sub-part is a complete Chilkat MIME message itself.

long get_NumSignerCerts(void);

The number of certificates use for signing. This property is set after UnwrapSecurity is called.

void get_Protocol(CkString &str);
void put_Protocol(const char *newVal);

A protocol such as "application/x-pkcs7-signature". Properties such as this are rarely set manually, as Chilkat MIME automatically sets it to the correct value when creating a signed message.

bool get_UnwrapExtras(void);
void put_UnwrapExtras(bool newVal);

Controls whether extra (informative) header fields are added to the MIME message when unwrapping security.

bool get_UseMmDescription(void);
void put_UseMmDescription(bool newVal);

Controls whether the boilerplate text "This is a multi-part message in MIME format." is used as the body content of a multipart MIME part.

bool get_Utf8(void) const;
void put_Utf8(bool b);

When set to true, all "const char *" arguments are expected to be utf-8 strings. If set to false, the "const char *" arguments are expected to be ANSI strings.

void get_Version(CkString &str);

The version, such as "1.0.0".

Methods

bool AddDetachedSignature(const CkCert & cert);

Signs the message using the certificate provided. If successful, the message is converted to "multipart/signed" and the original message will be contained in the first sub-part.

bool AddDetachedSignature2(const CkCert & cert, bool transferHeaderFields);

Same as AddDetachedSignature, except an extra argument is provided to control whether header fields from the calling MIME object are transferred to the content part of the multipart/signed object. This method transforms the calling object into a multipart/signed MIME with two sub-parts. The first contains the original content of the calling object, and the second contains the digital signature.

Returns true for success, false for failure.

bool AddDetachedSignaturePk(const CkCert & cert, const CkPrivateKey & privateKey);

To be documented soon.

bool AddDetachedSignaturePk2(const CkCert & cert, const CkPrivateKey & privateKey, bool transferHeaderFields);

To be documented soon...

bool AddHeaderField(const char * name, const char * value);

Adds a header field to the MIME.

bool AppendPart(const CkMime & mime);

Appends a MIME message to the sub-parts of this message. Arbitrarily complex messages with unlimited nesting levels can be created. If the calling Mime object is not already multipart, it is automatically converted to multipart/mixed first.

bool AppendPartFromFile(const char * filename);

Loads a file and creates a Mime message object using the file extension to determine the content type, and adds it as a sub-part to the calling object.

bool ContainsEncryptedParts();

Returns true if the MIME message contains encrypted parts.

bool ContainsSignedParts();

Returns true if the MIME message contains signed parts.

void Convert8Bit();

(PreRelease) Changes the content-transfer-encoding to "base64" for all 8bit or binary MIME subparts. This allows for the MIME to be exported as a string via the GetMime method.

void ConvertToMultipartAlt();

To be documented soon.

void ConvertToMultipartMixed();

To be documented soon.

bool ConvertToSigned(const CkCert & cert);

Digitally signs the calling Mime object, but rather than the signature becoming a sub-part of the message (as in AddDetachedSignature) it becomes part of the message. In S/MIME terms, the message becomes application/x-pkcs7-mime rather than multipart/signed.

bool ConvertToSignedPk(const CkCert & cert, const CkPrivateKey & privateKey);

To be documented soon...

bool Decrypt();

To be documented soon.

bool Decrypt2(const CkCert & cert, const CkPrivateKey & privateKey);

To be documented soon.

bool Encrypt(const CkCert & cert);

Encrypt a MIME message object using a digital certificate.

bool GetBodyBinary(CkByteData & db);

Returns the body of the MIME message as a block of binary data. The body is automatically converted from its encoding type, such as base64 or quoted-printable, before being returned.

bool GetBodyDecoded(CkString & decodedBody);

Returns the body of the MIME message as a string. The body is automatically converted from its encoding type, such as base64 or quoted-printable, before being returned.

Returns true for success, false for failure.

bool GetBodyEncoded(CkString & encodedBody);

Returns the body of the MIME message as a String. The body is explicitly not decoded from it's encoding type, so if it was represented in Base64, you will get the Base64 encoded body, as an example.

Returns true for success, false for failure.

CkCert * GetEncryptCert(long index);

Returns the Nth certificate used for encryption. Most likely the message was only encrypted once, and if so, the index should be set to 0.

void GetEntireBody(CkString & str);

Returns the entire MIME body, including all sub-parts.

Returns true for success, false for failure.

void GetEntireHead(CkString & str);

Returns the MIME header.

Returns true for success, false for failure.

bool GetHeaderField(const char * name, CkString & value);

Returns the content of a MIME header field. The "fieldName" is case-insensitive, and if the MIME header field does not exist, an empty string is returned.

Returns true for success, false for failure.

bool GetHeaderFieldName(int index, CkString & fieldName);

Returns the Nth MIME header field name.

Returns true for success, false for failure.

bool GetHeaderFieldValue(int index, CkString & fieldValue);

Returns the Nth MIME header field value.

Returns true for success, false for failure.

bool GetMime(CkString & mime);

Returns a string containing the complete MIME message, including all sub-parts.

Returns true for success, false for failure.

bool GetMimeBytes(CkByteData & outBytes);

(PreRelease) Returns a byte array containing the complete MIME message, including all sub-parts.

CkMime * GetPart(long index);

Returns the Nth sub-part of the MIME message. Indexing begins at 0.

CkCert * GetSignerCert(long index);

Returns the Nth digital certificate used to sign the MIME message. Indexing begins at 0.

bool GetXml(CkString & xml);

Converts the MIME (or S/MIME) message to XML and returns the XML as a string.

Returns true for success, false for failure.

bool IsApplicationData();

Return true if the MIME message contains application data, otherwise returns false.

bool IsAttachment();

Return true if this MIME message is an attachment, otherwise returns false

bool IsAudio();

Return true if the MIME message contains audio data, otherwise returns false.

bool IsEncrypted();

Returns true if the MIME message is encrypted.

bool IsHtml();

Return true if the MIME body is HTML

bool IsImage();

Return true if the MIME message contains image data, otherwise returns false.

bool IsMultipart();

Return true if the MIME message is multipart (multipart/mixed, multipart/related, multipart/alternative, etc.), otherwise returns false.

bool IsMultipartAlternative();

Return true if the MIME message is multipart/alternative, otherwise returns false.

bool IsMultipartMixed();

Return true if the MIME message is multipart/mixed, otherwise returns false.

bool IsMultipartRelated();

Return true if the MIME message is multipart/related, otherwise returns false.

bool IsPlainText();

Return true if the MIME message body is plain text, otherwise returns false.

bool IsSigned();

Return true if the MIME message is digitally signed, otherwise returns false.

bool IsText();

Return true if the MIME message body is any text content type, such as text/plain, text/html, text/xml, etc., otherwise returns false.

bool IsUnlocked();

Returns true if the component is already unlocked, false if not.

bool IsVideo();

Return true if the MIME message contains video data, otherwise returns false.

bool IsXml();

Return true if the MIME message body is XML, otherwise returns false.

bool LoadMime(const char * mimeMsg);

Discards the current contents of the MIME object and loads a new MIME message from a string.

bool LoadMimeBytes(CkByteData & bData);

Loads a MIME document from an in-memory byte array.

bool LoadMimeFile(const char * fileName);

Discards the current contents of the MIME object and loads a new MIME message from a file.

bool LoadXml(const char * xml);

Converts XML to MIME and replaces the MIME object's contents with the converted XML.

bool LoadXmlFile(const char * fileName);

Converts XML to MIME and replaces the MIME object's contents with the converted XML.

bool NewMessageRfc822(const CkMime & mimeObject);

Clears the Mime object and initializes it such that the header contains a "content-type: message/rfc822" line and the body is the MIME text of the Mime object passed to the method.

bool NewMultipartAlternative();

Discards the current MIME message header fields and contents, if any, an initializes the MIME object to be an empty mulipart/alternative message.

bool NewMultipartMixed();

Discards the current MIME message header fields and contents, if any, an initializes the MIME object to be an empty mulipart/mixed message.

bool NewMultipartRelated();

Discards the current MIME message header fields and contents, if any, an initializes the MIME object to be an empty mulipart/related message.

bool RemovePart(int index);

Removes the Nth subpart from the MIME message.

bool SaveBody(const char * filename);

Saves the MIME message body to a file. If the body is base64 or quoted-printable encoded, it is automatically decoded.

bool SaveLastError(const char * filename);

Saves the last error information to an XML formatted file.

bool SaveMime(const char * filename);

Saves the MIME message to a file, in MIME format. (This is the same as the .EML format used by Microsoft Outlook Express.)

bool SaveXml(const char * filename);

Converts the MIME message to XML and saves to an XML file.

bool SetBodyFromBinary(const CkByteData & dbuf);

Sets the MIME message body from a byte array.

bool SetBodyFromEncoded(const char * encoding, const char * str);

Sets the MIME message body from a Base64 or Quoted-Printable encoded string.

bool SetBodyFromFile(const char * fileName);

Sets the MIME message body from the contents of a file.

bool SetBodyFromHtml(const char * str);

Sets the MIME message body from a string containing HTML, and also updates the content-type to be text/html

bool SetBodyFromPlainText(const char * str);

Sets the MIME message body from a string containing plain text, and also updates the content-type to be text/plain

bool SetBodyFromXml(const char * str);

Sets the MIME message body from a string containing XML, and also updates the content-type to be text/xml

bool SetCSP(const CkCSP & csp);

Sets the encryption and digital signature preferences for this message. The CSP object will control the Cryptographic Service Provider used, the key container within the CSP to be used, and the encryption/hash algorithms.

bool SetHeaderField(const char * name, const char * value);

Adds or replaces a MIME message header field. If the field already exists, it is automatically replaced. Otherwise it is added.

void SetVerifyCert(const CkCert * cert);

Allows a certificate to be explicitly specified for verifying a signature.

void SetVerifyCert(const CkCert & cert);

Allows a certificate to be explicitly specified for verifying a signature.

CkEmail * ToEmailObject();

Returns the MIME message converted to a CkEmail object.

bool UnlockComponent(const char * unlockCode);

Unlocks the component allowing for the full functionality to be used. Returns true if the unlock code is valid.

bool UnwrapSecurity();

Decrypts and verifies all digital signatures contained within the MIME message, and returns true if all decryptions and verifications succeeded. Otherwise returns false. After unwrapping, the information regarding security and certificates can be obtained by the methods GetSignerCert and GetEncryptCert, and the properties NumEncryptCerts and NumSignerCerts.

bool Verify();

To be documented soon...

const char * bodyDecoded();

Returns the body of the MIME message as a string. The body is automatically converted from its encoding type, such as base64 or quoted-printable, before being returned.

const char * bodyEncoded();

Returns the body of the MIME message as a String. The body is explicitly not decoded from it's encoding type, so if it was represented in Base64, you will get the Base64 encoded body, as an example.

const char * boundary();

The boundary string to be used if this is a multipart message. By default, the boundary is automatically generated to be a unique and random string, so explicitly setting the boundary is not necessary.

const char * charset();

The charset, such as "ISO-8859-1" or "utf-8"

const char * contentType();

The MIME content type, such as "text/plain", "text/html", "multipart/alternative", "multipart/mixed", etc.

const char * disposition();

The content disposition, which can be "attachment", "inline", etc.

const char * encoding();

A content encoding such as "base64", "quoted-printable", "7bit", "8bit", etc.

const char * entireBody();

Returns the entire MIME body, including all sub-parts.

const char * entireHead();

Returns the MIME header.

const char * filename();

The filename when the content disposition is "attachment".

const char * getBodyDecoded();

Returns the body of the MIME message as a string. The body is automatically converted from its encoding type, such as base64 or quoted-printable, before being returned.

const char * getBodyEncoded();

Returns the body of the MIME message as a String. The body is explicitly not decoded from it's encoding type, so if it was represented in Base64, you will get the Base64 encoded body, as an example.

const char * getEntireBody();

Returns the entire MIME body, including all sub-parts.

const char * getEntireHead();

Returns the MIME header.

const char * getHeaderField(const char * name);

Returns the content of a MIME header field. The "fieldName" is case-insensitive, and if the MIME header field does not exist, an empty string is returned.

const char * getHeaderFieldName(int index);

Returns the Nth MIME header field name.

const char * getHeaderFieldValue(int index);

Returns the Nth MIME header field value.

const char * getMime();

Returns a string containing the complete MIME message, including all sub-parts.

const char * getXml();

Converts the MIME (or S/MIME) message to XML and returns the XML as a string.

const char * header(const char * name);

Returns the content of a MIME header field. The "fieldName" is case-insensitive, and if the MIME header field does not exist, an empty string is returned.

const char * headerName(int index);

Returns the Nth MIME header field name.

const char * headerValue(int index);

Returns the Nth MIME header field value.

const char * lastErrorHtml();

Error information in HTML format for the last method called.

const char * lastErrorText();

Error information in plain-text format for the last method called.

const char * lastErrorXml();

Error information in XML format for the last method called.

const char * micalg();

The MIC algorithm, such as "SHA1" when the content type is multipart/signed. Properties such as this are rarely set manually, as Chilkat MIME automatically sets it to the correct value when creating a signed message.

const char * mime();

Returns a string containing the complete MIME message, including all sub-parts.

const char * name();

The name attribute of the content-type header field.

const char * protocol();

A protocol such as "application/x-pkcs7-signature". Properties such as this are rarely set manually, as Chilkat MIME automatically sets it to the correct value when creating a signed message.

const char * xml();

Converts the MIME (or S/MIME) message to XML and returns the XML as a string.