---
product: Chilkat
product_version: 11.7.0
language: wcpp
language_label: Unicode C++
class: Mime
class_name: CkMimeW
license: bundle
deprecated: false
reference_html: https://www.chilkatsoft.com/refdoc/wcppCkMimeWRef.html
---
# Chilkat Mime — Unicode C++ — v11.7.0

> Chilkat 11.7.0 · language=wcpp · class=Mime (CkMimeW)
> Other versions: replace `11.7.0` in this URL. Other languages: `https://www.chilkatsoft.com/ai-docs/v/11.7.0/<lang>/classes/Mime.md`.
> Language-wide rules (install, unlock, error model, strings/bytes): `https://www.chilkatsoft.com/ai-docs/v/11.7.0/wcpp/guide.md`.

## Purpose

**Build, parse, modify, serialize, secure, and inspect MIME and S/MIME data.**

`Mime` provides low-level MIME and S/MIME handling for applications that need direct control over MIME structure, headers, body content, encodings, multipart relationships, attachments, and PKCS7/CMS security layers. It can load, create, inspect, modify, serialize, and save MIME messages; build multipart structures; manage headers and content-transfer encodings; extract attachments; convert MIME to and from XML; and sign, verify, encrypt, decrypt, or unwrap S/MIME content.

**Create and load MIME**

Build MIME content programmatically or load existing MIME from strings, files, byte data, or other application sources.

**Headers and body content**

Read, add, replace, or remove MIME headers, set body content, and control content types, charsets, and transfer encodings.

**Multipart structures**

Create and inspect multipart MIME trees such as mixed, alternative, related, signed, encrypted, and nested MIME structures.

**Attachments and parts**

Add, locate, extract, remove, or inspect MIME parts and attachments, including filenames and encoded body data.

**S/MIME security**

Sign, verify, encrypt, decrypt, unwrap, and inspect PKCS7/CMS S/MIME layers using certificates and private keys.

**Serialization and XML**

Emit MIME text, save MIME to files, or convert MIME to and from XML for structured inspection, transformation, or storage.

**Common pattern:** Use `Mime` when an application needs low-level control over MIME parts, headers, encodings, multipart layout, or S/MIME security. For ordinary email composition and message-level operations, use `Email`; use `Mime` when you need to work closer to the raw MIME structure.

**Initial state:** A new `Mime` object has no headers or child parts. Its string serialization consists only of the blank header/body separator (`CRLF CRLF`) until content is added.

**MIME parsing is semantic, not byte-preserving.** Loading and reserializing can unfold headers, normalize parameter quoting and transfer encodings, use CRLF for generated headers and multipart framing, and discard multipart preamble or epilogue text. Use byte-oriented methods such as `LoadMimeBd` and `GetMimeBd` when arbitrary 8-bit bytes or embedded NUL bytes must be preserved.

For an extended overview, see [Mime Class Overview](https://www.chilkatsoft.com/mime_class_overview.asp).

## Object creation, unlocking and error handling

**Object Creation**

```cpp
// Local variable on the stack
CkMimeW obj;

// Dynamically allocate/delete
CkMimeW *pObj = new CkMimeW();
// ...
delete pObj;
```

Call `Global.UnlockBundle` once at the start of the program, before using this or any other Chilkat class. Any string unlocks a fully functional 30-day trial; a purchased unlock code is used in production. See `guide.md` for the exact code in Unicode C++.

How failure is reported depends on the method's return type and is stated in the note under each method below. In every case the diagnostic text is in the `LastErrorText` property of the object whose method was called.

## Members common to every Chilkat class

Documented once per language in `common-members.md`; listed here so this page is self-contained.

| Property | Signature | Access | Meaning |
|---|---|---|---|
| `DebugLogFilePath` | `void get_DebugLogFilePath(CkString &str); const wchar_t *debugLogFilePath(void); void put_DebugLogFilePath(const wchar_t *str);` | read/write | If set to a file path, this property logs the LastErrorText of each Chilkat method or property call to the specified file. |
| `LastErrorHtml` | `void get_LastErrorHtml(CkString &str); const wchar_t *lastErrorHtml(void);` | read-only | Provides HTML-formatted information about the last called method or property. |
| `LastErrorText` | `void get_LastErrorText(CkString &str); const wchar_t *lastErrorText(void);` | read-only | Provides plain text information about the last called method or property. |
| `LastErrorXml` | `void get_LastErrorXml(CkString &str); const wchar_t *lastErrorXml(void);` | read-only | Provides XML-formatted information about the last called method or property. |
| `LastMethodSuccess` | `bool get_LastMethodSuccess(void); void put_LastMethodSuccess(bool newVal);` | read/write | Indicates the success or failure of the most recent method call: `true` means success, `false` means failure. |
| `VerboseLogging` | `bool get_VerboseLogging(void); void put_VerboseLogging(bool newVal);` | read/write | If set to `true`, then the contents of LastErrorText (or LastErrorXml, or LastErrorHtml) may contain more verbose information. |
| `Version` | `void get_Version(CkString &str); const wchar_t *version(void);` | read-only | Version of the component/library, such as "10.1.0" |

## Member index

| Member | Kind | Signature |
|---|---|---|
| `Boundary` | property, read/write | `void get_Boundary(CkString &str); const wchar_t *boundary(void); void put_Boundary(const wchar_t *str);` |
| `Charset` | property, read/write | `void get_Charset(CkString &str); const wchar_t *charset(void); void put_Charset(const wchar_t *str);` |
| `CmsOptions` | property, read/write | `void get_CmsOptions(CkString &str); const wchar_t *cmsOptions(void); void put_CmsOptions(const wchar_t *str);` |
| `ContentType` | property, read/write | `void get_ContentType(CkString &str); const wchar_t *contentType(void); void put_ContentType(const wchar_t *str);` |
| `CurrentDateTime` | property, read-only | `void get_CurrentDateTime(CkString &str); const wchar_t *currentDateTime(void);` |
| `Disposition` | property, read/write | `void get_Disposition(CkString &str); const wchar_t *disposition(void); void put_Disposition(const wchar_t *str);` |
| `Encoding` | property, read/write | `void get_Encoding(CkString &str); const wchar_t *encoding(void); void put_Encoding(const wchar_t *str);` |
| `Filename` | property, read/write | `void get_Filename(CkString &str); const wchar_t *filename(void); void put_Filename(const wchar_t *str);` |
| `Micalg` | property, read/write | `void get_Micalg(CkString &str); const wchar_t *micalg(void); void put_Micalg(const wchar_t *str);` |
| `Name` | property, read/write | `void get_Name(CkString &str); const wchar_t *name(void); void put_Name(const wchar_t *str);` |
| `NumDecryptCerts` | property, read-only | `int get_NumDecryptCerts(void);` |
| `NumHeaderFields` | property, read-only | `int get_NumHeaderFields(void);` |
| `NumParts` | property, read-only | `int get_NumParts(void);` |
| `NumSignerCerts` | property, read-only | `int get_NumSignerCerts(void);` |
| `OaepHash` | property, read/write | `void get_OaepHash(CkString &str); const wchar_t *oaepHash(void); void put_OaepHash(const wchar_t *str);` |
| `OaepMgfHash` | property, read/write | `void get_OaepMgfHash(CkString &str); const wchar_t *oaepMgfHash(void); void put_OaepMgfHash(const wchar_t *str);` |
| `OaepPadding` | property, read/write | `bool get_OaepPadding(void); void put_OaepPadding(bool newVal);` |
| `Pkcs7CryptAlg` | property, read/write | `void get_Pkcs7CryptAlg(CkString &str); const wchar_t *pkcs7CryptAlg(void); void put_Pkcs7CryptAlg(const wchar_t *str);` |
| `Pkcs7KeyLength` | property, read/write | `int get_Pkcs7KeyLength(void); void put_Pkcs7KeyLength(int newVal);` |
| `Protocol` | property, read/write | `void get_Protocol(CkString &str); const wchar_t *protocol(void); void put_Protocol(const wchar_t *str);` |
| `SigningAlg` | property, read/write | `void get_SigningAlg(CkString &str); const wchar_t *signingAlg(void); void put_SigningAlg(const wchar_t *str);` |
| `SigningHashAlg` | property, read/write | `void get_SigningHashAlg(CkString &str); const wchar_t *signingHashAlg(void); void put_SigningHashAlg(const wchar_t *str);` |
| `UncommonOptions` | property, read/write | `void get_UncommonOptions(CkString &str); const wchar_t *uncommonOptions(void); void put_UncommonOptions(const wchar_t *str);` |
| `UnwrapExtras` | property, read/write | `bool get_UnwrapExtras(void); void put_UnwrapExtras(bool newVal);` |
| `UseMmDescription` | property, read/write | `bool get_UseMmDescription(void); void put_UseMmDescription(bool newVal);` |
| `UseXPkcs7` | property, read/write | `bool get_UseXPkcs7(void); void put_UseXPkcs7(bool newVal);` |
| `AddContentLength` | method | `void AddContentLength(void);` |
| `AddDecryptCert` | method | `bool AddDecryptCert(CkCertW &cert);` |
| `AddDetachedSignature` | method | `bool AddDetachedSignature(CkCertW &cert);` |
| `AddDetachedSignature2` | method | `bool AddDetachedSignature2(CkCertW &cert, bool transferHeaderFields);` |
| `AddDetachedSignaturePk` | method | `bool AddDetachedSignaturePk(CkCertW &cert, CkPrivateKeyW &privateKey);` |
| `AddDetachedSignaturePk2` | method | `bool AddDetachedSignaturePk2(CkCertW &cert, CkPrivateKeyW &privateKey, bool transferHeaderFields);` |
| `AddEncryptCert` | method | `bool AddEncryptCert(CkCertW &cert);` |
| `AddHeaderField` | method | `bool AddHeaderField(const wchar_t *name, const wchar_t *value);` |
| `AddPfxSourceBd` | method | `bool AddPfxSourceBd(CkBinDataW &bd, const wchar_t *password);` |
| `AddPfxSourceFile` | method | `bool AddPfxSourceFile(const wchar_t *pfxFilePath, const wchar_t *password);` |
| `AppendPart` | method | `bool AppendPart(CkMimeW &mime);` |
| `AppendPartFromFile` | method | `bool AppendPartFromFile(const wchar_t *filename);` |
| `AsnBodyToXml` | method | `bool AsnBodyToXml(CkString &outStr); const wchar_t *asnBodyToXml(void);` |
| `ClearEncryptCerts` | method | `void ClearEncryptCerts(void);` |
| `ContainsEncryptedParts` | method | `bool ContainsEncryptedParts(void);` |
| `ContainsSignedParts` | method | `bool ContainsSignedParts(void);` |
| `Convert8Bit` | method | `void Convert8Bit(void);` |
| `ConvertToMultipartAlt` | method | `bool ConvertToMultipartAlt(void);` |
| `ConvertToMultipartMixed` | method | `bool ConvertToMultipartMixed(void);` |
| `ConvertToSigned` | method | `bool ConvertToSigned(CkCertW &cert);` |
| `ConvertToSignedPk` | method | `bool ConvertToSignedPk(CkCertW &cert, CkPrivateKeyW &privateKey);` |
| `Decrypt` | method | `bool Decrypt(void);` |
| `Decrypt2` | method | `bool Decrypt2(CkCertW &cert, CkPrivateKeyW &privateKey);` |
| `DecryptUsingCert` | method | `bool DecryptUsingCert(CkCertW &cert);` |
| `DecryptUsingPfxFile` | method | `bool DecryptUsingPfxFile(const wchar_t *pfxFilePath, const wchar_t *pfxPassword);` |
| `Encrypt` | method | `bool Encrypt(CkCertW &cert);` |
| `EncryptN` | method | `bool EncryptN(void);` |
| `GetBodyBd` | method | `bool GetBodyBd(CkBinDataW &binDat);` |
| `GetBodyDecoded` | method | `bool GetBodyDecoded(CkString &outStr); const wchar_t *getBodyDecoded(void);` |
| `GetBodyEncoded` | method | `bool GetBodyEncoded(CkString &outStr); const wchar_t *getBodyEncoded(void);` |
| `GetDecryptCertInfo` | method | `bool GetDecryptCertInfo(CkJsonObjectW &certInfo);` |
| `GetEntireBody` | method | `bool GetEntireBody(CkString &outStr); const wchar_t *getEntireBody(void);` |
| `GetEntireHead` | method | `bool GetEntireHead(CkString &outStr); const wchar_t *getEntireHead(void);` |
| `GetHeaderField` | method | `bool GetHeaderField(const wchar_t *fieldName, CkString &outStr); const wchar_t *getHeaderField(const wchar_t *fieldName);` |
| `GetHeaderFieldAttribute` | method | `bool GetHeaderFieldAttribute(const wchar_t *name, const wchar_t *attrName, CkString &outStr); const wchar_t *getHeaderFieldAttribute(const wchar_t *name, const wchar_t *attrName);` |
| `GetHeaderFieldName` | method | `bool GetHeaderFieldName(int index, CkString &outStr); const wchar_t *getHeaderFieldName(int index);` |
| `GetHeaderFieldValue` | method | `bool GetHeaderFieldValue(int index, CkString &outStr); const wchar_t *getHeaderFieldValue(int index);` |
| `GetLastJsonData` | method | `void GetLastJsonData(CkJsonObjectW &json);` |
| `GetMime` | method | `bool GetMime(CkString &outStr); const wchar_t *getMime(void);` |
| `GetMimeBd` | method | `bool GetMimeBd(CkBinDataW &bindat);` |
| `GetMimeSb` | method | `bool GetMimeSb(CkStringBuilderW &sb);` |
| `GetSignatureSigningTimeStr` | method | `bool GetSignatureSigningTimeStr(int index, CkString &outStr); const wchar_t *getSignatureSigningTimeStr(int index);` |
| `GetStructure` | method | `bool GetStructure(const wchar_t *fmt, CkString &outStr); const wchar_t *getStructure(const wchar_t *fmt);` |
| `GetXml` | method | `bool GetXml(CkString &outStr); const wchar_t *getXml(void);` |
| `HasSignatureSigningTime` | method | `bool HasSignatureSigningTime(int index);` |
| `IsApplicationData` | method | `bool IsApplicationData(void);` |
| `IsAttachment` | method | `bool IsAttachment(void);` |
| `IsAudio` | method | `bool IsAudio(void);` |
| `IsEncrypted` | method | `bool IsEncrypted(void);` |
| `IsHtml` | method | `bool IsHtml(void);` |
| `IsImage` | method | `bool IsImage(void);` |
| `IsMultipart` | method | `bool IsMultipart(void);` |
| `IsMultipartAlternative` | method | `bool IsMultipartAlternative(void);` |
| `IsMultipartMixed` | method | `bool IsMultipartMixed(void);` |
| `IsMultipartRelated` | method | `bool IsMultipartRelated(void);` |
| `IsPlainText` | method | `bool IsPlainText(void);` |
| `IsSigned` | method | `bool IsSigned(void);` |
| `IsText` | method | `bool IsText(void);` |
| `IsVideo` | method | `bool IsVideo(void);` |
| `IsXml` | method | `bool IsXml(void);` |
| `LastDecryptCert` | method | `bool LastDecryptCert(int index, CkCertW &cert);` |
| `LastSignerCert` | method | `bool LastSignerCert(int index, CkCertW &cert);` |
| `LoadMime` | method | `bool LoadMime(const wchar_t *mimeMsg);` |
| `LoadMimeBd` | method | `bool LoadMimeBd(CkBinDataW &bindat);` |
| `LoadMimeFile` | method | `bool LoadMimeFile(const wchar_t *fileName);` |
| `LoadMimeSb` | method | `bool LoadMimeSb(CkStringBuilderW &sb);` |
| `LoadXml` | method | `bool LoadXml(const wchar_t *xml);` |
| `LoadXmlFile` | method | `bool LoadXmlFile(const wchar_t *fileName);` |
| `NewMessageRfc822` | method | `bool NewMessageRfc822(CkMimeW &mimeObject);` |
| `NewMultipartAlternative` | method | `bool NewMultipartAlternative(void);` |
| `NewMultipartMixed` | method | `bool NewMultipartMixed(void);` |
| `NewMultipartRelated` | method | `bool NewMultipartRelated(void);` |
| `PartAt` | method | `bool PartAt(int index, CkMimeW &subPart);` |
| `PartsToFiles` | method | `bool PartsToFiles(const wchar_t *path, CkStringTableW &st);` |
| `RemoveHeaderField` | method | `void RemoveHeaderField(const wchar_t *fieldName, bool bAllOccurrences);` |
| `RemovePart` | method | `bool RemovePart(int index);` |
| `SaveBody` | method | `bool SaveBody(const wchar_t *filename);` |
| `SaveMime` | method | `bool SaveMime(const wchar_t *filename);` |
| `SaveXml` | method | `bool SaveXml(const wchar_t *filename);` |
| `SetBody` | method | `void SetBody(const wchar_t *str);` |
| `SetBodyBd` | method | `bool SetBodyBd(CkBinDataW &bd);` |
| `SetBodyFromEncoded` | method | `bool SetBodyFromEncoded(const wchar_t *encoding, const wchar_t *str);` |
| `SetBodyFromFile` | method | `bool SetBodyFromFile(const wchar_t *fileName);` |
| `SetBodyFromHtml` | method | `bool SetBodyFromHtml(const wchar_t *str);` |
| `SetBodyFromPlainText` | method | `bool SetBodyFromPlainText(const wchar_t *str);` |
| `SetBodyFromXml` | method | `bool SetBodyFromXml(const wchar_t *str);` |
| `SetHeaderField` | method | `bool SetHeaderField(const wchar_t *name, const wchar_t *value);` |
| `SetVerifyCert` | method | `bool SetVerifyCert(CkCertW &cert);` |
| `UnwrapSecurity` | method | `bool UnwrapSecurity(void);` |
| `UrlEncodeBody` | method | `void UrlEncodeBody(const wchar_t *charset);` |
| `UseCertVault` | method | `bool UseCertVault(CkXmlCertVaultW &vault);` |
| `Verify` | method | `bool Verify(void);` |

Deprecated members are listed at the end of this file with their replacements; do not use them in new code.

## Properties

### Mime.Boundary

`Chilkat 11.7.0 · wcpp · Mime · Boundary · property · read/write`

```cpp
void get_Boundary(CkString &str);

const wchar_t *boundary(void);

void put_Boundary(const wchar_t *str);
```

Gets or sets the raw boundary token used by a multipart MIME entity. Do not include surrounding quotation marks.

```
Content-Type: multipart/mixed; boundary="example-boundary"
```

For this example, `Boundary` is `example-boundary`. Chilkat automatically quotes the parameter when the token contains characters such as spaces or semicolons.

**Normally automatic.** Methods such as `NewMultipartMixed`, `NewMultipartAlternative`, and `NewMultipartRelated` generate a nonempty boundary.

**Caller-supplied boundaries are not validated.** Chilkat does not detect collisions with body text. An empty value is permitted but produces invalid multipart delimiters, and supplying quotation marks as part of the property value causes those quotation marks to become part of the boundary. The property can also be set on a nonmultipart entity, where it is simply added as a `Content-Type` parameter.

### Mime.Charset

`Chilkat 11.7.0 · wcpp · Mime · Charset · property · read/write`

```cpp
void get_Charset(CkString &str);

const wchar_t *charset(void);

void put_Charset(const wchar_t *str);
```

Gets or sets the `charset` parameter of the `Content-Type` header field.

```
Content-Type: text/plain; charset=utf-8
```

Changing this property preserves the media type and other parameters. Setting it when no `Content-Type` exists creates a `Content-Type` field, although the media type remains empty until `ContentType` is set.

**Charset versus transfer encoding.** The charset identifies how text characters are represented as bytes. `Encoding` controls the MIME transport representation of those bytes.

**Empty-string behavior.** Setting `Charset` to an empty string does not remove the parameter. It selects the platform default ANSI charset; on Windows this is typically `windows-1252`.

### Mime.CmsOptions

`Chilkat 11.7.0 · wcpp · Mime · CmsOptions · property · read/write · since 9.5.0.78`

```cpp
void get_CmsOptions(CkString &str);

const wchar_t *cmsOptions(void);

void put_CmsOptions(const wchar_t *str);
```

Gets or sets a JSON string containing advanced CMS/PKCS #7 signing and validation options. The default is an empty string, which selects normal behavior. A valid empty JSON object may also be supplied as `{}`.

Unknown JSON members are retained but ignored. Malformed JSON is normalized to `{}`. This property is intended for specialized interoperability requirements; applications should leave it empty unless a documented option is specifically needed.

### Mime.ContentType

`Chilkat 11.7.0 · wcpp · Mime · ContentType · property · read/write`

```cpp
void get_ContentType(CkString &str);

const wchar_t *contentType(void);

void put_ContentType(const wchar_t *str);
```

Gets or sets the MIME media type of the current part, excluding all parameters. Supply a value such as `text/plain`, `text/html`, `application/pdf`, or `multipart/mixed`; do not include `charset`, `boundary`, or other parameters in this property.

Changing the media type preserves the existing `charset` and unrecognized parameters, but may remove parameters that are specific to the previous media type, such as `format=flowed`. Setting an empty string leaves an empty media type and can therefore produce an invalid-looking header if other parameters remain.

**Classification methods use this value.** Methods such as `IsText`, `IsImage`, and `IsMultipart` classify the media type stored here. Parameters must be set through their dedicated properties or header attributes, not appended to `ContentType`.

### Mime.CurrentDateTime

`Chilkat 11.7.0 · wcpp · Mime · CurrentDateTime · property · read-only`

```cpp
void get_CurrentDateTime(CkString &str);

const wchar_t *currentDateTime(void);
```

Returns the current local date and time formatted as an Internet message date, including the numeric UTC offset. For example:

```
Fri, 21 Nov 1997 09:55:06 -0600
```

### Mime.Disposition

`Chilkat 11.7.0 · wcpp · Mime · Disposition · property · read/write`

```cpp
void get_Disposition(CkString &str);

const wchar_t *disposition(void);

void put_Disposition(const wchar_t *str);
```

Gets or sets the disposition value from the `Content-Disposition` header field, excluding parameters such as `filename`.

```
Content-Disposition: attachment; filename="report.pdf"
```

Changing this property preserves an existing `filename` parameter. Typical values are `attachment` and `inline`.

### Mime.Encoding

`Chilkat 11.7.0 · wcpp · Mime · Encoding · property · read/write`

```cpp
void get_Encoding(CkString &str);

const wchar_t *encoding(void);

void put_Encoding(const wchar_t *str);
```

Gets or sets the value of the `Content-Transfer-Encoding` header field for the current part. Common values include `base64`, `quoted-printable`, `7bit`, `8bit`, and `binary`.

**Transfer encoding is not compression.** It determines how the body bytes are represented in serialized MIME. `GetBodyEncoded` returns the transfer-encoded form, while `GetBodyBd`, `GetBodyBinary`, and `SaveBody` return or save decoded bytes.

### Mime.Filename

`Chilkat 11.7.0 · wcpp · Mime · Filename · property · read/write`

```cpp
void get_Filename(CkString &str);

const wchar_t *filename(void);

void put_Filename(const wchar_t *str);
```

Gets or sets the `filename` parameter of the `Content-Disposition` header field. The value is a receiver-facing filename, not a local filesystem path.

Changing this property preserves the disposition value but removes other `Content-Disposition` parameters such as `size`. Setting an empty string removes the `filename` parameter.

**International filenames.** When setting a non-ASCII filename, Chilkat emits an RFC 2047 encoded-word in `filename=`. When reading a header containing both `filename=` and `filename*=`, this property returns `filename=`. Use `GetHeaderFieldAttribute` to retrieve the raw `filename*` value.

### Mime.Micalg

`Chilkat 11.7.0 · wcpp · Mime · Micalg · property · read/write`

```cpp
void get_Micalg(CkString &str);

const wchar_t *micalg(void);

void put_Micalg(const wchar_t *str);
```

Gets or sets the `micalg` parameter of a `multipart/signed` `Content-Type` header field.

```
Content-Type: multipart/signed;
  protocol="application/pkcs7-signature";
  micalg=sha-256;
  boundary="example-boundary"
```

The parameter advertises the message-digest algorithm used by the detached signature.

**SigningHashAlg is authoritative.** When a detached signature is created, `SigningHashAlg` selects the digest and Chilkat replaces any conflicting `Micalg` value with the corresponding MIME token, such as `sha-1`, `sha-256`, `sha-384`, or `sha-512`. Setting `Micalg` alone does not select the cryptographic digest.

### Mime.Name

`Chilkat 11.7.0 · wcpp · Mime · Name · property · read/write`

```cpp
void get_Name(CkString &str);

const wchar_t *name(void);

void put_Name(const wchar_t *str);
```

Gets or sets the `name` parameter of the `Content-Type` header field. For attachments, `Filename` is generally the primary receiver-facing name.

Setting a non-ASCII value causes Chilkat to emit an RFC 2047 encoded-word in the `name=` parameter. Setting this property when no media type exists creates a `Content-Type` field with an empty media type.

### Mime.NumDecryptCerts

`Chilkat 11.7.0 · wcpp · Mime · NumDecryptCerts · property · read-only · since 11.0.0`

```cpp
int get_NumDecryptCerts(void);
```

Returns the number of recipient or decryption certificates currently recorded by the most recent S/MIME encryption, decryption, or security-unwrapping operation. A new object returns `0`. A successful single-recipient `Encrypt` records `1`, and successful decryption records the certificate whose private key was used.

Use `LastDecryptCert` with a zero-based index to retrieve a recorded certificate. This is a result count; it is not the number of PFX sources or decryption certificates configured on the object.

### Mime.NumHeaderFields

`Chilkat 11.7.0 · wcpp · Mime · NumHeaderFields · property · read-only`

```cpp
int get_NumHeaderFields(void);
```

Returns the number of header-field occurrences in the current part. Duplicate names count separately and retain their order. Valid indexes range from `0` through `NumHeaderFields - 1` for use with `GetHeaderFieldName` and `GetHeaderFieldValue`.

During MIME parsing, duplicate ordinary fields are retained. Duplicate `Content-Type` fields are collapsed, with the last value taking effect.

### Mime.NumParts

`Chilkat 11.7.0 · wcpp · Mime · NumParts · property · read-only`

```cpp
int get_NumParts(void);
```

Returns the number of direct child parts. It does not include deeper descendants. Iterate from `0` through `NumParts - 1` and call `PartAt` to traverse the tree.

The object returned by `PartAt` provides live access to the stored child. Modifying that returned object modifies the parent MIME tree.

### Mime.NumSignerCerts

`Chilkat 11.7.0 · wcpp · Mime · NumSignerCerts · property · read-only`

```cpp
int get_NumSignerCerts(void);
```

Returns the number of signer certificates currently recorded by the most recent S/MIME signing, signature-verification, or security-unwrapping operation. A new object returns `0`. A single-certificate signing method records `1`; `Verify` and `UnwrapSecurity` replace the count with the signer results from that operation.

A failed call to `Verify` clears the signer results and sets this property to `0`. Use `LastSignerCert` with a zero-based index to retrieve a recorded signer certificate.

### Mime.OaepHash

`Chilkat 11.7.0 · wcpp · Mime · OaepHash · property · read/write · since 9.5.0.67`

```cpp
void get_OaepHash(CkString &str);

const wchar_t *oaepHash(void);

void put_OaepHash(const wchar_t *str);
```

Gets or sets the hash algorithm used by RSAES-OAEP when encrypting the CMS content-encryption key. Supported values are `sha1`, `sha256`, `sha384`, and `sha512`. The default is `sha256`. An empty or unrecognized value leaves the current valid setting unchanged.

This property is used only when `OaepPadding` is `true`. It is independent of `OaepMgfHash`; for example, OAEP may use SHA-256 while MGF1 uses SHA-1.

### Mime.OaepMgfHash

`Chilkat 11.7.0 · wcpp · Mime · OaepMgfHash · property · read/write · since 9.5.0.71`

```cpp
void get_OaepMgfHash(CkString &str);

const wchar_t *oaepMgfHash(void);

void put_OaepMgfHash(const wchar_t *str);
```

Gets or sets the hash algorithm used by the MGF1 mask generation function within RSAES-OAEP. Supported values are `sha1`, `sha256`, `sha384`, and `sha512`. The default is `sha256`. An empty or unrecognized value leaves the current valid setting unchanged.

This property is used only when `OaepPadding` is `true` and is independent of `OaepHash`.

### Mime.OaepPadding

`Chilkat 11.7.0 · wcpp · Mime · OaepPadding · property · read/write · since 9.5.0.67`

```cpp
bool get_OaepPadding(void);

void put_OaepPadding(bool newVal);
```

Selects the RSA key-transport padding used when creating encrypted MIME. The default is `false`, which uses RSAES-PKCS1-v1_5. Set to `true` to use RSAES-OAEP.

**Scope.** This setting protects the symmetric content-encryption key for an RSA recipient. It does not change the symmetric content algorithm selected by `Pkcs7CryptAlg`.

### Mime.Pkcs7CryptAlg

`Chilkat 11.7.0 · wcpp · Mime · Pkcs7CryptAlg · property · read/write`

```cpp
void get_Pkcs7CryptAlg(CkString &str);

const wchar_t *pkcs7CryptAlg(void);

void put_Pkcs7CryptAlg(const wchar_t *str);
```

Gets or sets the symmetric content-encryption algorithm used when creating CMS/PKCS #7 encrypted MIME. Supported input values are `aes`, `aes-gcm`, `des`, `3des`, and `rc2`. The default is `aes`. The `aes-gcm` option was added in version 10.0.0.

The getter returns normalized names: after setting `aes-gcm` it returns `aes`, and after setting `3des` it returns `des`. The generated CMS data nevertheless uses AES-GCM or 3DES-CBC respectively.

**Hybrid encryption.** S/MIME encrypts the MIME content with a symmetric content-encryption key. The recipient certificate then protects that content-encryption key. This property selects the symmetric algorithm; `Pkcs7KeyLength` selects its key length.

### Mime.Pkcs7KeyLength

`Chilkat 11.7.0 · wcpp · Mime · Pkcs7KeyLength · property · read/write`

```cpp
int get_Pkcs7KeyLength(void);

void put_Pkcs7KeyLength(int newVal);
```

Gets or sets the content-encryption key length, in bits, used when creating CMS/PKCS #7 encrypted MIME. The default is `128`.

Because this property may be set before `Pkcs7CryptAlg`, the setter accepts the union of key lengths that can be valid for any supported symmetric algorithm: `40`, `56`, `64`, `128`, `192`, and `256`. A value outside this set is rejected and the previous value is retained.

| Algorithm | Normal key lengths |
| :--- | :--- |
| `aes` or `aes-gcm` | `128`, `192`, or `256` |
| `3des` | `192` |
| `des` | `40` |
| `rc2` | `40`, `56`, `64`, or `128` |

**Set both properties before encrypting.** The property setter rejects only lengths that cannot be valid for any supported algorithm. Applications should select the algorithm and its appropriate key length before calling `Encrypt` or `EncryptN`.

### Mime.Protocol

`Chilkat 11.7.0 · wcpp · Mime · Protocol · property · read/write`

```cpp
void get_Protocol(CkString &str);

const wchar_t *protocol(void);

void put_Protocol(const wchar_t *str);
```

Gets or sets the `protocol` parameter of the `Content-Type` header field. This parameter is commonly used by `multipart/signed` to identify the media type of the detached signature part.

```
Content-Type: multipart/signed;
  protocol="application/pkcs7-signature";
  micalg=sha-256;
  boundary="example-boundary"
```

For this example, `Protocol` is `application/pkcs7-signature`.

### Mime.SigningAlg

`Chilkat 11.7.0 · wcpp · Mime · SigningAlg · property · read/write · since 9.5.0.67`

```cpp
void get_SigningAlg(CkString &str);

const wchar_t *signingAlg(void);

void put_SigningAlg(const wchar_t *str);
```

Gets or sets the RSA signature scheme used when creating CMS/PKCS #7 signed MIME. The default and normalized PKCS #1 v1.5 value is `PKCS1-V1_5`. Set the property to `RSASSA-PSS` or `pss` to use RSASSA-PSS; the getter returns `RSASSA-PSS`.

An empty or unrecognized value selects `PKCS1-V1_5`. This setting applies only when the signing private key is RSA. It does not select the signature scheme for EC or DSA keys. The property controls signature creation and is not updated during verification; use `GetLastJsonData` to inspect a verified signature.

### Mime.SigningHashAlg

`Chilkat 11.7.0 · wcpp · Mime · SigningHashAlg · property · read/write`

```cpp
void get_SigningHashAlg(CkString &str);

const wchar_t *signingHashAlg(void);

void put_SigningHashAlg(const wchar_t *str);
```

Gets or sets the message-digest algorithm used when creating CMS/PKCS #7 signatures. The default is `sha256`. Supported values are `sha1`, `sha256`, `sha384`, `sha512`, `md5`, and `md2`. Names are case-insensitive and are returned in lowercase.

An empty or unrecognized value selects `sha1`. This property controls signature creation only and is not changed when a signature is verified. After verification, call `GetLastJsonData` to inspect the digest algorithm found in the signed data.

**Security guidance.** Use a SHA-2 algorithm such as `sha256` unless interoperability with a legacy system requires otherwise. MD2, MD5, and SHA-1 are retained for compatibility with older signed messages. Because invalid input falls back to SHA-1, applications should set this property to a known supported value.

### Mime.UncommonOptions

`Chilkat 11.7.0 · wcpp · Mime · UncommonOptions · property · read/write · since 9.5.0.89`

```cpp
void get_UncommonOptions(CkString &str);

const wchar_t *uncommonOptions(void);

void put_UncommonOptions(const wchar_t *str);
```

Gets or sets a semicolon-delimited or implementation-specific option string used for uncommon compatibility requirements. The default is the empty string, and normal applications should leave it empty. Options placed here may be version-specific and should be used only when directed by Chilkat documentation or support.

### Mime.UnwrapExtras

`Chilkat 11.7.0 · wcpp · Mime · UnwrapExtras · property · read/write`

```cpp
bool get_UnwrapExtras(void);

void put_UnwrapExtras(bool newVal);
```

Controls whether `UnwrapSecurity` adds informative header fields describing the security layers removed. The default is `true`.

| Header | Example value |
| :--- | :--- |
| `X-NumPartsSigned` | `1` |
| `X-SignaturesValid` | `yes` |
| `X-NumPartsEncrypted` | `1` |
| `X-Decrypted` | `yes` |

Set to `false` when the application requires the unwrapped MIME without these additional status headers.

### Mime.UseMmDescription

`Chilkat 11.7.0 · wcpp · Mime · UseMmDescription · property · read/write`

```cpp
bool get_UseMmDescription(void);

void put_UseMmDescription(bool newVal);
```

Controls whether Chilkat uses the conventional multipart preamble text `This is a multi-part message in MIME format.` when serializing a multipart entity. The default is `false`. The preamble is meaningful only when the multipart has content and is ignored by MIME-aware readers.

### Mime.UseXPkcs7

`Chilkat 11.7.0 · wcpp · Mime · UseXPkcs7 · property · read/write`

```cpp
bool get_UseXPkcs7(void);

void put_UseXPkcs7(bool newVal);
```

Controls whether newly created S/MIME media types use the historical `x-pkcs7` names.

| Value | Generated media types |
| :--- | :--- |
| `true` (default) | `application/x-pkcs7-mime` and `application/x-pkcs7-signature` |
| `false` | `application/pkcs7-mime` and `application/pkcs7-signature` |

For detached signatures, the selected signature media type is used both for the outer `protocol` parameter and for the signature part. For opaque signed or encrypted MIME, it controls the `application/...pkcs7-mime` content type.

**Interoperability.** The `x-` forms are widely encountered in existing S/MIME messages. Chilkat recognizes both naming forms.

## Methods

### Mime.AddContentLength

`Chilkat 11.7.0 · wcpp · Mime · AddContentLength · method`

```cpp
void AddContentLength(void);
```

Computes the byte length of the current entity's serialized MIME body and adds or updates its `Content-Length` header. The count is based on the transfer-encoded serialized body, not the decoded payload.

For a multipart entity, the count includes boundary delimiter lines, child headers, child bodies, and the closing boundary. Only the current entity's header is updated; child parts do not receive `Content-Length` fields. Repeated calls recompute the value and leave a single header occurrence.

### Mime.AddDecryptCert

`Chilkat 11.7.0 · wcpp · Mime · AddDecryptCert · method · since 9.5.0.40`

```cpp
bool AddDecryptCert(CkCertW &cert);
```

Adds `cert` to the internal collection of certificates available for S/MIME decryption. The certificate must have access to its corresponding private key. Call this method once for each candidate certificate.

The collection is searched by `Decrypt` and `UnwrapSecurity`. Other ways to provide decryption credentials include `AddPfxSourceFile`, `AddPfxSourceBd`, and `UseCertVault`.

Returns true for success, false for failure.

### Mime.AddDetachedSignature

`Chilkat 11.7.0 · wcpp · Mime · AddDetachedSignature · method`

```cpp
bool AddDetachedSignature(CkCertW &cert);
```

Creates an S/MIME detached signature using `cert`. The certificate itself must have access to its private key. On success, the current object becomes a `multipart/signed` entity with two direct children:

| Part | Contents |
| :--- | :--- |
| First | The original MIME entity being signed. |
| Second | The CMS/PKCS #7 signature data, normally named `smime.p7s`. |

`SigningHashAlg` selects the digest and generated `micalg` parameter. For RSA keys, `SigningAlg` selects PKCS #1 v1.5 or RSASSA-PSS. `UseXPkcs7` selects the signature media-type spelling.

**Private-key requirement.** Adding a matching PFX source does not supply a missing signing key for a public-only `Cert`. Load the private key into `cert` or use `AddDetachedSignaturePk`.

**Signing an already signed MIME.** Calling this method again creates a new outer `multipart/signed` layer. It does not add another signer to the existing CMS signer-information set.

Returns true for success, false for failure.

### Mime.AddDetachedSignature2

`Chilkat 11.7.0 · wcpp · Mime · AddDetachedSignature2 · method`

```cpp
bool AddDetachedSignature2(CkCertW &cert, bool transferHeaderFields);
```

Creates the same detached `multipart/signed` structure as `AddDetachedSignature`. `cert` is the signing certificate and must have access to its private key.

| `transferHeaderFields` | Header placement |
| :--- | :--- |
| `false` | Existing message header fields, such as `Subject` and `From`, remain on the first signed content part. The new outer multipart has no copies of those fields. |
| `true` | Existing message header fields are moved to the new outer `multipart/signed` entity and removed from the first content part. |

Returns true for success, false for failure.

### Mime.AddDetachedSignaturePk

`Chilkat 11.7.0 · wcpp · Mime · AddDetachedSignaturePk · method`

```cpp
bool AddDetachedSignaturePk(CkCertW &cert, CkPrivateKeyW &privateKey);
```

Creates a detached S/MIME signature using `cert` as the signer certificate and `privateKey` as its associated private key. Use this method when the certificate and private key are supplied separately.

On success, the current object becomes the same two-part `multipart/signed` structure described by `AddDetachedSignature`. `SigningHashAlg`, `SigningAlg`, and `UseXPkcs7` control the generated signature.

Returns true for success, false for failure.

### Mime.AddDetachedSignaturePk2

`Chilkat 11.7.0 · wcpp · Mime · AddDetachedSignaturePk2 · method`

```cpp
bool AddDetachedSignaturePk2(CkCertW &cert, CkPrivateKeyW &privateKey, bool transferHeaderFields);
```

Creates a detached S/MIME signature using the certificate in `cert` and the corresponding private key in `privateKey`. `transferHeaderFields` controls placement of the existing message header fields:

| `transferHeaderFields` | Header placement |
| :--- | :--- |
| `false` | Headers remain on the first signed content part. |
| `true` | Headers are moved to the new outer `multipart/signed` entity and removed from the first content part. |

This is the separate-private-key counterpart of `AddDetachedSignature2`.

Returns true for success, false for failure.

### Mime.AddEncryptCert

`Chilkat 11.7.0 · wcpp · Mime · AddEncryptCert · method`

```cpp
bool AddEncryptCert(CkCertW &cert);
```

Adds `cert` to the internal recipient-certificate list used by `EncryptN`. Call this method once for each intended recipient. Encryption uses the public key in each certificate, so recipient private keys are not required at encryption time.

Call `ClearEncryptCerts` to empty the list.

Returns true for success, false for failure.

### Mime.AddHeaderField

`Chilkat 11.7.0 · wcpp · Mime · AddHeaderField · method`

```cpp
bool AddHeaderField(const wchar_t *name, const wchar_t *value);
```

Appends a new header field named by `name` with the value in `value`. Existing fields having the same case-insensitive name are preserved. An empty `value` creates a legal empty-valued field.

Chilkat converts spaces in a header name to hyphens, removes embedded CR and LF characters from the value to prevent header injection, and folds long values when serializing.

**Replacing versus appending.** Use `SetHeaderField` to remove all existing occurrences and set one replacement value.

Returns true for success, false for failure.

### Mime.AddPfxSourceBd

`Chilkat 11.7.0 · wcpp · Mime · AddPfxSourceBd · method · since 11.0.0`

```cpp
bool AddPfxSourceBd(CkBinDataW &bd, const wchar_t *password);
```

Adds the PKCS #12/PFX bytes in `bd` to the internal collection of credential sources used by later S/MIME decryption operations. `password` is the password protecting the PFX data. Call the method once for each PFX source that should be searched.

The source remains configured across subsequent `LoadMime` calls and repeated decryptions. Chilkat continues searching after a PFX that does not contain the required recipient key.

**Not a signing-key fallback.** Adding a PFX source does not make a public-only certificate usable by the signing methods. The signing certificate itself must have its private key, or the private key must be supplied explicitly by a method whose name ends in `Pk`.

Returns true for success, false for failure.

### Mime.AddPfxSourceFile

`Chilkat 11.7.0 · wcpp · Mime · AddPfxSourceFile · method`

```cpp
bool AddPfxSourceFile(const wchar_t *pfxFilePath, const wchar_t *password);
```

Adds the PFX/P12 file at the local filesystem path in `pfxFilePath` to the internal collection of credential sources used by later S/MIME decryption operations. `password` is the password protecting the file. Call the method once for each PFX source that should be searched.

The source remains configured across subsequent `LoadMime` calls and repeated decryptions. Chilkat continues searching after a PFX that does not contain the required recipient key.

**Not a signing-key fallback.** Adding a PFX source does not make a public-only certificate usable by the signing methods. The signing certificate itself must have its private key, or the private key must be supplied explicitly by a method whose name ends in `Pk`.

Returns true for success, false for failure.

### Mime.AppendPart

`Chilkat 11.7.0 · wcpp · Mime · AppendPart · method`

```cpp
bool AppendPart(CkMimeW &mime);
```

Appends a copy of `mime` as the last direct child. Chilkat does not retain a reference to `mime`, so later changes to `mime` do not affect the appended part. The same source object may be appended more than once.

If the current object is not multipart, it is converted to `multipart/mixed`. The complete original entity, including its existing headers and body, becomes part 0; the copy of `mime` becomes part 1. The new outer entity contains its generated multipart `Content-Type`.

**Editing an appended child.** Retrieve it with `PartAt`. The object returned by `PartAt` is a live child, unlike the copied input to this method.

Returns true for success, false for failure.

### Mime.AppendPartFromFile

`Chilkat 11.7.0 · wcpp · Mime · AppendPartFromFile · method`

```cpp
bool AppendPartFromFile(const wchar_t *filename);
```

Reads the local file at `filename`, creates an attachment part, and appends it. Filename-extension matching is case-insensitive.

| File kind | Generated headers |
| :--- | :--- |
| `.txt` | `text/plain; charset=windows-1252; format=flowed`, `7bit`, attachment filename and name |
| Known binary type, such as `.PNG` | Inferred media type such as `image/png`, `base64`, attachment filename and name |
| Unknown extension | `application/octet-stream`, `base64`, attachment filename and name |

If the current object is not multipart, the same conversion described by `AppendPart` occurs. Calling this method on a new empty object therefore creates an empty part 0 and the file attachment as part 1.

Returns true for success, false for failure.

### Mime.AsnBodyToXml

`Chilkat 11.7.0 · wcpp · Mime · AsnBodyToXml · method`

```cpp
bool AsnBodyToXml(CkString &outStr);

const wchar_t *asnBodyToXml(void);
```

Parses the current part's decoded body as ASN.1 DER and returns an XML representation of the ASN.1 structure. This is primarily useful for inspecting CMS/PKCS #7 bodies such as `application/pkcs7-mime` or `application/x-pkcs7-mime`.

```
Content-Type: application/pkcs7-mime; smime-type=signed-data
Content-Transfer-Encoding: base64

MII...
```

**Diagnostic conversion.** The returned XML exposes ASN.1 tags, object identifiers, and values for inspection. It is not the MIME-to-XML representation returned by `GetXml`.

Returns true for success, false for failure.

### Mime.ClearEncryptCerts

`Chilkat 11.7.0 · wcpp · Mime · ClearEncryptCerts · method`

```cpp
void ClearEncryptCerts(void);
```

Clears the internal recipient-certificate list populated by `AddEncryptCert`. A subsequent call to `EncryptN` requires certificates to be added again.

### Mime.ContainsEncryptedParts

`Chilkat 11.7.0 · wcpp · Mime · ContainsEncryptedParts · method`

```cpp
bool ContainsEncryptedParts(void);
```

Returns `true` if the currently visible MIME tree contains a CMS/PKCS #7 encrypted entity. Both `application/pkcs7-mime` and `application/x-pkcs7-mime` forms are recognized.

**Encrypted layers hide their contents.** This method examines the MIME structure as it currently exists. It cannot report signed or encrypted entities inside ciphertext until the enclosing encrypted layer is successfully removed.

### Mime.ContainsSignedParts

`Chilkat 11.7.0 · wcpp · Mime · ContainsSignedParts · method`

```cpp
bool ContainsSignedParts(void);
```

Returns `true` if the currently visible MIME tree contains a complete detached or opaque CMS/PKCS #7 signed entity. A standalone `application/pkcs7-signature` or `application/x-pkcs7-signature` leaf part is not by itself classified as a signed message.

**Encrypted layers hide their contents.** A signature nested inside encrypted data is not visible until the encrypted layer is removed. After a signature is successfully verified and unwrapped, this method returns `false` because the signed wrapper no longer exists.

### Mime.Convert8Bit

`Chilkat 11.7.0 · wcpp · Mime · Convert8Bit · method`

```cpp
void Convert8Bit(void);
```

Recursively converts every part whose `Content-Transfer-Encoding` is `8bit` or `binary` to `base64`. Both the child object's `Encoding` property and the serialized header are updated. Parts using `7bit` or another encoding are unchanged.

### Mime.ConvertToMultipartAlt

`Chilkat 11.7.0 · wcpp · Mime · ConvertToMultipartAlt · method`

```cpp
bool ConvertToMultipartAlt(void);
```

Wraps the current entity in a new outer `multipart/alternative` entity. The original entity becomes the first and initially only child.

The new outer entity retains message-level and custom headers such as `MIME-Version`, `Date`, `Subject`, `From`, `To`, `Content-ID`, `Content-Location`, and custom fields. The original `Content-Type`, `Content-Transfer-Encoding`, `Content-Disposition`, and body move to the first child. An existing `charset` parameter is retained on the new multipart `Content-Type`. Calling the method again wraps the existing multipart in another multipart layer; the operation is not idempotent.

**Alternative ordering.** Additional representations can be appended with `AppendPart`. Conventionally, alternatives are ordered from least rich to most rich, such as `text/plain` followed by `text/html`.

Returns true for success, false for failure.

### Mime.ConvertToMultipartMixed

`Chilkat 11.7.0 · wcpp · Mime · ConvertToMultipartMixed · method`

```cpp
bool ConvertToMultipartMixed(void);
```

Wraps the current entity in a new outer `multipart/mixed` entity. The original entity becomes the first and initially only child.

The new outer entity retains message-level and custom headers such as `MIME-Version`, `Date`, `Subject`, `From`, `To`, `Content-ID`, `Content-Location`, and custom fields. The original `Content-Type`, `Content-Transfer-Encoding`, `Content-Disposition`, and body move to the first child. An existing `charset` parameter is retained on the new multipart `Content-Type`. Calling the method again wraps the existing multipart in another multipart layer; the operation is not idempotent.

Returns true for success, false for failure.

### Mime.ConvertToSigned

`Chilkat 11.7.0 · wcpp · Mime · ConvertToSigned · method`

```cpp
bool ConvertToSigned(CkCertW &cert);
```

Creates an opaque (attached) S/MIME signature using `cert`. The certificate itself must have access to its private key. On success, the current MIME entity is replaced by CMS/PKCS #7 `signed-data` containing both the original MIME bytes and the signature.

The result has no MIME child parts, uses Base64 content-transfer encoding, and has an `application/x-pkcs7-mime` or `application/pkcs7-mime` content type according to `UseXPkcs7`. `SigningHashAlg` and, for RSA keys, `SigningAlg` select the signing algorithms.

This differs from `AddDetachedSignature`, which creates a visible `multipart/signed` wrapper with a separate signature part.

Returns true for success, false for failure.

### Mime.ConvertToSignedPk

`Chilkat 11.7.0 · wcpp · Mime · ConvertToSignedPk · method`

```cpp
bool ConvertToSignedPk(CkCertW &cert, CkPrivateKeyW &privateKey);
```

Creates an opaque (attached) S/MIME signature using `cert` as the signer certificate and `privateKey` as its associated private key. Use this method when the certificate and private key are supplied separately.

The resulting CMS/PKCS #7 `signed-data` contains the original MIME entity and its signature, has no MIME child parts, and uses Base64 content-transfer encoding. For a detached `multipart/signed` result, use `AddDetachedSignaturePk`.

Returns true for success, false for failure.

### Mime.Decrypt

`Chilkat 11.7.0 · wcpp · Mime · Decrypt · method`

```cpp
bool Decrypt(void);
```

Decrypts the current CMS/PKCS #7 encrypted MIME entity and replaces it with the recovered MIME content. Chilkat identifies the intended recipient from the CMS recipient information and searches configured credential sources for the matching certificate and private key.

| Source | How it is supplied |
| :--- | :--- |
| Explicit certificate | `AddDecryptCert` or `DecryptUsingCert` |
| PFX/P12 | `AddPfxSourceFile`, `AddPfxSourceBd`, or a `DecryptUsingPfx...` method |
| Certificate vault | `UseCertVault` |
| Platform certificate store | Windows certificate stores and the macOS Keychain are searched automatically where supported |

On success, `NumDecryptCerts` and `LastDecryptCert` identify the certificate used, and `GetLastJsonData` reports the content-encryption algorithm and key size. On failure, the encrypted MIME remains unchanged.

**Serialization after decryption.** The recovered MIME content is restored semantically, but its generated serialization is not guaranteed to be byte-for-byte identical to the bytes that existed before encryption.

Returns true for success, false for failure.

### Mime.Decrypt2

`Chilkat 11.7.0 · wcpp · Mime · Decrypt2 · method`

```cpp
bool Decrypt2(CkCertW &cert, CkPrivateKeyW &privateKey);
```

Decrypts the current CMS/PKCS #7 encrypted MIME entity using the certificate in `cert` and its associated private key in `privateKey`. On success, the encrypted wrapper is replaced by the recovered MIME content, the decryption certificate is available through `LastDecryptCert`, and operation details are available through `GetLastJsonData`. On failure, the encrypted MIME remains unchanged.

Use this method when the certificate and private key are stored separately. Use `Decrypt` when Chilkat should locate the credential from configured sources.

Returns true for success, false for failure.

### Mime.DecryptUsingCert

`Chilkat 11.7.0 · wcpp · Mime · DecryptUsingCert · method · since 9.5.0.40`

```cpp
bool DecryptUsingCert(CkCertW &cert);
```

Decrypts the current CMS/PKCS #7 encrypted MIME entity using `cert`. The certificate must have access to its corresponding private key; a public-only certificate is insufficient. On success, the encrypted wrapper is replaced by the recovered MIME content and `cert` is recorded in the decryption results. On failure, the encrypted MIME remains unchanged.

Returns true for success, false for failure.

### Mime.DecryptUsingPfxFile

`Chilkat 11.7.0 · wcpp · Mime · DecryptUsingPfxFile · method`

```cpp
bool DecryptUsingPfxFile(const wchar_t *pfxFilePath, const wchar_t *pfxPassword);
```

Decrypts the current CMS/PKCS #7 encrypted MIME entity using certificates and private keys from the PFX/P12 file at the local filesystem path in `pfxFilePath`. `pfxPassword` is the password protecting the file.

On success, the encrypted wrapper is replaced by the recovered MIME content and the matching certificate is available through `LastDecryptCert`. `GetLastJsonData` may include both CMS decryption details and information produced while reading the PFX. On failure, the encrypted MIME remains unchanged.

Returns true for success, false for failure.

### Mime.Encrypt

`Chilkat 11.7.0 · wcpp · Mime · Encrypt · method`

```cpp
bool Encrypt(CkCertW &cert);
```

Encrypts the current MIME entity for the recipient certificate in `cert` and replaces it with CMS/PKCS #7 encrypted S/MIME. `cert` must be RSA-based. Only the recipient's public key is needed to encrypt; the matching private key is required later to decrypt.

The default content encryption is AES-128-CBC. `Pkcs7CryptAlg` and `Pkcs7KeyLength` select the symmetric algorithm and key length. By default, RSAES-PKCS1-v1_5 transports the content-encryption key; set `OaepPadding` to `true` to use RSAES-OAEP, with `OaepHash` and `OaepMgfHash` controlling its parameters.

The generated MIME uses Base64 transfer encoding, the filename `smime.p7m`, and an `application/x-pkcs7-mime` or `application/pkcs7-mime` content type according to `UseXPkcs7`. After encryption, `GetDecryptCertInfo` can report the recipient identifiers stored in the CMS data. If encryption fails, the original MIME remains unchanged.

Returns true for success, false for failure.

### Mime.EncryptN

`Chilkat 11.7.0 · wcpp · Mime · EncryptN · method`

```cpp
bool EncryptN(void);
```

Encrypts the current MIME entity for every certificate previously added with `AddEncryptCert`. Each recipient receives independently protected access to the same encrypted content.

Add one certificate per intended recipient, call this method, and use `ClearEncryptCerts` before preparing a different recipient set.

Returns true for success, false for failure.

### Mime.GetBodyBd

`Chilkat 11.7.0 · wcpp · Mime · GetBodyBd · method · since 9.5.0.67`

```cpp
bool GetBodyBd(CkBinDataW &binDat);
```

Replaces the contents of `binDat` with the decoded body bytes of the current part. Existing bytes in `binDat` are discarded. Base64 and quoted-printable are decoded. MIME headers, multipart boundaries, and child parts are not included.

Returns true for success, false for failure.

### Mime.GetBodyDecoded

`Chilkat 11.7.0 · wcpp · Mime · GetBodyDecoded · method`

```cpp
bool GetBodyDecoded(CkString &outStr);

const wchar_t *getBodyDecoded(void);
```

Returns the decoded body as text. Chilkat first decodes the `Content-Transfer-Encoding` and then interprets text according to the declared charset.

**Use a byte-oriented getter for binary content.** A string result cannot reliably represent arbitrary binary bytes or embedded NUL bytes. Use `GetBodyBd` or `GetBodyBinary` for binary payloads.

Returns true for success, false for failure.

### Mime.GetBodyEncoded

`Chilkat 11.7.0 · wcpp · Mime · GetBodyEncoded · method`

```cpp
bool GetBodyEncoded(CkString &outStr);

const wchar_t *getBodyEncoded(void);
```

Returns the current part's transfer-encoded body text without decoding Base64 or quoted-printable. The returned value is Chilkat's normalized serialization of the body, not necessarily the exact text that appeared in the loaded MIME. For example, Base64 padding and line wrapping or quoted-printable spelling may be regenerated.

Returns true for success, false for failure.

### Mime.GetDecryptCertInfo

`Chilkat 11.7.0 · wcpp · Mime · GetDecryptCertInfo · method · since 11.4.0`

```cpp
bool GetDecryptCertInfo(CkJsonObjectW &certInfo);
```

Examines the current encrypted S/MIME entity and writes recipient-certificate identifiers to the `JsonObject` in `certInfo`. This can be used to identify which certificate and private key must be made available before calling `Decrypt` or `UnwrapSecurity`. A typical result is:

```
{
  "recipientInfo": [
    {
      "serial": "166FC256FC66A64B20C710F15BFAB63E",
      "issuerCN": "Example Issuing CA"
    }
  ]
}
```

The method returns `false` and writes an empty JSON object when the current MIME entity is not encrypted, including after it has already been decrypted.

**No private key is revealed.** The encrypted message contains recipient identifiers and encrypted key material, not recipient private keys.

Returns true for success, false for failure.

### Mime.GetEntireBody

`Chilkat 11.7.0 · wcpp · Mime · GetEntireBody · method`

```cpp
bool GetEntireBody(CkString &outStr);

const wchar_t *getEntireBody(void);
```

Returns the complete serialized body of the current MIME entity. For multipart MIME, this includes boundary delimiters, each child part's headers and body, and the closing boundary. The current entity's own header fields are not included.

Use `GetBodyDecoded` when the decoded payload of a single part is needed.

Returns true for success, false for failure.

### Mime.GetEntireHead

`Chilkat 11.7.0 · wcpp · Mime · GetEntireHead · method`

```cpp
bool GetEntireHead(CkString &outStr);

const wchar_t *getEntireHead(void);
```

Returns the complete serialized header section of the current MIME entity. The body and any multipart child content are not included.

Returns true for success, false for failure.

### Mime.GetHeaderField

`Chilkat 11.7.0 · wcpp · Mime · GetHeaderField · method`

```cpp
bool GetHeaderField(const wchar_t *fieldName, CkString &outStr);

const wchar_t *getHeaderField(const wchar_t *fieldName);
```

Returns the value of the first header field whose name matches `fieldName` case-insensitively. Duplicate later occurrences are not combined. Returns null when no matching field exists.

Returns true for success, false for failure.

### Mime.GetHeaderFieldAttribute

`Chilkat 11.7.0 · wcpp · Mime · GetHeaderFieldAttribute · method`

```cpp
bool GetHeaderFieldAttribute(const wchar_t *name, const wchar_t *attrName, CkString &outStr);

const wchar_t *getHeaderFieldAttribute(const wchar_t *name, const wchar_t *attrName);
```

Returns an attribute value parsed from the first header field named by `name`. Both the header name and `attrName` attribute name are matched case-insensitively. Surrounding quotation marks are removed, and semicolons inside a quoted value are handled as part of the value.

Extended parameters such as `filename*=utf-8''r%C3%A9sum%C3%A9.txt` are returned in their raw encoded form; this method does not percent-decode or apply the declared charset. Returns null when the field or attribute is absent.

Returns true for success, false for failure.

### Mime.GetHeaderFieldName

`Chilkat 11.7.0 · wcpp · Mime · GetHeaderFieldName · method`

```cpp
bool GetHeaderFieldName(int index, CkString &outStr);

const wchar_t *getHeaderFieldName(int index);
```

Returns the name of the header-field occurrence at zero-based `index`. Header order and original casing are preserved for ordinary loaded headers. Use `NumHeaderFields` to determine the valid range.

Returns true for success, false for failure.

### Mime.GetHeaderFieldValue

`Chilkat 11.7.0 · wcpp · Mime · GetHeaderFieldValue · method`

```cpp
bool GetHeaderFieldValue(int index, CkString &outStr);

const wchar_t *getHeaderFieldValue(int index);
```

Returns the unfolded value of the header-field occurrence at zero-based `index`. Continuation lines are combined into a single value. Use `NumHeaderFields` to determine the valid range.

Returns true for success, false for failure.

### Mime.GetLastJsonData

`Chilkat 11.7.0 · wcpp · Mime · GetLastJsonData · method · since 9.5.0.69`

```cpp
void GetLastJsonData(CkJsonObjectW &json);
```

Copies structured details from the most recent operation into `json` when such details are available. Many methods do not produce JSON data.

| Operation | Typical result |
| :--- | :--- |
| Signing or encryption | An empty JSON object. |
| `Verify` | `pkcs7.verify` details such as embedded certificates, digest algorithms, signer information, signature algorithm, signing time, message digest, and authenticated attributes. |
| Decryption | `pkcs7.decrypt` details including the content algorithm and key size. A PFX-based method may also include PKCS #12 parsing details. |
| `UnwrapSecurity` | May contain both verification and decryption sections when both kinds of security layer were removed. |

**Read immediately.** The information describes the most recent applicable call on this object and can be replaced by a later operation.

### Mime.GetMime

`Chilkat 11.7.0 · wcpp · Mime · GetMime · method`

```cpp
bool GetMime(CkString &outStr);

const wchar_t *getMime(void);
```

Serializes and returns the complete MIME entity, including headers, body, multipart boundaries, and all descendants.

**Serialization is normalized.** The result is semantically equivalent MIME, not a byte-for-byte copy of loaded input. Chilkat can unfold headers, normalize parameter quoting and transfer encodings, discard multipart preamble and epilogue text, and generate CRLF for headers and multipart framing. Existing body line endings may not always be rewritten.

Returns true for success, false for failure.

### Mime.GetMimeBd

`Chilkat 11.7.0 · wcpp · Mime · GetMimeBd · method · since 9.5.0.62`

```cpp
bool GetMimeBd(CkBinDataW &bindat);
```

Serializes the complete MIME entity and appends its bytes to `bindat`. Existing `BinData` bytes are preserved. Use this method when arbitrary binary body bytes must not pass through a text string.

**Serialization is normalized.** The result is semantically equivalent MIME, not a byte-for-byte copy of loaded input. Chilkat can unfold headers, normalize parameter quoting and transfer encodings, discard multipart preamble and epilogue text, and generate CRLF for headers and multipart framing. Existing body line endings may not always be rewritten.

Returns true for success, false for failure.

### Mime.GetMimeSb

`Chilkat 11.7.0 · wcpp · Mime · GetMimeSb · method · since 9.5.0.62`

```cpp
bool GetMimeSb(CkStringBuilderW &sb);
```

Serializes the complete MIME entity and appends it to `sb`. Existing `StringBuilder` content is preserved.

**Serialization is normalized.** The result is semantically equivalent MIME, not a byte-for-byte copy of loaded input. Chilkat can unfold headers, normalize parameter quoting and transfer encodings, discard multipart preamble and epilogue text, and generate CRLF for headers and multipart framing. Existing body line endings may not always be rewritten.

Returns true for success, false for failure.

### Mime.GetSignatureSigningTimeStr

`Chilkat 11.7.0 · wcpp · Mime · GetSignatureSigningTimeStr · method`

```cpp
bool GetSignatureSigningTimeStr(int index, CkString &outStr);

const wchar_t *getSignatureSigningTimeStr(int index);
```

Returns the CMS `signingTime` signed attribute for the signer at zero-based `index`, formatted as an RFC 822-style date string in GMT. For example:

```
Wed, 29 Jul 2026 14:32:58 GMT
```

Call `HasSignatureSigningTime` first because the attribute is optional. Use `NumSignerCerts` for the signer count.

**Signing time is not a trusted timestamp.** The CMS `signingTime` value is supplied by the signer. It is different from a timestamp token issued and signed by a trusted timestamp authority.

Returns true for success, false for failure.

### Mime.GetStructure

`Chilkat 11.7.0 · wcpp · Mime · GetStructure · method · since 9.5.0.56`

```cpp
bool GetStructure(const wchar_t *fmt, CkString &outStr);

const wchar_t *getStructure(const wchar_t *fmt);
```

Returns a concise MIME-tree summary. `fmt` is case-insensitive. The value `xml` selects XML output; all other values, including `text`, an empty string, or an unrecognized value, select the indented text format.

```
multipart/mixed
    text/plain
    application/octet-stream
```

```
<multipart-mixed>
    <text-plain />
    <application-octet-stream />
</multipart-mixed>
```

Returns true for success, false for failure.

### Mime.GetXml

`Chilkat 11.7.0 · wcpp · Mime · GetXml · method`

```cpp
bool GetXml(CkString &outStr);

const wchar_t *getXml(void);
```

Converts the MIME tree to Chilkat's XML representation and returns it as a string. Header names become XML element names, structured header parameters become XML attributes, duplicate headers become repeated elements, multipart children are nested in `subpart` elements, and binary bodies are represented in an encoded textual form.

**XML round-tripping is semantic.** Loading this XML reconstructs an equivalent MIME tree, but it is not byte-preserving and header names are normalized to lowercase.

Returns true for success, false for failure.

### Mime.HasSignatureSigningTime

`Chilkat 11.7.0 · wcpp · Mime · HasSignatureSigningTime · method`

```cpp
bool HasSignatureSigningTime(int index);
```

Returns `true` if the signer at zero-based `index` has a CMS `signingTime` signed attribute. Use `NumSignerCerts` for the signer count and `GetSignatureSigningTimeStr` to retrieve the value.

### Mime.IsApplicationData

`Chilkat 11.7.0 · wcpp · Mime · IsApplicationData · method`

```cpp
bool IsApplicationData(void);
```

Returns `true` when `ContentType` begins with `application/`. It returns `false` for an empty or malformed media type.

### Mime.IsAttachment

`Chilkat 11.7.0 · wcpp · Mime · IsAttachment · method`

```cpp
bool IsAttachment(void);
```

Returns `true` when the current part's disposition value is `attachment`, matched case-insensitively. Parameters such as `filename` do not affect the test. An `inline` part remains non-attachment even when it has a filename.

### Mime.IsAudio

`Chilkat 11.7.0 · wcpp · Mime · IsAudio · method`

```cpp
bool IsAudio(void);
```

Returns `true` when `ContentType` begins with `audio/`.

### Mime.IsEncrypted

`Chilkat 11.7.0 · wcpp · Mime · IsEncrypted · method`

```cpp
bool IsEncrypted(void);
```

Returns `true` when the current MIME entity is a CMS/PKCS #7 encrypted S/MIME wrapper. Both `application/pkcs7-mime` and `application/x-pkcs7-mime` forms are recognized. To search the visible MIME tree rather than only the current entity, use `ContainsEncryptedParts`.

### Mime.IsHtml

`Chilkat 11.7.0 · wcpp · Mime · IsHtml · method`

```cpp
bool IsHtml(void);
```

Returns `true` when `ContentType` is `text/html`. The `ContentType` property must contain only the media type; set parameters such as `charset` separately.

### Mime.IsImage

`Chilkat 11.7.0 · wcpp · Mime · IsImage · method`

```cpp
bool IsImage(void);
```

Returns `true` when `ContentType` begins with `image/`, including values such as `image/svg+xml`.

### Mime.IsMultipart

`Chilkat 11.7.0 · wcpp · Mime · IsMultipart · method`

```cpp
bool IsMultipart(void);
```

Returns `true` when `ContentType` begins with `multipart/`.

### Mime.IsMultipartAlternative

`Chilkat 11.7.0 · wcpp · Mime · IsMultipartAlternative · method`

```cpp
bool IsMultipartAlternative(void);
```

Returns `true` when `ContentType` is `multipart/alternative`.

### Mime.IsMultipartMixed

`Chilkat 11.7.0 · wcpp · Mime · IsMultipartMixed · method`

```cpp
bool IsMultipartMixed(void);
```

Returns `true` when `ContentType` is `multipart/mixed`.

### Mime.IsMultipartRelated

`Chilkat 11.7.0 · wcpp · Mime · IsMultipartRelated · method`

```cpp
bool IsMultipartRelated(void);
```

Returns `true` when `ContentType` is `multipart/related`.

### Mime.IsPlainText

`Chilkat 11.7.0 · wcpp · Mime · IsPlainText · method`

```cpp
bool IsPlainText(void);
```

Returns `true` when `ContentType` is `text/plain`.

### Mime.IsSigned

`Chilkat 11.7.0 · wcpp · Mime · IsSigned · method`

```cpp
bool IsSigned(void);
```

Returns `true` when the current MIME entity is a complete CMS/PKCS #7 signed S/MIME wrapper, including detached `multipart/signed` and opaque signed-data forms. A standalone `application/pkcs7-signature` or `application/x-pkcs7-signature` leaf part is not by itself classified as a signed message. To search the visible MIME tree, use `ContainsSignedParts`.

### Mime.IsText

`Chilkat 11.7.0 · wcpp · Mime · IsText · method`

```cpp
bool IsText(void);
```

Returns `true` when `ContentType` begins with `text/`.

### Mime.IsVideo

`Chilkat 11.7.0 · wcpp · Mime · IsVideo · method`

```cpp
bool IsVideo(void);
```

Returns `true` when `ContentType` begins with `video/`.

### Mime.IsXml

`Chilkat 11.7.0 · wcpp · Mime · IsXml · method`

```cpp
bool IsXml(void);
```

Returns `true` only for `text/xml` or `application/xml`. It does not classify structured-suffix media types such as `application/soap+xml`, `application/atom+xml`, or `image/svg+xml` as XML.

### Mime.LastDecryptCert

`Chilkat 11.7.0 · wcpp · Mime · LastDecryptCert · method · since 11.0.0`

```cpp
bool LastDecryptCert(int index, CkCertW &cert);
```

Loads into `cert` the decryption certificate at zero-based `index` from the most recent successful decryption or security-unwrapping operation. Valid indexes range from `0` through `NumDecryptCerts` `- 1`. The returned certificate has access to the private key used for decryption.

An invalid index returns `false` and leaves `cert` unchanged.

Returns true for success, false for failure.

### Mime.LastSignerCert

`Chilkat 11.7.0 · wcpp · Mime · LastSignerCert · method · since 11.0.0`

```cpp
bool LastSignerCert(int index, CkCertW &cert);
```

Loads into `cert` the signer certificate at zero-based `index` from the most recent successful signature-verification or security-unwrapping operation. Valid indexes range from `0` through `NumSignerCerts` `- 1`. The returned certificate normally contains only the public key; it does not gain access to the signer's private key.

An invalid index returns `false` and leaves `cert` unchanged. A later failed call to `Verify` clears the signer results.

Returns true for success, false for failure.

### Mime.LoadMime

`Chilkat 11.7.0 · wcpp · Mime · LoadMime · method`

```cpp
bool LoadMime(const wchar_t *mimeMsg);
```

Parses the complete MIME text in `mimeMsg` and replaces the current object's headers, body, and multipart tree. A successful call always replaces the previous MIME.

If no blank line separates headers from the body, lines that appear header-like are parsed as headers and the body is empty. Data after the header/body separator belongs to the body.

**Permissive parser and normalized output.** Chilkat accepts many imperfect messages. Observed behavior includes ignoring malformed header lines and leading non-header text, using the last duplicate `Content-Type`, repairing a missing multipart closing delimiter during serialization, treating unmatched boundary-like text as an ordinary body, and tolerating malformed Base64 or quoted-printable. LF-only and CR-only input are accepted; generated headers and multipart framing use CRLF. Loading and reserializing is therefore not guaranteed to reproduce the original bytes, and multipart preamble and epilogue text are not retained.

**Text input is not a raw-byte container.** Use `LoadMimeBd` or `LoadMimeBytes` for arbitrary 8-bit bytes or embedded NUL bytes.

Returns true for success, false for failure.

### Mime.LoadMimeBd

`Chilkat 11.7.0 · wcpp · Mime · LoadMimeBd · method · since 9.5.0.62`

```cpp
bool LoadMimeBd(CkBinDataW &bindat);
```

Parses complete MIME bytes from `bindat` and replaces the current MIME on success. This is the preferred loader when the MIME can contain arbitrary 8-bit body bytes or embedded NUL bytes. Parsing tolerance and serialization normalization are the same as `LoadMime`.

Returns true for success, false for failure.

### Mime.LoadMimeFile

`Chilkat 11.7.0 · wcpp · Mime · LoadMimeFile · method`

```cpp
bool LoadMimeFile(const wchar_t *fileName);
```

Reads and parses the complete MIME entity from the local file at `fileName`. A successful call replaces the current MIME. If the file cannot be opened, the method returns `false` and preserves the existing object unchanged.

Parsing tolerance and serialization normalization are the same as `LoadMime`.

Returns true for success, false for failure.

### Mime.LoadMimeSb

`Chilkat 11.7.0 · wcpp · Mime · LoadMimeSb · method · since 9.5.0.62`

```cpp
bool LoadMimeSb(CkStringBuilderW &sb);
```

Parses complete MIME text from `sb` and replaces the current MIME on success. Parsing tolerance and serialization normalization are the same as `LoadMime`.

**Use byte input for arbitrary MIME bytes.** A `StringBuilder` is text-oriented. Use `LoadMimeBd` for binary MIME containing arbitrary 8-bit values or NUL bytes.

Returns true for success, false for failure.

### Mime.LoadXml

`Chilkat 11.7.0 · wcpp · Mime · LoadXml · method`

```cpp
bool LoadXml(const wchar_t *xml);
```

Reconstructs a MIME tree from Chilkat's MIME XML in `xml`. On success, the current object is replaced. If the XML is invalid, the method returns `false` and preserves the existing MIME unchanged.

The reconstructed MIME is semantically equivalent but not byte-identical to the MIME that produced the XML. Header names are normalized to lowercase.

Returns true for success, false for failure.

### Mime.LoadXmlFile

`Chilkat 11.7.0 · wcpp · Mime · LoadXmlFile · method`

```cpp
bool LoadXmlFile(const wchar_t *fileName);
```

Reads Chilkat MIME XML from the local file at `fileName` and reconstructs the MIME tree. On success, the current object is replaced. If the file cannot be opened or the XML is invalid, the method returns `false` and preserves the existing MIME unchanged. Header names are normalized to lowercase during reconstruction.

Returns true for success, false for failure.

### Mime.NewMessageRfc822

`Chilkat 11.7.0 · wcpp · Mime · NewMessageRfc822 · method`

```cpp
bool NewMessageRfc822(CkMimeW &mimeObject);
```

Clears the current object and initializes it as `message/rfc822`. Its body is a serialized copy of `mimeObject` at the time of the call. Later modifications to `mimeObject` do not change the embedded message.

Returns true for success, false for failure.

### Mime.NewMultipartAlternative

`Chilkat 11.7.0 · wcpp · Mime · NewMultipartAlternative · method`

```cpp
bool NewMultipartAlternative(void);
```

Initializes an empty `multipart/alternative` entity. Clears all existing headers, body content, and child parts. The new object contains only a multipart `Content-Type` with an automatically generated boundary, has zero parts, and does not automatically add `MIME-Version`.

Returns true for success, false for failure.

### Mime.NewMultipartMixed

`Chilkat 11.7.0 · wcpp · Mime · NewMultipartMixed · method`

```cpp
bool NewMultipartMixed(void);
```

Initializes an empty `multipart/mixed` entity. Clears all existing headers, body content, and child parts. The new object contains only a multipart `Content-Type` with an automatically generated boundary, has zero parts, and does not automatically add `MIME-Version`.

Returns true for success, false for failure.

### Mime.NewMultipartRelated

`Chilkat 11.7.0 · wcpp · Mime · NewMultipartRelated · method`

```cpp
bool NewMultipartRelated(void);
```

Initializes an empty `multipart/related` entity. Clears all existing headers, body content, and child parts. The new object contains only a multipart `Content-Type` with an automatically generated boundary, has zero parts, and does not automatically add `MIME-Version`.

Returns true for success, false for failure.

### Mime.PartAt

`Chilkat 11.7.0 · wcpp · Mime · PartAt · method · since 11.0.0`

```cpp
bool PartAt(int index, CkMimeW &subPart);
```

Provides live access to the direct child at zero-based `index` through `subPart`. Modifying `subPart` after a successful call modifies the child stored in the parent MIME tree.

Valid indexes range from `0` through `NumParts` `- 1`. An invalid index returns `false` and preserves `subPart` unchanged.

**Different from AppendPart.** `AppendPart` stores a copy of its argument. This method exposes the actual stored child.

Returns true for success, false for failure.

### Mime.PartsToFiles

`Chilkat 11.7.0 · wcpp · Mime · PartsToFiles · method · since 11.0.0`

```cpp
bool PartsToFiles(const wchar_t *path, CkStringTableW &st);
```

Recursively traverses the MIME tree and saves each part having a nonempty `filename` parameter to the existing directory in `path`. A `name` parameter alone is not used as a fallback. The disposition may be `attachment` or `inline`; a filename is what controls extraction.

- Only the final path component of a MIME filename is used. Directory components, absolute paths, and `..` traversal are discarded.
- On Windows, invalid filename characters are replaced with underscores.
- Duplicate filenames target the same path; later parts overwrite earlier parts.
- `st` is appended to rather than cleared. Each added entry is the full path actually written, including any sanitized filename.
- The destination directory is not created. If it does not exist, the method returns `false`, creates no files, and appends nothing to `st`.

**Treat MIME filenames as untrusted.** Use a controlled destination directory and apply any application-specific policy for file types, size limits, overwriting, and renaming.

Returns true for success, false for failure.

### Mime.RemoveHeaderField

`Chilkat 11.7.0 · wcpp · Mime · RemoveHeaderField · method`

```cpp
void RemoveHeaderField(const wchar_t *fieldName, bool bAllOccurrences);
```

Removes fields whose name matches `fieldName` case-insensitively. If `bAllOccurrences` is `false`, only the first matching occurrence is removed. If `bAllOccurrences` is `true`, all matching occurrences are removed. Remaining fields retain their relative order.

### Mime.RemovePart

`Chilkat 11.7.0 · wcpp · Mime · RemovePart · method`

```cpp
bool RemovePart(int index);
```

Removes the direct child at zero-based `index`. Valid indexes range from `0` through `NumParts` `- 1`. An out-of-range index returns `false` and leaves the tree unchanged.

Returns true for success, false for failure.

### Mime.SaveBody

`Chilkat 11.7.0 · wcpp · Mime · SaveBody · method`

```cpp
bool SaveBody(const wchar_t *filename);
```

Writes the decoded body bytes of the current part to the local path in `filename`. Base64 and quoted-printable are decoded. MIME headers and multipart framing are not written.

**File behavior.** Existing files are overwritten. Parent directories are not created, and passing a directory as the destination fails. On Windows, an existing read-only file is replaced and the read-only attribute is removed.

Returns true for success, false for failure.

### Mime.SaveMime

`Chilkat 11.7.0 · wcpp · Mime · SaveMime · method`

```cpp
bool SaveMime(const wchar_t *filename);
```

Serializes the complete MIME entity and writes it to the local path in `filename`, including headers, body, multipart boundaries, and all descendants.

**Serialization is normalized.** The result is semantically equivalent MIME, not a byte-for-byte copy of loaded input. Chilkat can unfold headers, normalize parameter quoting and transfer encodings, discard multipart preamble and epilogue text, and generate CRLF for headers and multipart framing. Existing body line endings may not always be rewritten.

**File behavior.** Existing files are overwritten. Parent directories are not created, and passing a directory as the destination fails. On Windows, an existing read-only file is replaced and the read-only attribute is removed.

Returns true for success, false for failure.

### Mime.SaveXml

`Chilkat 11.7.0 · wcpp · Mime · SaveXml · method`

```cpp
bool SaveXml(const wchar_t *filename);
```

Writes Chilkat's MIME XML representation to the local path in `filename`. The file can be loaded by `LoadXmlFile`.

**File behavior.** Existing files are overwritten. Parent directories are not created, and passing a directory as the destination fails. On Windows, an existing read-only file is replaced and the read-only attribute is removed.

Returns true for success, false for failure.

### Mime.SetBody

`Chilkat 11.7.0 · wcpp · Mime · SetBody · method`

```cpp
void SetBody(const wchar_t *str);
```

Sets the current part's body from `str` while preserving existing content headers such as `Content-Type`, `charset`, and `Content-Transfer-Encoding`.

**Multipart entities serialize their child parts.** Calling this method on a multipart object changes what the body getter methods return, but the assigned body is not included in the serialized multipart output while child parts are present. Build multipart content through `AppendPart` and `PartAt`.

### Mime.SetBodyBd

`Chilkat 11.7.0 · wcpp · Mime · SetBodyBd · method · since 11.0.0`

```cpp
bool SetBodyBd(CkBinDataW &bd);
```

Sets the decoded body bytes from `bd`, changes `Content-Transfer-Encoding` to `base64`, and preserves the bytes exactly. It does not set a `Content-Type`, disposition, filename, or name; set those separately when needed.

Returns true for success, false for failure.

### Mime.SetBodyFromEncoded

`Chilkat 11.7.0 · wcpp · Mime · SetBodyFromEncoded · method`

```cpp
bool SetBodyFromEncoded(const wchar_t *encoding, const wchar_t *str);
```

Sets the body from transfer-encoded text. `encoding` must be `base64` or `quoted-printable`; other values, including `7bit`, `8bit`, `binary`, an unknown name, or an empty string, cause failure.

Base64 whitespace is accepted and the stored representation is normalized. Invalid Base64 causes the method to return `false`. On any failure, all existing headers and body content are preserved unchanged.

**Do not encode twice.** `str` must already be in the encoding named by `encoding`. To provide decoded bytes, use `SetBodyBd` or `SetBodyFromBinary`.

Returns true for success, false for failure.

### Mime.SetBodyFromFile

`Chilkat 11.7.0 · wcpp · Mime · SetBodyFromFile · method`

```cpp
bool SetBodyFromFile(const wchar_t *fileName);
```

Reads the local file at `fileName` and replaces the current part's body and content headers according to the filename extension.

| File kind | Result |
| :--- | :--- |
| `.txt` | `text/plain; charset=windows-1252; format=flowed`, `7bit` |
| `.html` | `text/html; charset=windows-1252`, `7bit` |
| Unknown extension | `application/octet-stream`, `base64`, `attachment`, and filename/name parameters based on the local filename |

If the file cannot be opened, the method returns `false` and preserves the existing MIME unchanged.

Returns true for success, false for failure.

### Mime.SetBodyFromHtml

`Chilkat 11.7.0 · wcpp · Mime · SetBodyFromHtml · method`

```cpp
bool SetBodyFromHtml(const wchar_t *str);
```

Sets `str` as HTML and changes the media type to `text/html`. For ASCII input, Chilkat uses `Content-Transfer-Encoding: 7bit` and does not add a charset. Existing unrelated headers are preserved.

Returns true for success, false for failure.

### Mime.SetBodyFromPlainText

`Chilkat 11.7.0 · wcpp · Mime · SetBodyFromPlainText · method`

```cpp
bool SetBodyFromPlainText(const wchar_t *str);
```

Sets `str` as plain text. For ASCII input, Chilkat sets `Content-Type: text/plain; format=flowed` and `Content-Transfer-Encoding: 7bit` without a charset. For non-ASCII UTF-8 input, it sets `charset=utf-8` and uses `8bit`. Existing unrelated headers are preserved.

Returns true for success, false for failure.

### Mime.SetBodyFromXml

`Chilkat 11.7.0 · wcpp · Mime · SetBodyFromXml · method`

```cpp
bool SetBodyFromXml(const wchar_t *str);
```

Sets `str` as XML, changes the media type to `text/xml`, and selects a transfer encoding appropriate for the text. For ASCII input, Chilkat uses `7bit` and does not add a charset.

The XML declaration's `encoding` value is not copied to the MIME `charset` parameter.

**Different from LoadXml.** This method places an XML document in the MIME body. `LoadXml` reconstructs an entire MIME object from Chilkat MIME XML.

Returns true for success, false for failure.

### Mime.SetHeaderField

`Chilkat 11.7.0 · wcpp · Mime · SetHeaderField · method`

```cpp
bool SetHeaderField(const wchar_t *name, const wchar_t *value);
```

Sets one header field named by `name`. Matching is case-insensitive. All existing occurrences are removed and one replacement is inserted. If no field exists, a new one is added. Passing an empty `value` removes all matching occurrences rather than creating an empty-valued field.

Use `AddHeaderField` to append another occurrence or to create an empty-valued field.

Returns true for success, false for failure.

### Mime.SetVerifyCert

`Chilkat 11.7.0 · wcpp · Mime · SetVerifyCert · method`

```cpp
bool SetVerifyCert(CkCertW &cert);
```

Supplies `cert` as a signer-certificate fallback for subsequent signature verification. This is useful when the CMS/PKCS #7 signature does not embed the signer certificate and Chilkat cannot otherwise locate it. Only the public key is required.

**This does not require a particular signer.** An embedded signer certificate takes precedence. If the CMS signature embeds the correct signer certificate, verification can succeed even when `cert` is an unrelated certificate, and `LastSignerCert` returns the embedded certificate. To enforce signer identity, verify first and then compare the returned signer certificate using application-defined criteria such as its serial number, fingerprint, subject, issuer, or trusted chain.

Returns true for success, false for failure.

### Mime.UnwrapSecurity

`Chilkat 11.7.0 · wcpp · Mime · UnwrapSecurity · method`

```cpp
bool UnwrapSecurity(void);
```

Removes supported S/MIME security layers and restores the underlying MIME content. It handles both common layer orders: a message signed and then encrypted, and a message encrypted and then signed. It continues through nested top-level layers until no additional supported security wrapper remains.

After a successful call, `NumSignerCerts` and `LastSignerCert` identify verified signers, while `NumDecryptCerts` and `LastDecryptCert` identify decryption certificates. `GetLastJsonData` may contain both `pkcs7.verify` and `pkcs7.decrypt` details.

**Additional result headers.** When `UnwrapExtras` is `true`, Chilkat adds headers such as `X-NumPartsSigned`, `X-SignaturesValid`, `X-NumPartsEncrypted`, and `X-Decrypted`. Set it to `false` to omit these headers.

Returns true for success, false for failure.

### Mime.UrlEncodeBody

`Chilkat 11.7.0 · wcpp · Mime · UrlEncodeBody · method`

```cpp
void UrlEncodeBody(const wchar_t *charset);
```

Replaces the current body with an `application/x-www-form-urlencoded`-style representation using the character set named by `charset`. Spaces become `+`, a literal plus becomes `%2B`, non-ASCII bytes become `%HH` sequences, and separators such as `&` and `=` remain unchanged.

```
Input:  a b+c&d=e
Output: a+b%2Bc&d=e
```

The MIME content headers are not changed. If the named character set is unsupported, the body remains unchanged.

**Not a MIME transfer encoding.** This operation is distinct from `base64` and `quoted-printable`.

### Mime.UseCertVault

`Chilkat 11.7.0 · wcpp · Mime · UseCertVault · method`

```cpp
bool UseCertVault(CkXmlCertVaultW &vault);
```

Sets `vault` as the certificate vault used to locate certificates and private keys for S/MIME encryption, decryption, signing, and verification. Only one vault is active; each call replaces the previously configured vault.

Use `XmlCertVault` when credentials are maintained independently of platform certificate stores or individual PFX sources.

Returns true for success, false for failure.

### Mime.Verify

`Chilkat 11.7.0 · wcpp · Mime · Verify · method`

```cpp
bool Verify(void);
```

Verifies the current CMS/PKCS #7 signed MIME entity and removes the signature wrapper. Both detached `multipart/signed` messages and opaque CMS `signed-data` are supported. The method works with signed MIME loaded from serialized input as well as MIME signed by the current object.

On success, the object is restored to the MIME structure and content that was signed, `NumSignerCerts` reports the verified signer count, `LastSignerCert` returns the signer certificate, and `GetLastJsonData` reports CMS verification details. A detached signature can restore the original serialization exactly, but opaque signed-data restoration is semantic and is not guaranteed to reproduce byte-for-byte identical MIME serialization.

On failure, the signed wrapper remains unchanged, no content is unwrapped, and the signer-result count is cleared to `0`.

**SetVerifyCert is a fallback, not a signer restriction.** When the CMS data embeds a usable signer certificate, Chilkat uses that embedded certificate. Verification can therefore succeed even when `SetVerifyCert` was given an unrelated certificate. Enforce signer identity after verification by examining `LastSignerCert`.

**What verification proves.** Cryptographic verification establishes that the signed bytes have not changed and that the signature matches the signer certificate. Application trust decisions may additionally require validating the certificate chain, identity, usage, validity period, and revocation status.

Returns true for success, false for failure.

## Deprecated members — do not use in new code

| Member | Kind | Deprecated in | Use instead |
|---|---|---|---|
| `NumEncryptCerts` | property | before 11.6.1 | — |
| `AddPfxSourceData` | method | before 11.6.1 | — |
| `DecryptUsingPfxData` | method | before 11.6.1 | — |
| `ExtractPartsToFiles` | method | before 11.6.1 | `PartsToFiles` |
| `FindIssuer` | method | before 11.6.1 | — |
| `GetBodyBinary` | method | before 11.6.1 | — |
| `GetEncryptCert` | method | before 11.6.1 | `LastDecryptCert` |
| `GetMimeBytes` | method | before 11.6.1 | — |
| `GetPart` | method | before 11.6.1 | `PartAt` |
| `GetSignerCert` | method | before 11.6.1 | `LastSignerCert` |
| `GetSignerCertChain` | method | before 11.6.1 | — |
| `LastJsonData` | method | before 11.6.1 | — |
| `LoadMimeBytes` | method | before 11.6.1 | — |
| `SetBodyFromBinary` | method | before 11.6.1 | — |

## Related classes

[`BinData`](https://www.chilkatsoft.com/ai-docs/v/11.7.0/wcpp/classes/BinData.md), [`Cert`](https://www.chilkatsoft.com/ai-docs/v/11.7.0/wcpp/classes/Cert.md), [`JsonObject`](https://www.chilkatsoft.com/ai-docs/v/11.7.0/wcpp/classes/JsonObject.md), [`PrivateKey`](https://www.chilkatsoft.com/ai-docs/v/11.7.0/wcpp/classes/PrivateKey.md), [`StringBuilder`](https://www.chilkatsoft.com/ai-docs/v/11.7.0/wcpp/classes/StringBuilder.md), [`StringTable`](https://www.chilkatsoft.com/ai-docs/v/11.7.0/wcpp/classes/StringTable.md), [`XmlCertVault`](https://www.chilkatsoft.com/ai-docs/v/11.7.0/wcpp/classes/XmlCertVault.md)

