Email Swift Reference Documentation

CkoEmail

Current Version: 11.5.0

Object Creation

let obj = CkoEmail()!

Properties

Body
body: String!

Contains the main body of the email.

If the email has both HTML and plain-text bodies, this property returns the HTML body. Use GetHtmlBody or GetPlainTextBody to retrieve a specific body, and use HasHtmlBody or HasPlainTextBody to determine which body formats are present.

Usage: This property addresses the main body only. For a message that provides both plain-text and HTML representations, use AddPlainTextAlternativeBody and AddHtmlAlternativeBody.

More Information and Examples
top
Charset
charset: String!

Represents the main charset of the email, such as utf-8, iso-8859-1, Shift_JIS, US-ASCII, etc. This property can be empty if there is no explicit charset, such as for emails with only US-ASCII.

Setting this property causes Chilkat to use the new charset in HTML and plain-text bodies, where possible. This can include updating the HTML META tag in HTML bodies to agree with the charset specified in the email header and also the byte representation of the HTML body in the email.

Chilkat stores text internally as Unicode. This property mainly controls how body text is converted to bytes and labeled when MIME is generated.

More Information and Examples
top
DebugLogFilePath
debugLogFilePath: String!

If set to a file path, this property logs the LastErrorText of each Chilkat method or property call to the specified file. This logging helps identify the context and history of Chilkat calls leading up to any crash or hang, aiding in debugging.

Enabling the VerboseLogging property provides more detailed information. This property is mainly used for debugging rare instances where a Chilkat method call causes a hang or crash, which should generally not happen.

Possible causes of hangs include:

  • A timeout property set to 0, indicating an infinite timeout.
  • A hang occurring within an event callback in the application code.
  • An internal bug in the Chilkat code causing the hang.

More Information and Examples
top
Decrypted
decrypted: Bool (read-only)

true if the email arrived encrypted and was successfully decrypted, otherwise false. This property is only meaningful when the ReceivedEncrypted property is equal to true.

Check ReceivedEncrypted first. A value of false can mean either that the message was not encrypted or that decryption did not succeed.

top
EmailDateStr
emailDateStr: String!

The date/time from the Date header in the UTC/GMT timezone in RFC822 string form.

For example: Fri, 10 Jul 2026 20:15:30 GMT.

Setting this property updates the email's Date header.

top
EncryptedBy
encryptedBy: String! (read-only)

If the email was received encrypted, this contains the details of the certificate used for encryption.

This property is meaningful only when ReceivedEncrypted is true. To obtain a certificate object rather than descriptive text, use GetEncryptedByCert or LastDecryptCert.

top
FileDistList
fileDistList: String!

Set this property to send an email to a list of recipients stored in a plain text file. The file format is simple: one recipient per line, no comments allowed, blank lines are ignored.Setting this property is equivalent to adding a CKX-FileDistList header field to the email. MailMan treats header fields beginning with CKX- specially in that these fields are never transmitted with the email when sent. However, CKX fields are saved and restored when saving to XML or loading from XML (or MIME). When sending an email containing a CKX-FileDistList header field, MailMan will read the distribution list file and send the email to each recipient. Emails can be sent individually, or with BCC, 100 recipients at a time. (see the MailMan.SendIndividual property).

The distribution-list file is read when the message is sent, so the file must still exist and be accessible at that time. This feature is separate from the recipients stored in the normal To, Cc, and Bcc lists.

top
From
from: String!

Contains the sender name and email address as they appear in the From header, such as John Smith <john.smith@mail.com>.

If the sender identified by the Sender header field should differ from the visible From address, call AddHeaderField to set the Sender header field.

From, FromName, and FromAddress are different views of the same MIME From header.

top
FromAddress
fromAddress: String!

The email address of the sender.

Changing this property updates the address portion of the MIME From header while preserving the sender name when possible.

top
FromName
fromName: String!

The name of the sender.

Changing this property updates the display-name portion of the MIME From header while preserving the email address.

top
Header
header: String! (read-only)

The complete MIME header of the email.

This is the header generated from the current in-memory email object. Modify individual fields through the corresponding properties or header methods rather than attempting to assign to this read-only property.

top
Language
language: String! (read-only)

Identifies the primary language group detected in the email subject and body text.

  • latin1 — English and Western European languages
  • central — Central European languages, such as Polish, Czech, and Hungarian
  • russian — Cyrillic languages
  • greek, turkish, hebrew, arabic, thai, or vietnamese
  • chinese, japanese, or korean
  • devanagari, bengali, gurmukhi, gujarati, oriya, tamil, telugu, kannada, malayalam, or sinhala
  • lao, tibetan, myanmar, or georgian
  • unknown

Characters in address and other MIME header fields are not considered. The Subject header has the greatest influence on the result. For example, an email with Japanese text in the subject and Russian text in the body is classified as japanese.

The classification is based on the Unicode blocks containing the characters found in the email.

This is a character-based heuristic intended to help choose encodings. It is not taken from the MIME Content-Language header and should not be treated as formal language detection.

top
LastErrorHtml
lastErrorHtml: String! (read-only)

Provides HTML-formatted information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.

top
LastErrorText
lastErrorText: String! (read-only)

Provides plain text information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.

top
LastErrorXml
lastErrorXml: String! (read-only)

Provides XML-formatted information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.

top
LastMethodSuccess
lastMethodSuccess: Bool

Indicates the success or failure of the most recent method call: true means success, false means failure. This property remains unchanged by property setters or getters. This method is present to address challenges in checking for null or Nothing returns in certain programming languages. Note: This property does not apply to methods that return integer values or to boolean-returning methods where the boolean does not indicate success or failure.

top
LocalDateStr
localDateStr: String!

The date/time found in the Date header field returned in the local timezone in RFC822 string form.

For example: Fri, 10 Jul 2026 15:15:30 -0500.

Setting this property updates the email's Date header. Use LocalDate when a native local date/time value is preferred.

top
Mailer
mailer: String!

Identifies the email software that sent the email.

This corresponds to the MIME X-Mailer header, which is informational and may be absent or supplied by the sending application.

top
NumAlternatives
numAlternatives: Int (read-only)

The number of alternative bodies present in the email. An alternative is one of multiple representations of the same email body, such as plain text and HTML, within a multipart/alternative message.

For example, an email containing plain-text and HTML alternatives, inline images, and an attachment may have a MIME structure similar to:

multipart/mixed
  multipart/alternative
    text/plain
    multipart/related
      text/html
      image/png
  application/pdf

In this example, the text/plain part and the multipart/related part are alternatives. The multipart/related part contains the HTML body and an inline image, while the PDF is a separate attachment.

An email that is not multipart/alternative returns 0. An email that contains alternatives returns a value greater than or equal to 1.

Alternative indexes used by methods such as GetAlternativeBody are zero-based.

top
NumAttachedMessages
numAttachedMessages: Int (read-only)

Returns the number of embedded emails. Some mail clients will embed an email that is to be forwarded into a new email as a message/rfc822 subpart of the MIME message structure. This property tells how many emails have been embedded. The original email can be retrieved by calling GetAttachedMessage.

Attached-message indexes are zero-based. Use GetAttachedEmail to copy an embedded message into another Email object.

top
NumAttachments
numAttachments: Int (read-only)

The number of attachments contained in the email.

Note: If an email is downloaded from an IMAP server without attachments, then the number of attachments should be obtained by calling the IMAP object's GetMailNumAttach method. This property indicates the actual number of attachments already present within the email object.

Attachment indexes are zero-based. Related resources referenced by an HTML body are counted separately by NumRelatedItems, and embedded emails are counted by NumAttachedMessages.

top
NumBcc
numBcc: Int (read-only)

The number of blind carbon-copy email recipients.

Bcc recipient indexes are zero-based and can be inspected with GetBcc, GetBccAddr, and GetBccName.

top
NumCC
numCC: Int (read-only)

The number of carbon-copy email recipients.

Cc recipient indexes are zero-based and can be inspected with GetCC, GetCcAddr, and GetCcName.

More Information and Examples
top
NumDaysOld
numDaysOld: Int (read-only)

Returns the number of days old from the current system date/time. The email's date is obtained from the Date header field. If the Date header field is missing, or invalid, then -9999 is returned. A negative number may be returned if the Date header field contains a future date/time. (However, -9999 represents an error condition.)

The calculation uses the parsed Date header, not the time when the message was downloaded or loaded into the object.

top
NumDigests
numDigests: Int (read-only)
Introduced in version 9.5.0.66

Returns the number of message/rfc822 parts contained within the multipart/digest enclosure. If no multipart/digest enclosure exists, then this property has the value of 0. The GetDigest method is called to get the Nth digest as an email object.

Digest indexes are zero-based. Use GetDigestEmail to retrieve an individual message from the digest.

More Information and Examples
top
NumHeaderFields
numHeaderFields: Int (read-only)

The number of header fields. When accessing a header field by index, the first header field is at index 0, and the last is at NumHeaderFields-1. (Chilkat indexing is always 0-based.)

Repeated header fields are counted separately. Use GetHeaderFieldName and GetHeaderFieldValue to enumerate them by zero-based index.

top
NumRelatedItems
numRelatedItems: Int (read-only)

The number of related items present in this email. Related items are typically image files (JPEGs or GIFs) or style sheets (CSS files) that are included with HTML formatted messages with internal CID hyperlinks.

Related-item indexes are zero-based. These items are distinct from ordinary attachments and are commonly referenced from HTML by cid: URLs.

top
NumReplacePatterns
numReplacePatterns: Int (read-only)

Returns the number of replacement patterns previously set by calling the SetReplacePattern method 1 or more times. If replacement patterns are set, the email bodies and header fields are modified by applying the search/replacement strings during the message sending process.

Pattern indexes are zero-based. Replacement patterns are retained in the email object and applied later during supported mail-merge sending operations.

More Information and Examples
top
NumReports
numReports: Int (read-only)

Contains the number of report parts in a multipart/report email.

A MIME part is counted as a report when its Content-Type is message/*, except for message/rfc822, or when its Content-Type is text/rfc822-headers. A message/rfc822 part is treated as an attached email and is counted by NumAttachedMessages.

Use GetReport to retrieve the body of each report part.

Report indexes are zero-based. Use GetReport to retrieve the content of an individual report part.

top
NumTo
numTo: Int (read-only)

The number of direct email recipients.

To-recipient indexes are zero-based and can be inspected with GetTo, GetToAddr, and GetToName.

More Information and Examples
top
OaepHash
oaepHash: String!
Introduced in version 9.5.0.67

Selects the hash algorithm for use within OAEP padding when encrypting email using RSAES-OAEP. The valid choices are sha1, sha256, sha384, sha512,

This property is used only when OaepPadding is true.

top
OaepMgfHash
oaepMgfHash: String!
Introduced in version 9.5.0.71

Selects the MGF hash algorithm for use within OAEP padding when encrypting email using RSAES-OAEP. The valid choices are sha1, sha256, sha384, sha512,

This property is used only when OaepPadding is true. Some recipients require the MGF hash to match OaepHash.

top
OaepPadding
oaepPadding: Bool
Introduced in version 9.5.0.67

Selects the RSA encryption scheme when encrypting email. The default value is false, which selects RSAES_PKCS1-V1_5. When set to true, RSAES_OAEP is used.

This affects the RSA key-encryption step used for S/MIME encryption; it does not change the symmetric content-encryption algorithm selected by Pkcs7CryptAlg.

top
OverwriteExisting
overwriteExisting: Bool

When true (the default) the methods to save email attachments and related items will overwrite files if they already exist. When false, the methods that save email attachments and related items will append a string of 4 characters to create a unique filename if a file already exists. The filename of the attachment (or related item) within the email object is updated and can be retrieved by the program to determine the actual file(s) created.

This setting applies only when attachments or related items are written to the filesystem. When false and a name collision occurs during a save operation, Chilkat chooses a unique filename and updates the corresponding filename stored in the email object.

top
Pkcs7CryptAlg
pkcs7CryptAlg: String!

When an email is sent encrypted (using PKCS#7 public-key encryption), this selects the underlying symmetric encryption algorithm. Possible values are: aes, aes-gcm, des, 3des, and rc2. The default value is aes.

Note: The aes-gcm option was added in Chilkat v10.0.0

This setting is used when S/MIME encryption is generated, typically after SendEncrypted is set to true and recipient encryption certificates have been supplied.

top
Pkcs7KeyLength
pkcs7KeyLength: Int

When the email is sent encrypted (using PKCS#7 public-key encryption), this selects the key length of the underlying symmetric encryption algorithm. The possible values allowed depend on the Pkcs7CryptAlg property. For aes, the key length may be 128, 192, or 256. For 3des the key length must be 192. For des the key length must be 40. For rc2 the key length can be 40, 56, 64, or 128.

The value must be valid for the algorithm selected by Pkcs7CryptAlg. An unsupported combination causes the encryption operation to fail.

top
PreferredCharset
preferredCharset: String!

Only applies when building an email with non-English characters where the charset is not explicitly set. The Chilkat email component will automatically choose a charset based on the languages found within an email (if the charset is not already specified within the MIME or explicitly specified by setting the Charset property). The default charset chosen for each language is:

Chinese: gb2312
Japanese: shift_JIS
Korean: ks_c_5601-1987
Thai: windows-874
All others: iso-8859-*

This allows for charsets such as iso-2022-jp to be chosen instead of the default. If the preferred charset does not apply to the situation, it is not used. For example, if the preferred charset is iso-2022-jp, but the email contains Greek characters, then the preferred charset is ignored.

This is a preference, not a forced conversion. It is ignored when the message already specifies a charset or when the requested charset cannot represent the email text.

More Information and Examples
top
PrependHeaders
prependHeaders: Bool

When true, header fields added via the AddHeaderField or AddHeaderField2 methods are prepended to the top of the header as opposed to appended to the bottom. The default value is false.

This affects header fields added after the property is set. It does not reorder fields that are already present.

top
ReceivedEncrypted
receivedEncrypted: Bool (read-only)

true if this email was originally received with encryption, otherwise false.

This records how the message was originally received. It remains useful after successful automatic decryption, when the visible body is already the decrypted content.

top
ReceivedSigned
receivedSigned: Bool (read-only)

true if this email was originally received with a digital signature, otherwise false.

This records whether the original message contained one or more digital signatures. Use SignaturesValid to determine whether the signed content verified successfully.

More Information and Examples
top
ReplyTo
replyTo: String!

Sets the Reply-To header field to the specified email address such as john@example.com. The Reply-To header automatically defaults to the From email address. You would only set this property if you wish for the Reply-To email address to be different from the From address.

There is usually only a single Reply-To email address. If multiple Reply-To addresses are needed, then set with a comma-separated list of email addresses such as john@example.com, mary@somewhere.com.

This changes the MIME Reply-To header only; it does not change the SMTP envelope sender or the visible From header.

top
ReturnReceipt
returnReceipt: Bool

Set to true if you want the email to request a return-receipt when received by the recipient. The default value is false.

Setting this property causes the Disposition-Notification-To email header to be added when the email is sent.

A return receipt is only a request. The recipient's mail client or server may ignore it, and a receipt is not proof that the message was read by a person.

top
SendEncrypted
sendEncrypted: Bool

Set to true if this email should be sent encrypted.

Encryption requires one or more recipient certificates, supplied with methods such as AddEncryptCert or SetEncryptCert. Setting this property alone does not provide a certificate.

top
SendSigned
sendSigned: Bool

Set to true if this email should be sent with a digital signature.

Note: Please be aware of the Apple Mail bug explained in the webpage at the link below.

Signing requires a certificate with access to its private key, supplied with SetSigningCert or SetSigningCert2.

top
SignaturesValid
signaturesValid: Bool (read-only)

true if the email was received with one or more digital signatures, and if all the signatures were validated indicating that the email was not altered. Otherwise this property is set to false. (This property is only meaningful when the ReceivedSigned property is equal to true.)

This indicates cryptographic integrity of the signed content. Applications that also require certificate trust should separately examine the signer certificate and its chain.

More Information and Examples
top
SignedBy
signedBy: String! (read-only)

If the email was received digitally signed, this property contains the fields of the certificate's SubjectDN.

For example: US, 94105, California, San Francisco, 100 Market Street, Northwind Research LLC, Engineering, Avery Morgan

This is similar to a distinguished name (DN), but without the attribute names, such as C=, ST=, L=, O=, and CN=, preceding each value.

This is intended for display or diagnostics. Use LastSignerCert when the signer certificate itself is needed.

top
SigningAlg
signingAlg: String!
Introduced in version 9.5.0.67

Selects the signature algorithm to be used when sending signed (PKCS#7) email. The default value is PKCS1-v1_5. This can be set to RSASSA-PSS (or simply pss) to use the RSASSA-PSS signature scheme.

Note: This property only applies when signing with an RSA private key. It does not apply for ECC or DSA private keys.

This setting is used only for RSA signing. The selected scheme must also be supported by the private key provider.

top
SigningHashAlg
signingHashAlg: String!

Selects the underlying hash algorithm used when sending signed (PKCS#7) email. Possible values are sha1, sha256, sha384, sha512, md5, and md2.

This property controls the message-digest algorithm placed in the signature. It is used only when a signed message is generated.

top
Size
size: Int (read-only)

The size in bytes of the email, including all parts and attachments.

Note: This property is only valid if the full email was downloaded. If only the header was downloaded, then this property will contain the size of just the header.

This value describes the email data currently present in the object. It should not be used as the server-reported full message size when only a partial message was downloaded.

top
Subject
subject: String!

The email subject.

This property reads or writes the MIME Subject header. Chilkat performs the required MIME header encoding when the subject contains non-ASCII characters.

top
Uidl
uidl: String! (read-only)

Contains the unique message identifier assigned by a POP3 server. The value is also represented by the X-UIDL header field.

Important: UIDLs are specific to POP3. IMAP uses UIDs instead. An email downloaded through Chilkat.Imap stores its IMAP identifier in the ckx-imap-uid header. The ckx-imap-isUid header contains YES when that value is an IMAP UID, or NO when it is a mailbox sequence number.

A UIDL identifies a POP3 message within the server's mailbox and is normally used to avoid downloading the same message repeatedly.

top
UncommonOptions
uncommonOptions: String!
Introduced in version 9.5.0.79

This is a catch-all property to be used for uncommon needs. This property defaults to the empty string, and should typically remain empty.

  • NoBccHeader - (added in v11.0.0) Do not add the Bcc MIME header for BCC email addresses. Note: The NoBccHeader keyword must be present before calling AddBcc or AddMultipleBcc
  • NO_FORMAT_FLOWED - Don't automatically add format=flowed to any Content-Type header.

Leave this property empty unless a documented compatibility option is specifically required. Unrecognized keywords should not be assumed to have any effect.

top
UnpackUseRelPaths
unpackUseRelPaths: Bool

Applies to the UnpackHtml method. When true, relative paths are used within the HTML for the links to the related files (images and style sheets) that were unpacked to the filesystem. Otherwise absolute paths are used. The default value is true.

Relative paths are usually preferable when the unpacked HTML directory will be moved or deployed as a unit. Absolute paths can be useful for immediate local viewing.

top
VerboseLogging
verboseLogging: Bool

If set to true, then the contents of LastErrorText (or LastErrorXml, or LastErrorHtml) may contain more verbose information. The default value is false. Verbose logging should only be used for debugging. The potentially large quantity of logged information may adversely affect peformance.

top
Version
version: String! (read-only)

Version of the component/library, such as "10.1.0"

More Information and Examples
top

Methods

AddAttachmentBd
addAttachmentBd(filename: String, binData: CkoBinData, contentType: String) -> Bool
Introduced in version 9.5.0.63

Adds an attachment using the contents of a BinData object. If contentType is empty, then the Content-Type will be inferred from extension.

is the filename stored in MIME, not a filesystem path. The bytes are taken from binData.

Returns true for success, false for failure.

More Information and Examples
top
AddAttachmentHeader
addAttachmentHeader(index: Int, fieldName: String, fieldValue: String)

Adds or replaces a MIME header field in one of the email attachments. If the header field does not exist, it is added. Otherwise it is replaced.

Indexing: is zero-based and must identify an existing attachment. This changes the attachment MIME header in the current email object; it does not modify the original source file.

More Information and Examples
top
AddBcc
addBcc(friendlyName: String, emailAddress: String) -> Bool

Adds a recipient to the blind carbon-copy (BCC) list. emailAddress is required; is optional. Call this method separately for each BCC recipient.

Note: Before v11.0.0, BCC addresses are not added to the MIME header. After v11.0.0, BCC addresses are included in the MIME header. Most email servers remove the BCC header before delivering the message to regular recipients. The NoBccHeader keyword can be used in UncommonOptions to prevent BCC email addresses in the MIME passed to the SMTP server. If your application specifies NoBccHeader, do so before adding BCC addresses.

The recipient is added to the in-memory message only. The message is not transmitted until it is passed to a sending method of MailMan.

Returns true for success, false for failure.

top
AddCC
addCC(friendlyName: String, emailAddress: String) -> Bool

Adds a recipient to the carbon-copy list. emailAddress is required, but may be empty.

To add multiple CC recipients, call this method once per recipient.

The recipient is added to the in-memory message only. Use NumCC and the Cc getter methods to inspect the resulting list.

Returns true for success, false for failure.

More Information and Examples
top
AddDataAttachment
addDataAttachment(fileName: String, content: NSData) -> Bool

Adds an attachment directly from data in memory to the email.

is the filename that appears in MIME; it does not need to be an existing local path. content supplies the attachment bytes.

Returns true for success, false for failure.

top
AddDataAttachment2
addDataAttachment2(fileName: String, content: NSData, contentType: String) -> Bool

Adds an attachment to an email from in-memory data. Same as AddDataAttachment but allows the Content-Type to be specified.

is the MIME filename, content contains the attachment bytes, and contentType is the MIME type such as application/pdf.

Returns true for success, false for failure.

top
AddEncryptCert
addEncryptCert(cert: CkoCert) -> Bool

Allows for certificates to be explicitly specified for sending encrypted email to one or more recipients. Call this method once per certificate to be used. The ClearEncryptCerts method may be called to clear the list of explicitly-specified certificates.

Note: It is possible to send encrypted email without explicitly specifying the certificates. On Windows, the registry-based Current-User and Local-Machine certificate stores are automatically searched for certificates matching each recipient in the To, CC, and BCC lists. On macOS, the Keychain is automatically searched for matching recipient certificates.

Note: The SetEncryptCert method is equivalent to calling ClearEncryptCerts followed by AddEncryptCert.

Use this method when encrypting for multiple recipients: add each recipient certificate separately. For a single explicitly selected certificate, SetEncryptCert may be simpler.

Returns true for success, false for failure.

top
AddFileAttachment
addFileAttachment(path: String) -> String

Adds a file as an attachment to the email. Returns the MIME Content-Type of the attachment, which is inferred based on the filename extension.

The file is read and incorporated into the current email object. is a local filesystem path, while the attachment filename placed in MIME is derived from the path.

Returns nil on failure

top
AddFileAttachment2
addFileAttachment2(path: String, contentType: String) -> Bool

Same as AddFileAttachment, but the content type can be explicitly specified.

Use this form when filename-based MIME type inference is unsuitable. contentType should be a MIME media type such as application/octet-stream.

Returns true for success, false for failure.

More Information and Examples
top
AddHeaderField
addHeaderField(fieldName: String, fieldValue: String)

Any standard or non-standard (custom) header field can be added to the email with this method. One interesting feature is that all header fields whose name begins with CKX- will not be included in the header when an email is sent. These fields will be included when saved to or loaded from XML. This makes it easy to include persistent meta-data with an email which your programs can use in any way it chooses.

Important: This method will replace an already-existing header field. To allow for adding duplicate header fields, call AddHeaderField2 (see below).

This changes the MIME header stored in the current email object. It does not change the SMTP envelope, except where another component explicitly interprets a particular header.

top
AddHeaderField2
addHeaderField2(fieldName: String, fieldValue: String)

This method is the same as AddHeaderField, except that if the header field already exists, it is not replaced. A duplicate header will be added.

Use this method for headers that may legally occur more than once, such as Received. For a single-valued field that should be replaced, use AddHeaderField.

top
AddHtmlAlternativeBody
addHtmlAlternativeBody(body: String) -> Bool

Sets the HTML body of the email. Use this method if there will be multiple versions of the body, but in different formats, such as HTML and plain text. Otherwise, set the body by calling the SetHtmlBody method.

When paired with AddPlainTextAlternativeBody, Chilkat creates a multipart/alternative body so mail clients can choose the representation they support.

Returns true for success, false for failure.

More Information and Examples
top
AddiCalendarAlternativeBody
addiCalendarAlternativeBody(body: String, methodName: String) -> Bool

Adds an iCalendar body as a text/calendar alternative.

contains the iCalendar data. methodName specifies the method parameter placed in the alternative body's Content-Type header, such as REQUEST.

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//hacksw/handcal//NONSGML v1.0//EN
BEGIN:VEVENT
UID:uid1@example.com
DTSTAMP:19970714T170000Z
ORGANIZER;CN=John Doe:MAILTO:john.doe@example.com
DTSTART:19970714T170000Z
DTEND:19970715T035959Z
SUMMARY:Bastille Day Party
END:VEVENT
END:VCALENDAR

For example, when methodName is REQUEST, the MIME headers for the alternative body include:

Content-Type: text/calendar; method=REQUEST
Content-Transfer-Encoding: base64

Calendar-aware mail clients may display this part as a meeting invitation, cancellation, or published event according to the iCalendar METHOD value and the contents of .

Returns true for success, false for failure.

top
AddMultipleBcc
addMultipleBcc(commaSeparatedAddresses: String) -> Bool

Adds multiple recipients to the blind carbon-copy list from a comma-separated string of email addresses.

Note: Before v11.0.0, BCC addresses are not added to the MIME header. After v11.0.0, BCC addresses are included in the MIME header. Most email servers remove the BCC header before delivering the message to regular recipients. The NoBccHeader keyword can be used in UncommonOptions to prevent BCC email addresses in the MIME passed to the SMTP server. If your application specifies NoBccHeader, do so before adding BCC addresses.

The parsed recipients are appended to the existing Bcc list. Each item may be a bare address or a mailbox containing a display name.

Returns true for success, false for failure.

top
AddMultipleCC
addMultipleCC(commaSeparatedAddresses: String) -> Bool

Adds the comma-separated email addresses in to the carbon-copy (Cc) recipient list.

Each item may be a bare address or a mailbox containing a display name. The parsed recipients are appended to the existing Cc list.

Returns true for success, false for failure.

top
AddMultipleTo
addMultiple(to: String) -> Bool

Adds the comma-separated email addresses in to to the direct-recipient (To) list.

Each item may be a bare address or a mailbox containing a display name. The parsed recipients are appended to the existing To list.

Returns true for success, false for failure.

top
AddPfxSourceBd
addPfxSourceBd(bd: CkoBinData, password: String) -> Bool
Introduced in version 11.0.0

Adds the PFX data in to the list of certificate and private-key sources used during decryption or signing. password contains the PFX password.

Call this method once for each additional PFX source.

The PFX data becomes a lookup source for subsequent cryptographic operations by this object. Adding it does not immediately decrypt or sign the message.

Returns true for success, false for failure.

top
AddPfxSourceData
addPfxSourceData(pfxData: NSData, password: String) -> Bool

Adds the PFX data in to the internal list of certificate and private-key sources used during decryption. pfxPassword contains the PFX password.

Call this method once for each additional PFX source. On Windows, Chilkat automatically searches the system certificate stores. On macOS, Chilkat automatically searches the Keychain. Therefore, explicitly adding a PFX source is often unnecessary when the required certificate and private key are already installed.

The PFX is retained as a certificate source for later operations performed by this email object. Adding a source does not itself decrypt or sign the current message.

Returns true for success, false for failure.

top
AddPfxSourceFile
addPfxSourceFile(pfxFilePath: String, password: String) -> Bool

Adds the PFX file specified by to the internal list of certificate and private-key sources used during decryption. pfxPassword contains the PFX password.

Call this method once for each additional PFX file. On Windows, Chilkat automatically searches the system certificate stores. On macOS, Chilkat automatically searches the Keychain. Therefore, explicitly adding a PFX source is often unnecessary when the required certificate and private key are already installed.

The PFX file becomes a certificate source for later operations performed by this email object. The file must be readable when this method is called.

Returns true for success, false for failure.

top
AddPlainTextAlternativeBody
addPlainTextAlternativeBody(body: String) -> Bool

Sets the plain-text body of the email. Use this method if there will be multiple versions of the body, but in different formats, such as HTML and plain text. Otherwise, simply set the Body property.

When paired with AddHtmlAlternativeBody, Chilkat creates a multipart/alternative body so text-only clients have a suitable representation.

Returns true for success, false for failure.

More Information and Examples
top
AddRelatedBd
addRelatedBd(filename: String, binData: CkoBinData) -> String
Introduced in version 9.5.0.65

Adds a related item using the contents of a BinData object. Returns the Content-ID for the newly added related item.

The returned Content-ID can be used in the HTML body as cid:returnedContentId.

Returns nil on failure

top
AddRelatedBd2
addRelatedBd2(binData: CkoBinData, fileNameInHtml: String) -> Bool
Introduced in version 9.5.0.65

Adds a related item using the binary data in .

fileNameInHtml specifies the filename, path, or URL used by the corresponding HTML reference, such as an img element's src attribute.

This form is useful when the HTML already contains a filename, URL, or path reference that Chilkat should associate with the new related MIME part.

Returns true for success, false for failure.

top
AddRelatedData
addRelatedData(fileName: String, in: NSData) -> String

Adds the memory data as a related item to the email and returns the Content-ID. Emails formatted in HTML can include images with this call and internally reference the image through a cid hyperlink. (Chilkat Email.NET fully supports the MHTML standard.)

The returned Content-ID can be inserted into the HTML body as a cid: reference. A related item is part of the HTML presentation and is separate from an ordinary downloadable attachment.

Returns nil on failure

top
AddRelatedData2
addRelatedData2(inData: NSData, fileNameInHtml: String)

Adds a related item to the email from in-memory byte data. Related items are things such as images and style sheets that are embedded within an HTML email. They are not considered attachments because their sole purpose is to participate in the display of the HTML. This method differs from AddRelatedData in that it does not use or return a Content-ID. The filename argument should be set to the filename used in the HTML img tag's src attribute (if it's an image), or the URL referenced in an HTML link tag for a stylesheet.

Use this form when the HTML already contains a filename, path, or URL that should be associated with the new related MIME part.

top
AddRelatedFile
addRelatedFile(path: String) -> String

Adds the contents of a file to the email and returns the Content-ID. Emails formatted in HTML can include images with this call and internally reference the image through a cid hyperlink. (Chilkat Email.NET fully supports the MHTML standard.)

The returned Content-ID can be inserted into the HTML body as a cid: reference. The file becomes a related MIME resource rather than an ordinary attachment.

Returns nil on failure

top
AddRelatedFile2
addRelatedFile2(fileNameOnDisk: String, filenameInHtml: String) -> Bool

Adds a related item from the local file specified by . Related items are resources, such as images and style sheets, used to render the HTML body and are not treated as ordinary attachments.

filenameInHtml specifies the filename, path, or URL used by the corresponding HTML reference, such as an img element's src attribute. Unlike AddRelatedFile, this method does not create or return a Content-ID.

Note: Outlook.com may fail to display embedded images when filenameInHtml contains a path. For best compatibility, use only a filename when targeting Outlook.com.

This form is useful when the HTML body already refers to the resource by filename, path, or URL and Chilkat should rewrite or associate that reference.

Returns true for success, false for failure.

top
AddRelatedHeader
addRelatedHeader(index: Int, fieldName: String, fieldValue: String)

Adds or replaces a MIME header field in one of the email's related items. If the header field does not exist, it is added. Otherwise it is replaced.

Indexing: is zero-based and must identify an existing related item. The change applies to the related item's MIME sub-header.

top
AddRelatedString
addRelatedString(nameInHtml: String, str: String, charset: String) -> String

Adds a text-based related item, such as a style sheet or other resource referenced by the HTML body.

is the filename or resource name used by the HTML, not a path to a local file. str contains the text content, and charset specifies the charset used to encode that text.

Returns the generated Content-ID for the newly added related item.

Use the returned Content-ID in a cid: reference when the HTML should address the new resource by Content-ID.

Returns nil on failure

top
AddRelatedString2
addRelatedString2(filenameInHtml: String, str: String, charset: String)

Adds a related item to the email from an in-memory string. Related items are things such as images and style sheets that are embedded within an HTML email. They are not considered attachments because their sole purpose is to participate in the display of the HTML. The filenameInHtml argument should be set to the filename used in the HTML img tag's src attribute (if it's an image), or the URL referenced in an HTML link tag for a stylesheet. The charset argument indicates that the content should first be converted to the specified charset prior to adding to the email. It should hava a value such as iso-8859-1, utf-8, Shift_JIS, etc.

This method converts the Unicode string to the specified charset before creating the MIME part. The resource is related content, not a normal file attachment.

top
AddStringAttachment
addStringAttachment(fileName: String, str: String) -> Bool

Adds an attachment directly from a string in memory to the email.

supplies the filename placed in MIME, not a file to be read. content is the text content that becomes the attachment body.

Returns true for success, false for failure.

More Information and Examples
top
AddStringAttachment2
addStringAttachment2(fileName: String, str: String, charset: String) -> Bool

Adds a text attachment using the in-memory string in content.

specifies the attachment filename; it is not a path to an existing local file. charset specifies the charset used to encode the string before it is added to the email.

Note: charset may begin with bom- or no-bom- to require or suppress a byte-order mark for encodings such as UTF-8 or UTF-16. Examples include bom-utf-8 and no-bom-utf-8.

This method is appropriate for text data already held in memory. For arbitrary binary bytes, use a BinData- or byte-based attachment method instead.

Returns true for success, false for failure.

top
AddTo
add(to: String, emailAddress: String) -> Bool

Adds a recipient to the to list. emailAddress is required, but to may be empty. Emails that have no To recipients will be sent to <undisclosed-recipients>.

To add multiple recipients, call this method once per TO recipient.

The recipient is added to the current in-memory message. Use NumTo and the To getter methods to inspect the resulting list.

Returns true for success, false for failure.

More Information and Examples
top
AesDecrypt
aesDecrypt(password: String) -> Bool

Decrypts and restores an email message that was previously encrypted using AesEncrypt. The password must match the password used for encryption.

This is Chilkat's password-based email-object encryption counterpart to AesEncrypt; it is not S/MIME certificate-based decryption.

Returns true for success, false for failure.

top
AesEncrypt
aesEncrypt(password: String) -> Bool

Encrypts the email body, all alternative bodies, all message sub-parts and attachments using 128-bit AES CBC encryption. Decrypting is achieved by calling AesDecrypt with the same password. The AesEncrypt/Decrypt methods use symmetric password-based AES encryption and greatly simplify sending and receiving encrypted emails because certificates and private keys are not used. However, the sending and receiving applications must both use Chilkat, and the password must be pre-known on both ends.

This is password-based encryption of the email object and is separate from S/MIME encryption controlled by SendEncrypted. The recipient must use the same password and compatible Chilkat decryption.

Returns true for success, false for failure.

top
AppendToBody
append(toBody: String)

Appends a string to the plain-text body.

If the message has only an HTML body, this method does not append HTML. Use SetHtmlBody or retrieve and reset the HTML body when HTML content must be extended.

top
ApplyFixups
applyFixups(fixups: String) -> Bool
Introduced in version 9.5.0.71

Repairs selected MIME-formatting problems commonly found in email produced by other software.

is a comma-separated list of fixup keywords. The following keyword is currently defined:

  • FixRelated — Relocates HTML-related items, such as embedded images, into the appropriate MIME structure so they are not incorrectly presented as ordinary attachments.

Fixups modify the current in-memory MIME structure. Apply them only when the input message exhibits the corresponding formatting problem.

Returns true for success, false for failure.

top
AspUnpack
aspUnpack(prefix: String, saveDir: String, urlPath: String, cleanFiles: Bool) -> Bool

Please see the examples at the following pages for detailed information:

This is a legacy helper for unpacking an email for use by an ASP application. The linked examples define the directory and URL mapping expected by the arguments.

Returns true for success, false for failure.

top
AspUnpack2
aspUnpack2(prefix: String, saveDir: String, urlPath: String, cleanFiles: Bool) -> NSData

Please see the examples at the following pages for detailed information:

This is a legacy helper for unpacking an email for use by an ASP application. The linked examples define the directory and URL mapping expected by the arguments.

Returns nil on failure

top
AttachEmail
attach(email: CkoEmail) -> Bool
Introduced in version 9.5.0.87

Attaches copy of to this email object. The attached email will be encapsulated in an message/rfc822 sub-part.

A copy is attached, so later changes to do not change the embedded message. The new part is counted by NumAttachedMessages.

Returns true for success, false for failure.

top
AttachMessage
attachMessage(mimeBytes: NSData) -> Bool

Attaches a MIME message to the email object. The attached MIME will be encapsulated in an message/rfc822 sub-part.

The attached message is counted by NumAttachedMessages and can later be retrieved as an Email object.

Returns true for success, false for failure.

top
BEncodeBytes
bEncodeBytes(inData: NSData, charset: String) -> String

Takes a byte array of multibyte (non-Unicode) data and returns a Unicode B-Encoded string.

B-encoding is commonly used in RFC 2047 encoded words for non-ASCII MIME header text. charset identifies the charset represented by the input bytes.

Returns nil on failure

top
BEncodeString
bEncodeString(str: String, charset: String) -> String

Takes a Unicode string, converts it to the charset specified in the second parameter, B-Encodes the converted multibyte data, and returns the encoded Unicode string.

B-encoding is commonly used in RFC 2047 encoded words for non-ASCII MIME header text. charset controls the byte charset used before Base64 encoding.

Returns nil on failure

top
Clear
clear()
Introduced in version 9.5.0.76

Removes all current email content and restores the object to its newly created state. The reset object contains the default headers normally initialized by Chilkat, such as MIME-Version, Date, Message-ID, Content-Type, Content-Transfer-Encoding, and X-Priority.

This changes only the current in-memory Email object and does not delete or alter a message on a mail server.

top
ClearBcc
clearBcc()

Clears the list of blind carbon-copy recipients.

This changes only the current email object and does not affect messages already sent.

top
ClearCC
clearCC()

Clears the list of carbon-copy recipients.

This changes only the current email object and does not affect messages already sent.

top
ClearEncryptCerts
clearEncryptCerts()

Clears the internal list of explicitly specified certificates to be used for this encrypted email.

This removes certificates added explicitly for future encryption operations. It does not remove certificates from the Windows certificate stores, the macOS Keychain, or any PFX source.

top
ClearTo
clearTo()

Clears the list of to recipients.

This changes only the current email object and does not affect messages already sent.

top
ComputeGlobalKey2
computeGlobalKey2(encoding: String, bFold: Bool) -> String
Introduced in version 9.5.0.59

Computes a global unique key for the email. The key is created by a digest-MD5 hash of the concatenation of the following:

messageID + CRLF + subject + CRLF + from + CRLF + date + CRLF + recipientAddrs

messageID contains the contents of the <code>Message-ID</code> header field.
subject contains the contents of the <code>Subject</code> header field, trimmed of whitespace from both ends,
 where TAB characters are converted to SPACE characters, and internal whitespace is trimmed so that
 no more than one SPACE char in a row exists.
from contains the lowercase <code>From</code> header email address.
date contains the contents of the <code>Date</code> header field.
toAddrs contains lowercase To and Cc recipient email addresses, comma-separated, with duplicates removed, and sorted
 in ascending order. The BCC addresses are NOT included.

(After calling this method, the LastErrorText property can be examined to see the string that was hashed.)

The 16-byte MD5 hash is returned as an encoded string. determines the encoding: base64, hex, url, etc. If bFold is true, then the 16-byte MD5 hash is folded to 8 bytes with an XOR to produce a shorter key.

The result is intended as a deterministic message key for indexing or duplicate detection. It is separate from the MIME Message-ID and does not modify the email.

Returns nil on failure

top
ConvertInlineImages
convertInlineImages() -> Bool
Introduced in version 9.5.0.78

Converts images embedded inline within HTML to multipart/related MIME parts referenced from the HTML by CID.

This is useful for producing conventional HTML email where image data is stored in MIME parts rather than directly in the HTML. Review the resulting HTML and related-item collection after conversion.

Returns true for success, false for failure.

top
CreateTempMht
createTempMht(inPath: String) -> String

Saves the email to a temporary MHT file so that a WebBrowser control can navigate to it and display it. If fileName is empty, a temporary filename is generated and returned. If fileName is non-empty, then it will be created or overwritten, and the input filename is simply returned.The MHT file that is created will not contain any of the email's attachments, if any existed. Also, if the email was plain-text, the MHT file will be saved such that the plain-text is converted to HTML using pre-formatted text (pre HTML tags) allowing it to be displayed correctly in a WebBrowser.

This method creates a local temporary presentation file; it does not send the email or publish the file. The caller should remove the temporary file when it is no longer needed.

Returns nil on failure

top
DropAttachments
dropAttachments()

Removes all attachments from the email.

This removes ordinary file attachments from the in-memory message. Related items and attached message/rfc822 emails are separate and are not described by this method.

top
DropRelatedItem
dropRelatedItem(index: Int)

A related item is typically an embedded image referenced from the HTML in the email via a CID hyperlink. This method removes the Nth embedded image from the email. Note: If the HTML tries to reference the removed image, it will be displayed as a broken image link.

This changes only the current in-memory Email object and does not delete or alter a message on a mail server.

top
DropRelatedItems
dropRelatedItems()

A related item is typically an embedded image referenced from the HTML in the email via a CID hyperlink. This method removes all the embedded images from the email.

This removes related MIME resources from the in-memory message. It does not remove ordinary attachments.

top
DropSingleAttachment
dropSingleAttachment(index: Int) -> Bool

Removes the attachment at the zero-based index specified by .

is zero-based; valid values are from 0 through NumAttachments - 1.

Returns true for success, false for failure.

top
GenerateFilename
generateFilename() -> String

Generates a unique filename for this email. The filename will be different each time the method is called.

This method returns a filename only; it does not create a file. It is useful when saving many messages and a collision-resistant local name is needed.

Returns nil on failure

top
GetAlternativeBody
getAlternativeBody(index: Int) -> String

Returns the Nth alternative body. The NumAlternatives property tells the number of alternative bodies present. Use the GetHtmlBody and GetPlainTextBody methods to easily get the HTML or plain text alternative bodies.

is zero-based; valid values are from 0 through NumAlternatives - 1.

Returns nil on failure

top
GetAlternativeBodyBd
getAlternativeBodyBd(index: Int, binData: CkoBinData) -> Bool
Introduced in version 9.5.0.67

Returns the contents of the Nth alternative body to binData. The first alternative body is at index 0. This method should only be called when the NumAlternatives property has a value greater than 0.

is zero-based; valid values are from 0 through NumAlternatives - 1. binData receives the body bytes.

Returns true for success, false for failure.

top
GetAlternativeBodyByContentType
getAlternativeBody(byContentType: String) -> String

Returns the alternative body by Content-Type, such as text/plain, text/html, text/xml, etc.

The lookup is useful when the alternative order is not known. Typical values for byContentType are text/plain and text/html.

Returns nil on failure

top
GetAlternativeContentType
getAlternativeContentType(index: Int) -> String

Returns the content type of the Nth alternative body. The NumAlternatives property tells the number of alternative bodies present.

is zero-based; valid values are from 0 through NumAlternatives - 1.

Returns nil on failure

top
GetAltHeaderField
getAltHeaderField(index: Int, fieldName: String) -> String

Returns the value of a header field within the Nth alternative body's MIME sub-part.

is zero-based and refers to an alternative counted by NumAlternatives. fieldName names the MIME header field within that alternative part.

Returns nil on failure

top
GetAttachedEmail
getAttached(index: Int, email: CkoEmail) -> Bool
Introduced in version 11.0.0

Copies the Nth embedded message/rfc822 MIME part into email. is a zero-based index.

is zero-based; valid values are from 0 through NumAttachedMessages - 1. email is replaced with a copy of the embedded message.

Returns true for success, false for failure.

top
GetAttachedMessageAttr
getAttachedMessageAttr(index: Int, fieldName: String, attrName: String) -> String
Introduced in version 9.5.0.41

Returns a header field attribute value for the Nth attached (embedded) email. For example, to get the value of the name attribute in the Content-Type header for the first attached message:

Content-Type: message/rfc822; name="md75000024149.eml"

then the method arguments should contain the values 0, Content-Type, name.

is a zero-based attached-message index. fieldName names a MIME header field and attrName names one of that field's parameters.

Returns nil on failure

top
GetAttachedMessageFilename
getAttachedMessageFilename(index: Int) -> String

Returns the filename of the Nth attached (embedded) email. The filename is the filename attribute of the Content-Disposition header field found within the Nth message/rfc822 sub-part of the calling email object.

Important: The attached message filename is only present if the Content-Disposition header exists AND contains a filename attribute. If questions arise, one could open the email in a text editor to examine the MIME sub-header for the attached message (where the Content-Type = message/rfc822). For example, here is a sub-header that has a filename:

Content-Type: message/rfc822; name="GetAttachedMessageAttr.eml"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="GetAttachedMessageAttr.eml"

Here is an attached message sub-header that does NOT have a filename:

Content-Type: message/rfc822
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment

is zero-based. The returned value comes from MIME metadata and should be sanitized before it is used as a local filesystem name.

Returns nil on failure

top
GetAttachmentAttr
getAttachmentAttr(index: Int, fieldName: String, attrName: String) -> String
Introduced in version 9.5.0.41

Returns a header field attribute value from the header field of the Nth attachment.

is a zero-based attachment index. fieldName names a header field such as Content-Type, and attrName names one of that field's parameters, such as charset or name.

Returns nil on failure

top
GetAttachmentBd
getAttachmentBd(index: Int, binData: CkoBinData) -> Bool
Introduced in version 9.5.0.67

Copies an attachment's binary data into binData. The first attachment is at index 0.

is zero-based. binData receives the attachment bytes.

Returns true for success, false for failure.

top
GetAttachmentContentID
getAttachmentContentID(index: Int) -> String

Returns the ContentID header field for the Nth attachment. The first attachment is at index 0.

is zero-based. The returned value is the identifier used by cid: references when the attachment is referenced inline.

Returns nil on failure

top
GetAttachmentContentType
getAttachmentContentType(index: Int) -> String

Returns the Content-Type header field for the Nth attachment. Indexing of attachments begins at 0.

is zero-based. The result is the MIME media type without implying that the filename extension is trustworthy.

Returns nil on failure

top
GetAttachmentData
getAttachmentData(index: Int) -> NSData

Retrieves an attachment's binary data for in-memory access.

is zero-based. This legacy byte-array method loads data already present in the email object and does not download missing attachment data from a server.

Returns nil on failure

top
GetAttachmentFilename
getAttachmentFilename(index: Int) -> String

Retrieves an attachment's filename.

is zero-based. The returned value is the filename stored in MIME and is not necessarily a safe or unique local filesystem name.

Returns nil on failure

top
GetAttachmentHeader
getAttachmentHeader(index: Int, fieldName: String) -> String

Returns the value of a header field (by name) of an attachment.

is a zero-based attachment index and fieldName is the MIME header-field name. Header-field names are case-insensitive.

Returns nil on failure

top
GetAttachmentSize
getAttachmentSize(index: Int) -> Int

Returns the size (in bytes) of the Nth attachment. The first attachment is at index 0. Returns -1 if there is no attachment at the specified index.

The size is the decoded attachment content size, not the number of Base64 characters in the MIME representation.

top
GetAttachmentString
getAttachmentString(index: Int, charset: String) -> String

Returns the attachment at the zero-based index specified by as text.

charset specifies the charset used to interpret the attachment bytes, such as utf-8. CRLF sequences in the attachment are normalized to single newline characters in the returned string.

is zero-based. charset controls conversion of the attachment bytes to Unicode; use a binary attachment getter when the content is not text.

Returns nil on failure

top
GetAttachmentStringCrLf
getAttachmentStringCrLf(index: Int, charset: String) -> String

Retrieves an attachment's data as a String. All end-of-lines will be translated to CRLF sequences.

is a zero-based attachment index. charset specifies the charset used to decode the attachment bytes to Unicode text.

Returns nil on failure

top
GetBcc
getBcc(index: Int) -> String

Returns a blind carbon-copy recipient's full email address.

is zero-based; valid values are from 0 through NumBcc - 1. The result may include both display name and address.

Returns nil on failure

More Information and Examples
top
GetBccAddr
getBccAddr(index: Int) -> String

Returns the Nth BCC address (only the address part, not the friendly-name part).

is zero-based; valid values are from 0 through NumBcc - 1.

Returns nil on failure

More Information and Examples
top
GetBccName
getBccName(index: Int) -> String

Returns the Nth BCC name (only the friendly-name part, not the address part).

is zero-based; valid values are from 0 through NumBcc - 1.

Returns nil on failure

More Information and Examples
top
GetCC
getCC(index: Int) -> String

Returns a carbon-copy recipient's full email address.

is zero-based; valid values are from 0 through NumCC - 1. The result may include both display name and address.

Returns nil on failure

More Information and Examples
top
GetCcAddr
getCcAddr(index: Int) -> String

Returns the Nth CC address (only the address part, not the friendly-name part).

is zero-based; valid values are from 0 through NumCC - 1.

Returns nil on failure

top
GetCcName
getCcName(index: Int) -> String

Returns the Nth CC name (only the friendly-name part, not the address part).

is zero-based; valid values are from 0 through NumCC - 1.

Returns nil on failure

top
GetDeliveryStatusInfo
getDeliveryStatusInfo(fieldName: String) -> String

Returns a field from the message/delivery-status part of a delivery-status notification.

Call this method only for an email identified as a multipart/report delivery-status notification. specifies the field name, such as Final-Recipient, Status, Action, or Reporting-MTA.

Reporting-MTA: dns; XYZ.abc.nl

Final-Recipient: RFC822; someEmailAddr@doesnotexist123.nl
Action: failed
Status: 5.4.4

names a field in the delivery-status section. This method reads the report already present in the email object and performs no server query.

Returns nil on failure

top
GetDigestEmail
getDigest(index: Int, email: CkoEmail) -> Bool
Introduced in version 11.0.0

Returns in email the Nth digest email contained within a multipart/digest. The first digest is at index 0. Use the NumDigests property to get the number of digests available.

is zero-based; valid values are from 0 through NumDigests - 1. email receives a copy of the digest message.

Returns true for success, false for failure.

top
GetDsnInfo
getDsnInfo(json: CkoJsonObject) -> Bool
Introduced in version 11.0.0

If the IsMultipartReport property indicates that the email is multipart/report, you can use this method to obtain the delivery status information, including the final recipients, in a JSON format that is easy to parse.

The JSON is derived from report data already contained in the email; the method does not contact an SMTP server for updated status.

Returns true for success, false for failure.

More Information and Examples
top
GetFileContent
getFileContent(path: String) -> NSData

Reads a file and returns the contents. This is here purely for convenience.

This convenience method is unrelated to the structure of the current email and does not modify the email object.

Returns nil on failure

top
GetHeaderField
getHeaderField(fieldName: String) -> String

Returns the value of a header field.

Header-field names are case-insensitive. If a field occurs more than once, use indexed header enumeration when each occurrence must be inspected separately.

Returns nil on failure

top
GetHeaderFieldName
getHeaderFieldName(index: Int) -> String

Return the name of the Nth header field. The NumHeaderFields() method can be used to get the number of header fields. The GetHeaderField() method can be used to get the value of the field given the field name.

The first header field is at index 0. (All Chilkat indexing is 0-based.)

is zero-based; valid values are from 0 through NumHeaderFields - 1. Repeated fields appear as separate entries.

Returns nil on failure

More Information and Examples
top
GetHeaderFieldValue
getHeaderFieldValue(index: Int) -> String

Returns the value of the Nth header field. (Indexing begins at 0) The number of header fields can be obtained from the NumHeaderFields property.

The first header field is at index 0, the last header field is at index NumHeaderFields-1. (All Chilkat indexing is 0-based.)

is zero-based; valid values are from 0 through NumHeaderFields - 1. Use the same index with GetHeaderFieldName to identify the field.

Returns nil on failure

top
GetHtmlBody
getHtmlBody() -> String

Returns the body having the text/html content type.

This reads the HTML representation already present in the email object. It does not automatically inline related images; use GetHtmlBodySb for that option.

Returns nil on failure

top
GetHtmlBodySb
getHtmlBodySb(inlineImageData: Bool, sb: CkoStringBuilder) -> Bool
Introduced in version 10.1.2

Returns the body having the text/html content type. If is true, the related images found in the MIME are inlined as base64 directly within the returned HTML. The HTML is returned in sb.

Inlining related images can substantially increase the size of the returned HTML because the image bytes are embedded as data URLs.

Returns true for success, false for failure.

top
GetImapUid
getImapUid() -> UInt

When email headers are downloaded from an IMAP server (using Chilkat IMAP), a ckx-imap-uid header field is added. The content of this header is the UID or sequence number of the email on the IMAP server. In addition, a ckx-imap-isUid header field is added, and this will have the value YES or NO. If the value is YES, then ckx-imap-uid contains a UID, if the value is NO, then ckx-imap-uid contains the sequence number. This method returns the UID if ckx-imap-uid exists and contains a UID, otherwise it returns 0xFFFFFFFF.

An application that wishes to download the full email would use this UID and then call the Chilkat IMAP object's FetchSingle or FetchSingleAsMime methods.

Note: If an email was downloaded from the IMAP server in a way such that the UID is not received, then there will be no ckx-imap-uid header field and this method would return 0xFFFFFFFF. For example, if emails are downloaded by sequence numbers via the Imap.FetchSequence method, then UIDs are not used and therefore the email object will not contain this information.

This reads Chilkat metadata stored in the email object; it does not contact the IMAP server. The accompanying Boolean output distinguishes a stable UID from a mailbox sequence number.

top
GetMime
getMime() -> String

Returns the email as MIME text containing the email header, body (or bodies), related items (if any), and all attachments

The result is a complete serialized message suitable for saving as an .eml file or passing to an API that accepts RFC822/MIME text.

Returns nil on failure

top
GetMimeBd
getMimeBd(bindat: CkoBinData) -> Bool
Introduced in version 9.5.0.62

Returns the email as binary MIME containing the email header, body (or bodies), related items (if any), and all attachments. The MIME is appended to the existing contents (if any) of .

Clear first when replacement rather than append behavior is desired.

Returns true for success, false for failure.

top
GetMimeBinary
getMimeBinary() -> NSData

Returns the full MIME of an email.

Use this form when the exact MIME bytes are required or when the programming language represents binary data separately from strings.

Returns nil on failure

top
GetMimeSb
getMimeSb(sb: CkoStringBuilder) -> Bool
Introduced in version 9.5.0.62

Returns the email as MIME text containing the email header, body (or bodies), related items (if any), and all attachments. The MIME is appended to the existing contents (if any) of .

Clear first when replacement rather than append behavior is desired.

Returns true for success, false for failure.

More Information and Examples
top
GetNthBinaryPartOfType
getNthBinaryPart(ofType: Int, contentType: String, inlineOnly: Bool, excludeAttachments: Bool) -> NSData
Introduced in version 9.5.0.44

Returns the binary content of the Nth non-multipart MIME part matching the Content-Type pattern in contentType. ofType is a zero-based index among the matching parts.

contentType may be an exact Content-Type, such as application/pdf, or a wildcard pattern, such as application/* or *. Use GetNumPartsOfType to determine the number of matching parts.

When inlineOnly is true, only parts having an inline Content-Disposition are considered. When excludeAttachments is true, parts having an attachment Content-Disposition are excluded.

Note: A header-only email, or an email downloaded from IMAP without attachments, does not contain every MIME part from the complete message.

Use GetNumPartsOfType with the same filters to determine the valid zero-based index range before retrieving a part.

Returns nil on failure

top
GetNthBinaryPartOfTypeBd
getNthBinaryPart(ofTypeBd: Int, contentType: String, inlineOnly: Bool, excludeAttachments: Bool, bd: CkoBinData) -> Bool
Introduced in version 9.5.0.95

Loads bd with the binary bytes of the Nth MIME sub-part matching contentType, which can be an exact Content-Type such as application/pdf, or a wildcarded Content-Type such as application/*, or */*. Indexing begins at 0. Call GetNumPartsOfType to find out how many MIME sub-parts exist for any given content type. If inlineOnly is true, then only MIME sub-parts having a Content-Disposition of inline are included. If excludeAttachments is true, then MIME sub-parts having a Content-Disposition of attachment are excluded.

Note: If the email was downloaded as header-only, it will not contain all the parts of the full email. Also, if downloaded from IMAP excluding attachments, those parts that are the attachments will (of course) be missing.

Note: Beginning in v9.5.0.95, contentType can be wildcarded. For example, it is possible to specify text/*, or simply * to match any Content-Type.

Note: Only non-multipart MIME parts are matched.

Use GetNumPartsOfType with the same filters to determine the valid zero-based index range before loading bd.

Returns true for success, false for failure.

More Information and Examples
top
GetNthContentType
getNthContentType(index: Int, contentType: String, inlineOnly: Bool, excludeAttachments: Bool) -> String
Introduced in version 9.5.0.95

Returns the Content-Type of the Nth non-multipart MIME part matching the pattern in contentType. is a zero-based index among the matching parts.

contentType may be an exact Content-Type, such as text/plain, or a wildcard pattern, such as text/* or *. When inlineOnly is true, only parts having an inline Content-Disposition are considered. When excludeAttachments is true, parts having an attachment Content-Disposition are excluded.

Use GetNumPartsOfType with the same filters to determine the valid zero-based index range.

Returns nil on failure

More Information and Examples
top
GetNthTextPartOfType
getNthTextPart(ofType: Int, contentType: String, inlineOnly: Bool, excludeAttachments: Bool) -> String
Introduced in version 9.5.0.44

Returns the text content of the Nth non-multipart MIME part matching the Content-Type pattern in contentType. ofType is a zero-based index among the matching parts.

contentType may be an exact Content-Type, such as text/plain, or a wildcard pattern, such as text/* or *. Use GetNumPartsOfType to determine the number of matching parts.

When inlineOnly is true, only parts having an inline Content-Disposition are considered. When excludeAttachments is true, parts having an attachment Content-Disposition are excluded.

Note: A header-only email, or an email downloaded from IMAP without attachments, does not contain every MIME part from the complete message.

Use GetNumPartsOfType with the same filters to determine the valid zero-based index range before retrieving a part.

Returns nil on failure

More Information and Examples
top
GetNumPartsOfType
getNumParts(ofType: String, inlineOnly: Bool, excludeAttachments: Bool) -> Int
Introduced in version 9.5.0.44

Returns the number of non-multipart MIME parts matching the Content-Type pattern in ofType.

ofType may be an exact Content-Type, such as text/plain, or a wildcard pattern, such as text/* or *. When inlineOnly is true, only parts having an inline Content-Disposition are counted. When excludeAttachments is true, parts having an attachment Content-Disposition are excluded.

Note: A header-only email, or an email downloaded from IMAP without attachments, does not contain every MIME part from the complete message.

The count is based on the MIME parts currently loaded in the email object. No attachment or body data is fetched from a server by this method.

More Information and Examples
top
GetPlainTextBody
getPlainTextBody() -> String

Returns the email body having the text/plain content type.

This reads the plain-text representation already present in the email object. It does not convert the HTML body to plain text.

Returns nil on failure

top
GetRelatedAttr
getRelatedAttr(index: Int, fieldName: String, attrName: String) -> String
Introduced in version 9.5.0.41

Returns a header field attribute value from the header field of the Nth related item.

is a zero-based related-item index. fieldName names a MIME header field and attrName names one of that field's parameters.

Returns nil on failure

top
GetRelatedContentID
getRelatedContentID(index: Int) -> String

Returns the content ID of a related item contained with the email. Related items are typically images and style-sheets embedded within HTML emails.

is zero-based; valid values are from 0 through NumRelatedItems - 1. The value is normally referenced from HTML as a cid: URL.

Returns nil on failure

top
GetRelatedContentLocation
getRelatedContentLocation(index: Int) -> String

Returns the Content-Location of a related item contained with the email. Related items are typically images and style-sheets embedded within HTML emails.

is zero-based. Content-Location is an alternative to Content-ID for identifying a resource referenced by the HTML body.

Returns nil on failure

top
GetRelatedContentType
getRelatedContentType(index: Int) -> String

Returns the Content-Type of the Nth related content item in an email message.

is zero-based; valid values are from 0 through NumRelatedItems - 1.

Returns nil on failure

top
GetRelatedData
getRelatedData(index: Int) -> NSData

Returns the content of a related item contained with the email. Related items are typically images and style-sheets embedded within HTML emails.

is zero-based. This legacy byte-array method returns data already loaded into the email object.

Returns nil on failure

top
GetRelatedFilename
getRelatedFilename(index: Int) -> String

Returns the filename of a related item contained with the email. Related items are typically images and style-sheets embedded within HTML emails.

is zero-based. The returned MIME filename should be sanitized before it is used as a local filesystem path.

Returns nil on failure

top
GetRelatedHeader
getRelatedHeader(index: Int, fieldName: String) -> String
Introduced in version 10.0.0

Returns the value of a header field (by name) of a related item.

is a zero-based related-item index. MIME header-field names are case-insensitive.

Returns nil on failure

top
GetRelatedString
getRelatedString(index: Int, charset: String) -> String

Returns the text with CR line-endings of a related item contained with the email. Related items are typically images and style-sheets embedded within HTML emails.

is zero-based and charset specifies the charset used to decode the related-item bytes to Unicode text.

Returns nil on failure

top
GetRelatedStringCrLf
getRelatedStringCrLf(index: Int, charset: String) -> String

Returns the text with CRLF line-endings of a related item contained with the email. Related items are typically images and style-sheets embedded within HTML emails.

is zero-based and charset specifies the charset used to decode the related-item bytes to Unicode text.

Returns nil on failure

top
GetReplacePattern
getReplacePattern(index: Int) -> String

Returns a replacement pattern previously defined for mail-merge operations.

is zero-based; valid values are from 0 through NumReplacePatterns - 1.

Returns nil on failure

More Information and Examples
top
GetReplaceString
getReplaceString(index: Int) -> String

Returns a replacement string for a previously defined pattern/replacement string pair. (This is a mail-merge feature.)

Note: This method was found to not be working correctly and is fixed in Chilkat v9.5.0.91.

is a zero-based pattern index. Use NumReplacePatterns to determine the valid range.

Returns nil on failure

More Information and Examples
top
GetReplaceString2
getReplaceString2(pattern: String) -> String

Returns a replacement string for a previously defined pattern/replacement string pair. (This is a mail-merge feature.)

is the previously registered pattern text, not a numeric index.

Returns nil on failure

More Information and Examples
top
GetReport
getReport(index: Int) -> String

(See the NumReports property.) Returns the body content of the Nth report within a multipart/report email.

Multipart/report is a message type that contains data formatted for a mail server to read. It is split between a text/plain (or some other content/type easily readable) and a message/delivery-status, which contains the data formatted for the mail server to read.

It is defined in RFC 3462

is zero-based; valid values are from 0 through NumReports - 1.

Returns nil on failure

top
GetTo
get(to: Int) -> String

Returns a to recipient's full email address.

to is zero-based; valid values are from 0 through NumTo - 1. The result may include both display name and address.

Returns nil on failure

More Information and Examples
top
GetToAddr
get(toAddr: Int) -> String

Returns the Nth To address (only the address part, not the friendly-name part).

toAddr is zero-based; valid values are from 0 through NumTo - 1.

Returns nil on failure

top
GetToName
get(toName: Int) -> String

Returns the Nth To name (only the friendly-name part, not the address part).

toName is zero-based; valid values are from 0 through NumTo - 1.

Returns nil on failure

top
GetXml
getXml() -> String

Convert the email object to an XML document in memory

The XML is Chilkat's email-object representation, not MIME and not a standardized interchange format. Use GetMime when an RFC822/MIME message is required.

Returns nil on failure

top
HasHeaderMatching
hasHeader(matching: String, valuePattern: String, caseInsensitive: Bool) -> Bool

Returns true when the email contains a header field named matching whose value matches the wildcard pattern in valuePattern.

valuePattern may contain any number of * characters, where each asterisk matches zero or more characters. caseSensitive controls whether matching is case-sensitive.

The pattern syntax is a simple wildcard match, not a regular expression. Header-field names are compared without regard to case.

top
HasHtmlBody
hasHtmlBody() -> Bool

Returns true if the email has an HTML body.

Returns true only when a text/html body is present in the current email object.

top
HasPlainTextBody
hasPlainTextBody() -> Bool

Returns true if the email has a plain-text body.

Returns true only when a text/plain body is present in the current email object.

top
IsMultipartReport
isMultipartReport() -> Bool

Returns true if the email is a multipart/report email.

Returns true when the top-level message structure is a multipart/report. Use GetDsnInfo or GetReport to examine report content.

top
LastDecryptCert
lastDecryptCert(cert: CkoCert) -> Bool
Introduced in version 11.0.0

Returns in the certificate used to decrypt this email.

Call this after a successful decryption to inspect the certificate associated with the private key that decrypted the message.

Returns true for success, false for failure.

top
LastSignerCert
lastSignerCert(index: Int, cert: CkoCert) -> Bool
Introduced in version 11.0.0

Copies the certificate for the signer at the zero-based index specified by into cert.

Most signed emails have one signer, but an email may contain multiple signatures.

Call this after parsing or verifying a signed message. cert receives a copy of the signer certificate and can be examined independently.

Returns true for success, false for failure.

top
LinkedDomains
linkedDomains(domains: CkoStringTable) -> Bool
Introduced in version 11.0.0

Extracts domain names from hyperlinks in an HTML email. Lowercase domains are appended to without creating duplicates.

This method parses links only; it does not perform DNS lookups or make network requests to the extracted domains.

Returns true for success, false for failure.

top
LoadEml
loadEml(mimePath: String) -> Bool

Loads a complete email from a.EML file. (EML files are simply RFC822 MIME text files.)

Note: This replaces the entire contents of the email object, including the To/CC recipients.

The file is parsed locally; this method does not connect to an SMTP, POP3, or IMAP server.

Returns true for success, false for failure.

top
LoadTaskResult
loadTaskResult(task: CkoTask) -> Bool
Introduced in version 9.5.0.52

Loads the email object from a completed asynchronous task.

must be a completed task produced by a compatible asynchronous email operation. Loading the result replaces the current email content.

Returns true for success, false for failure.

More Information and Examples
top
LoadXml
loadXml(xmlPath: String) -> Bool

Loads an email with the contents of an XML email file.

Note: This replaces the entire contents of the email object, including the To/CC recipients.

The file must contain XML previously produced by Chilkat email serialization. It is not an arbitrary XML-to-email conversion method.

Returns true for success, false for failure.

top
LoadXmlString
loadXmlString(xmlStr: String) -> Bool

Loads an email from an XML string (previously obtained by calling the GetXml method). The contents of the calling email object are erased and replaced with the email contained within the XML string.

This is a local parsing operation and does not connect to a mail server. Existing email content is replaced by the loaded message.

Returns true for success, false for failure.

top
MakeCopy
makeCopy(destEmail: CkoEmail) -> Bool
Introduced in version 11.0.0

Copies this email into .

becomes an independent copy. Subsequent changes to either email object do not affect the other.

Returns true for success, false for failure.

top
QEncodeBytes
qEncodeBytes(inData: NSData, charset: String) -> String

Takes a byte array of multibyte (non-Unicode) data and returns a Unicode Q-Encoded string.

Q-encoding is commonly used in RFC 2047 encoded words for non-ASCII MIME header text. charset identifies the charset represented by the input bytes.

Returns nil on failure

top
QEncodeString
qEncodeString(str: String, charset: String) -> String

Takes a Unicode string, converts it to the charset specified in the second parameter, Q-Encodes the converted multibyte data, and returns the encoded Unicode string.

Q-encoding is commonly used in RFC 2047 encoded words for non-ASCII MIME header text. charset controls the byte charset used before Q-encoding.

Returns nil on failure

top
RemoveAttachedMessage
removeAttachedMessage(index: Int)

Removes the Nth message/rfc822 sub-part of the email. Indexing begins at 0.

is zero-based; valid values are from 0 through NumAttachedMessages - 1. This changes only the in-memory email.

top
RemoveAttachedMessages
removeAttachedMessages()

Removes all message/rfc822 sub-parts of the email object.

This does not remove ordinary file attachments or related HTML resources.

top
RemoveAttachmentPaths
removeAttachmentPaths()

Removes path information from all attachment filenames.

This is useful before sending when attachment MIME filenames should not reveal local directory information. It does not move or rename files on disk.

top
RemoveHeaderField
removeHeaderField(fieldName: String)

Removes by name all occurrences of a header field.

Header-field names are case-insensitive. All repeated occurrences having the specified name are removed from the current email object.

top
RemoveHtmlAlternative
removeHtmlAlternative()

Removes the HTML body from the email (if an HTML body exists).

Other body representations, attachments, and related items remain unchanged.

top
RemovePlainTextAlternative
removePlainTextAlternative()

Removes the plain-text body from the email (if a plain-text body exists).

Other body representations, attachments, and related items remain unchanged.

top
SaveAllAttachments
saveAllAttachments(directory: String) -> Bool

Save all the attachments of an email to files in a directory specified by . The OverwriteExisting property controls whether existing files are allowed to be overwritten.

Note: Email attachment filenames can be renamed or modified prior to saving. The number of attachments is available in the NumAttachments property. An application can loop over the attachments to get the filename for each by calling GetAttachmentFilename(index). Each attachment's filename can be set by calling SetAttachmentFilename(index, newFilename).

Only attachments already present in the email object are saved. A message downloaded without attachment bodies must first have those bodies fetched by the mail protocol component.

Returns true for success, false for failure.

top
SaveAttachedFile
saveAttachedFile(index: Int, directory: String) -> Bool

Saves the Nth email attachment to the directory specified by dirPath. The first attachment is at index 0. The OverwriteExisting property controls whether existing files are allowed to be overwritten.

This serializes data already present in the current Email object; it does not send the message or retrieve missing data from a server.

Returns true for success, false for failure.

top
SaveEml
saveEml(path: String) -> Bool

Convert this email object to EML and save it to a file.

An EML file contains the complete RFC822/MIME message, including headers, bodies, related items, and attachments.

Returns true for success, false for failure.

top
SaveRelatedItem
saveRelatedItem(index: Int, directory: String) -> Bool

Saves the Nth related item to the directory specified by dirPath. (The first related item is at index 0) Related content items are typically image or style-sheets embedded within an HTML email. The OverwriteExisting property controls whether existing files are allowed to be overwritten.

is zero-based; valid values are from 0 through NumRelatedItems - 1. The related item is written from data already present in the email object.

Returns true for success, false for failure.

top
SaveXml
saveXml(path: String) -> Bool

Convert this email object to XML and save it to a file.

The generated XML is Chilkat's email-object serialization and can later be loaded with LoadXml. Use SaveEml for a standard MIME message file.

Returns true for success, false for failure.

top
SetAttachmentCharset
setAttachmentCharset(index: Int, charset: String) -> Bool

Sets the charset attribute of the Content-Type header field for a specified attachment. This can be used if the attachment is a text file that contains text in a non-ASCII charset such as Shift_JIS, iso-8859-2, big5, iso-8859-5, etc.

is zero-based. This updates MIME metadata and does not transcode the attachment bytes; use it only when the bytes are already encoded in the stated charset.

Returns true for success, false for failure.

top
SetAttachmentDisposition
setAttachmentDisposition(index: Int, disposition: String) -> Bool

Sets the Content-Disposition value for the attachment at the zero-based index specified by .

The default disposition is attachment. Set disposition to inline when the attachment should be presented as inline content.

is zero-based. inline suggests that a mail client may display the part in the message, while attachment suggests a separate downloadable file.

Returns true for success, false for failure.

top
SetAttachmentFilename
setAttachmentFilename(index: Int, filename: String) -> Bool

Changes the filename of the attachment at the zero-based index specified by . filename contains the new filename.

is zero-based. This changes the filename stored in MIME and does not rename any original local file.

Returns true for success, false for failure.

More Information and Examples
top
SetBinaryBody
setBinaryBody(byteData: NSData, contentType: String, disposition: String, filename: String) -> Bool
Introduced in version 9.5.0.44

Sets the main body of the email to binary content of any type. The disposition can be an empty string, inline, or attachment. If a filename is specified, the disposition must be non-empty because the filename is an attribute of the Content-Disposition header field.

This replaces the main body with the supplied binary content. Use an attachment method instead when the data should coexist with a separate message body.

Returns true for success, false for failure.

top
SetBodyBd
setBodyBd(bd: CkoBinData, contentType: String, disposition: String, filename: String) -> Bool
Introduced in version 11.0.0

Sets the main email body from the binary data in .

contentType specifies the MIME Content-Type. disposition specifies the disposition and may be empty, inline, or attachment. filename optionally specifies a filename. When filename is provided, disposition must also be specified because the filename is an attribute of the Content-Disposition header.

This replaces the main body using bytes already stored in . It does not add a separate attachment unless disposition and filename intentionally describe the body as one.

Returns true for success, false for failure.

top
SetDecryptCert
setDecryptCert(cert: CkoCert) -> Bool
Introduced in version 9.5.0.57

Allows for a certificate to be explicitly provided for decryption. When an email object is loaded via any method, such as LoadEml, SetFromMimeText, SetFromMimeBytes, etc., security layers (signatures and encryption) are automatically unwrapped. This method could be called prior to calling a method that loads the email.

Configure the certificate before loading or unwrapping the encrypted MIME so the private key is available at decryption time.

Returns true for success, false for failure.

top
SetDecryptCert2
setDecryptCert2(cert: CkoCert, key: CkoPrivateKey) -> Bool
Introduced in version 9.5.0.57

Allows for a certificate and private key to be explicitly specified for decryption. When an email object is loaded via any method, such as LoadEml, SetFromMimeText, SetFromMimeBytes, etc., security layers such as signatures and encryption are automatically unwrapped. Decryption requires a private key.

On Windows, Chilkat automatically searches the system certificate stores for the required certificate and private key. On macOS, Chilkat automatically searches the Keychain. If the required certificate and private key are not installed in one of these locations, they can be provided by this method or by calling AddPfxSourceFile or AddPfxSourceData.

Configure the certificate and key before loading or unwrapping the encrypted MIME. This overload is useful when the private key is not discoverable through a platform certificate store or Keychain.

Returns true for success, false for failure.

More Information and Examples
top
SetDt
setDt(dt: CkoDateTime) -> Bool

Sets the Date header field of the email to have the value of the date/time object provided.

The date/time is formatted as an RFC822 Date header when the message is serialized.

Returns true for success, false for failure.

top
SetEdifactBody
setEdifactBody(message: String, name: String, filename: String, charset: String)
Introduced in version 9.5.0.28

Creates a typical email used to send EDIFACT messages. Does the following:

  1. Sets the email body to the EDIFACT message passed in .
  2. Sets the Content-Transfer-Encoding to Base64.
  3. Set the Content-Type equal to application/EDIFACT.
  4. Sets the Content-Type header's name attribute to name.
  5. Sets the Content-Disposition equal to attachment.
  6. Sets the Content-Disposition's filename attribute equal to filename.
  7. The EDIFACT message is converted to the charset indicated by charset, and encoded using Base64 in the email body.

The email's subject, recipients, FROM address, and other headers are left unmodified.

This is a convenience method that constructs the customary MIME headers and body for EDIFACT transport. It replaces the existing main body configuration.

top
SetEncryptCert
setEncryptCert(cert: CkoCert) -> Bool

Set the encryption certificate to be used in encryption. Use the CreateCS, CertStore, and Cert classes to create a Cert object by either locating a certificate in a certificate store or loading one from a file.

This sets one explicit recipient encryption certificate. Use AddEncryptCert when the message must be decryptable by multiple recipients.

Returns true for success, false for failure.

top
SetFromMimeBd
set(fromMimeBd: CkoBinData) -> Bool
Introduced in version 9.5.0.62

Loads an email with the MIME stored in a BinData object.

Note: This replaces the entire contents of the email object, including the To/CC recipients.

The MIME is parsed locally and the BinData itself is not modified.

Returns true for success, false for failure.

top
SetFromMimeBytes
set(fromMimeBytes: NSData) -> Bool

Loads fromMimeBytes into the email object. If the email object already contained an email, it is entirely replaced. The character encoding (such as utf-8, iso-8859-1, etc.) of the bytes is automatically inferred from the content. If for some reason it is not possible to determine the character encoding, the SetFromMimeBytes2 method may be called to explicitly specify the charset.

Use this method when MIME text is supplied as bytes in a known character encoding. Parsing is local and replaces the current email content.

Returns true for success, false for failure.

top
SetFromMimeBytes2
set(fromMimeBytes2: NSData, charset: String) -> Bool

Replaces the current email with the MIME bytes in fromMimeBytes2.

charset specifies the character encoding of the MIME bytes, such as utf-8 or iso-8859-1.

Use this method only when the byte array contains MIME text in a known character encoding. For arbitrary MIME bytes that may contain binary sections, prefer a binary MIME-loading method.

Returns true for success, false for failure.

top
SetFromMimeSb
set(fromMimeSb: CkoStringBuilder) -> Bool
Introduced in version 9.5.0.62

Loads an email with the MIME stored in a StringBuilder object.

Note: This replaces the entire contents of the email object, including the To/CC recipients.

The MIME is parsed locally and the StringBuilder itself is not modified.

Returns true for success, false for failure.

top
SetFromMimeText
set(fromMimeText: String) -> Bool

Loads an email with the contents of a.eml (i.e. MIME) contained in a string.

Note: This replaces the entire contents of the email object, including the To/CC recipients.

This parses MIME already present in memory and does not contact a mail server.

Returns true for success, false for failure.

top
SetFromXmlText
set(fromXmlText: String) -> Bool

Loads an email from an XML string.

Note: This replaces the entire contents of the email object, including the To/CC recipients.

The XML must be in Chilkat's email serialization format, typically obtained from GetXml.

Returns true for success, false for failure.

top
SetHtmlBody
setHtmlBody(html: String)

Sets the HTML body of an email.

This creates or replaces the text/html body. It does not automatically create a plain-text alternative.

More Information and Examples
top
SetMbHtmlBody
setMbHtmlBody(charset: String, in: NSData) -> Bool

Sets the HTML email body from a byte array containing character data in the specified character set. This method also updates the email Content-Type header to properly reflect the content type of the body.

Use this method when HTML is already available as encoded bytes. For a Unicode string, SetHtmlBody is simpler.

Returns true for success, false for failure.

top
SetMbPlainTextBody
setMbPlainTextBody(charset: String, in: NSData) -> Bool

Sets the plain-text email body from a byte array containing character data in the specified character set. This method also updates the email Content-Type header to properly reflect the content type of the body.

Use this method when plain text is already available as encoded bytes. For a Unicode string, use SetTextBody or the plain-text body property/methods.

Returns true for success, false for failure.

top
SetRelatedFilename
setRelatedFilename(index: Int, filename: String) -> Bool

Sets the filename for a related item within the email.

is zero-based. This changes the filename stored in the related MIME part and does not rename a local source file.

Returns true for success, false for failure.

top
SetReplacePattern
setReplacePattern(pattern: String, replace: String) -> Bool

Create a pattern/replacement-text pair for mail-merge. When the email is sent via the MailMan's SendEmail method, or any other mail-sending method, the patterns are replaced with the replacement strings during the sending process. To define multiple replacement patterns, simply call SetReplacePattern once per pattern/replacement string. (Note: The MailMan's RenderToMime method will also do pattern replacements. Methods such as SaveEml or GetMime do not replace patterns.)

Note: Replacement patterns may be placed in any header field, and in both HTML and plain-text email bodies.

Defining a pattern does not immediately alter the stored body or headers. Replacement occurs later during supported sending operations.

Returns true for success, false for failure.

More Information and Examples
top
SetSigningCert
setSigningCert(cert: CkoCert) -> Bool

Set the certificate to be used in creating a digital signature. Use the CreateCS, CertStore, and Cert classes to create a Cert object by either locating a certificate in a certificate store or loading one from a file.

The certificate must have access to its private key when signing occurs. Use SetSigningCert2 when the key is supplied separately.

Returns true for success, false for failure.

More Information and Examples
top
SetSigningCert2
setSigningCert2(cert: CkoCert, key: CkoPrivateKey) -> Bool

Explicitly sets the certificate and private key to be used for sending digitally signed email.

If the certificate is already installed with its private key, it is usually sufficient to call SetSigningCert. On Windows, Chilkat automatically searches the system certificate stores and Windows Protected Store for the corresponding certificate and private key. On macOS, Chilkat automatically searches the Keychain.

In many cases, it is not necessary to set the signing certificate explicitly. Chilkat can automatically locate a certificate whose email address matches the email's From address, provided the certificate and private key are installed in a searchable certificate store or Keychain.

This method is useful when the signing key is held outside the certificate object or is provided by a separate key source. The certificate and key must correspond to one another.

Returns true for success, false for failure.

top
SetTextBody
setTextBody(bodyText: String, contentType: String)

Sets the body of the email and also sets the Content-Type header field of contentType. If the email is already multipart/alternative, an additional alternative with the indicated Content-Type will be added. If an alternative with the same Content-Type already exists, it is replaced.

Use a textual MIME type such as text/plain or text/html. When building a plain-text/HTML pair, the dedicated alternative-body methods make the intended multipart/alternative structure clearer.

More Information and Examples
top
ToDsn
toDsn(explanation: String, statusFields: String, headerOnly: Bool, dsnEmail: CkoEmail) -> Bool
Introduced in version 11.0.0

Creates a new Delivery Status Notification (DSN) email in the format specified by RFC 3464. The DSN email is generated in dsnEmail.

The source email is not modified. Populate any additional sender or recipient fields on dsnEmail before sending the generated notification.

Returns true for success, false for failure.

top
ToForward
toForward(forward: CkoEmail) -> Bool
Introduced in version 11.0.0

Creates an inline-forward email in based on this email.

The source email is not modified. can be edited to add recipients, introductory text, or other forwarding details before sending.

Returns true for success, false for failure.

top
ToMdn
toMdn(message: String, statusFields: String, headerOnly: Bool, mdn: CkoEmail) -> Bool
Introduced in version 11.0.0

Creates a new MDN (Message Disposition Notification) email in having the format as specified in RFC 3798.

The source email is not modified. Populate any additional sender or recipient fields on mdn before sending the generated notification.

Returns true for success, false for failure.

top
ToReply
toReply(reply: CkoEmail) -> Bool
Introduced in version 11.0.0

Generates a reply email in with updated header and body fields to enable sending as a reply. Note: Attachments are excluded from the reply, but attached messages are included. To exclude attached messages, call RemoveAttachedMessages on the reply email object.

The source email is not modified. can be edited to add introductory text, adjust recipients, or change reply behavior before sending.

Returns true for success, false for failure.

top
UidlEquals
uidlEquals(e: CkoEmail) -> Bool

Returns true if the caller email has a UIDL that equals the email passed in the argument.

This comparison is meaningful for messages obtained through POP3. It does not compare IMAP UIDs, MIME Message-IDs, or message content.

top
UnpackHtml
unpackHtml(unpackDir: String, htmlFilename: String, partsSubdir: String) -> Bool

Unpacks an HTML email into an HTML file and separate related files, such as images and style sheets. Links in the HTML are rewritten to reference the extracted files.

specifies the destination directory for the HTML file, htmlFilename specifies the HTML filename, and partsSubdir specifies the subdirectory beneath where related files are written. Chilkat creates the related-files subdirectory when necessary.

Example: If is C:/test, htmlFilename is myEmail.html, and partsSubdir is images, Chilkat writes C:/test/myEmail.html and stores related files in C:/test/images.

Note: Only related content physically contained in the email can be extracted. Images referenced by external web URLs are not downloaded.

The extracted filenames originate from message content and should be treated as untrusted when processing email from unknown senders. The method operates on data already present in the email object.

Returns true for success, false for failure.

More Information and Examples
top
UnSpamify
unSpamify()

Unobfuscates emails by undoing what spammers do to obfuscate email. It removes comments from HTML bodies and unobfuscates hyperlinked URLs.

This modifies the current email content. Make a copy first when the original HTML must be preserved for forensic or auditing purposes.

top
UnzipAttachments
unzipAttachments() -> Bool

Unzips and replaces any Zip file attachments with the expanded contents. As an example, if an email contained a single Zip file containing 3 GIF image files as an attachment, then after calling this method the email would contain 3 GIF file attachments, and the Zip attachment would be gone.If an email contains multiple Zip file attachments, each Zip is expanded and replaced with the contents.

This changes the attachment collection in memory; it does not extract files directly to a filesystem directory. Save the resulting attachments separately when files are required on disk.

Returns true for success, false for failure.

top
UseCertVault
useCertVault(vault: CkoXmlCertVault) -> Bool
Introduced in version 9.5.0.40

Adds an XML certificate vault to the object's internal list of sources to be searched for certificates and private keys when encrypting/decrypting or signing/verifying. Unlike the AddPfxSourceData and AddPfxSourceFile methods, only a single XML certificate vault can be used. If UseCertVault is called multiple times, only the last certificate vault will be used, as each call to UseCertVault will replace the certificate vault provided in previous calls.

The vault becomes an additional lookup source for subsequent operations by this object. Adding it does not immediately sign, verify, encrypt, or decrypt anything.

Returns true for success, false for failure.

top
ZipAttachments
zipAttachments(zipFilename: String) -> Bool

Replaces all the attachments of an email with a single Zip file attachment having the filename specified.

The original attachments are removed from the in-memory email and their contents are placed into the new Zip attachment. Related items and attached emails are separate.

Returns true for success, false for failure.

top

Deprecated

BounceAddress
bounceAddress: String!
This property is deprecated. It will be removed in a future version.

This property is deprecated and applications should use the MailMan.SmtpMailFrom property instead.

The SMTP envelope sender is separate from the visible From header. Use MailMan.SmtpMailFrom when delivery failures or bounces should be directed to a different address.

top
Clone
clone() -> CkoEmail
This method is deprecated and replaced by MakeCopy

This method is deprecated. Applications should instead call MakeCopy.

Creates and returns an identical copy of the Email object.

The returned object is independent of the original, so either copy may be modified without changing the other.

Returns nil on failure

More Information and Examples
top
CreateDsn
createDsn(explanation: String, xmlDeliveryStatus: String, bHeaderOnly: Bool) -> CkoEmail
This method is deprecated and replaced by ToDsn

This method is deprecated. Applications should instead call ToDsn.

Creates a new DSN (Delivery Status Notification) email having the format as specified in RFC 3464. See the example (below) for more detailed information.

The returned notification is a new, independent Email object. The source email is not modified.

Returns nil on failure

top
CreateForward
createForward() -> CkoEmail
This method is deprecated and replaced by ToForward

This method is deprecated. Applications should instead call ToForward.

Returns a copy of the Email object with the body and header fields changed so that the newly created email can be forwarded. After calling CreateForward, simply add new recipients to the created email, and call MailMan.SendEmail.

The returned forward is a new, independent Email object and may be edited before it is sent.

Returns nil on failure

top
CreateMdn
createMdn(explanation: String, xmlMdnFields: String, bHeaderOnly: Bool) -> CkoEmail
This method is deprecated and replaced by ToMdn

This method is deprecated. Applications should instead call ToMdn.

Creates a new MDN (Message Disposition Notification) email having the format as specified in RFC 3798. See the example (below) for more detailed information.

The returned notification is a new, independent Email object. The source email is not modified.

Returns nil on failure

top
CreateReply
createReply() -> CkoEmail
This method is deprecated and replaced by ToReply

This method is deprecated. Applications should instead call ToReply.

Returns a copy of the Email object with the body and header fields changed so that the newly created email can be sent as a reply. After calling CreateReply, simply prepend additional information to the body, and call MailMan.SendEmail.

Note: Attachments are not included in the returned reply email. However, attached messages are included. If an application does not wish to include the attached messages in a reply email, they can be removed by calling RemoveAttachedMessages on the reply email object.

The returned reply is a new, independent Email object. Add or adjust recipients and body text before sending it.

Returns nil on failure

top
FindIssuer
findIssuer(cert: CkoCert) -> CkoCert
This method is deprecated.

This method is deprecated. Applications can instead call the certificate object's GetIssuer method.

Digitally signed and/or encrypted emails are automatically unwrapped when received from a POP3 or IMAP server, or when loaded from any source such as a MIME string, in-memory byte data, or a.eml file. The results of the signature verification / decryption are stored in the properties such as ReceivedSigned, ReceivedEncrypted, SignaturesValid, etc. The signing certificate can be obtained via the GetSigningCert function. If the signature contained more certificates in the chain of authentication, this method provides a means to access them.

During signature verification, the email object collects the certs found in the signature and holds onto them internally. To get the issuing certificate of the signing certificate, call this method passing the cert returned by GetSigningCert. If the issuing cert is available, it is returned. Otherwise nil is returned. If the cert passed in is the root (i.e. a self-signed certificate), then the cert object returned is a copy of the cert passed in.

To traverse the chain to the root, one would write a loop that on first iteration passes the cert returned by GetSignedByCert (not GetSignerCert), and then on each subsequent iteration passes the cert from the previous iteration. The loop would exit when a cert is returned that has the same SubjectDN and SerialNumber as what was passed in (or when FindIssuer returns nil).

Issuer lookup is a certificate-chain operation and is separate from verifying whether the signer certificate should be trusted for a particular application.

Returns nil on failure

top
GetAttachedMessage
getAttachedMessage(index: Int) -> CkoEmail
This method is deprecated and replaced by GetAttachedEmail

This method is deprecated. Applications should instead call GetAttachedEmail.

Returns an embedded message/rfc822 subpart as an email object. (Emails are embedded as message/rfc822 subparts by some mail clients when forwarding an email.) This method allows the original email to be accessed.

is zero-based; valid values are from 0 through NumAttachedMessages - 1. The returned object is a copy of the embedded message.

Returns nil on failure

top
GetDigest
getDigest(index: Int) -> CkoEmail
Introduced in version 9.5.0.66
This method is deprecated and replaced by GetDigestEmail

This method is deprecated. Applications should instead call GetDigestEmail.

Returns a digest contained within a multipart/digest as an email object. The first digest is at index 0. Use the NumDigests property to get the number of digests available.

is zero-based; valid values are from 0 through NumDigests - 1.

Returns nil on failure

top
GetDsnFinalRecipients
getDsnFinalRecipients() -> CkoStringArray
This method is deprecated and replaced by GetDsnInfo

This method is deprecated. Applications should instead call GetDsnInfo.

If the email is a multipart/report, then it is a delivery status notification. This method can be used to get Final-Recipient values from the message/delivery-status part of the email. This method should only be called if the IsMultipartReport method returns true.

This reads recipient status information already contained in the DSN. It does not query the destination mail system for current delivery state.

Returns nil on failure

top
GetDt
getDt() -> CkoDateTime
This method is deprecated.

This method is deprecated. Applications should instead use the EmailDateStr property.

Returns the date/time found in the Date header field as a date/time object.

The returned value represents the parsed MIME Date header. It is not the file creation time or the time the message was downloaded.

Returns nil on failure

top
GetEncryptCert
getEncryptCert() -> CkoCert
This method is deprecated.

Returns the certificate that was previously set by SetEncryptCert.

This returns only a certificate explicitly assigned to the email object. It does not perform a new certificate-store search.

Returns nil on failure

top
GetEncryptedByCert
getEncryptedByCert() -> CkoCert
This method is deprecated and replaced by LastDecryptCert

This method is deprecated. Applications should instead call LastDecryptCert to get the certificate used to decrypt this email.

Returns the certificate associated with a received encrypted email.

Call this after an encrypted message has been parsed and decrypted. The returned certificate identifies the decryption recipient information found in the message.

Returns nil on failure

top
GetLinkedDomains
getLinkedDomains() -> CkoStringArray
This method is deprecated and replaced by LinkedDomains

This method is deprecated. Applications should instead call LinkedDomains.

Parses an HTML email and returns the set of domain names that occur in hyperlinks within the HTML body.

This method parses hyperlinks only. It does not perform DNS lookups or connect to any of the returned domains.

Returns nil on failure

top
GetSignedByCert
getSignedByCert() -> CkoCert
This method is deprecated and replaced by LastSignerCert

This method is deprecated. Applications should instead call LastSignerCert to get the certificate used to sign this email.

Return the certificate used to digitally sign this email.

The returned certificate describes the signer of the most recently parsed or verified signed message; it is not the certificate configured for a future signing operation.

Returns nil on failure

top
GetSignedByCertChain
getSignedByCertChain() -> CkoCertChain
Introduced in version 9.5.0.40
This method is deprecated.

This method is deprecated. Applications can get the cert chain by calling LastSignerCert to get the certificate object, and then get the certificate chain from the certificate object.

Return the full certificate chain of the certificate used to digitally sign this email.

The chain describes the signer of a received signed email. It is different from the certificate chain that might be configured for a future signing operation.

Returns nil on failure

top
GetSigningCert
getSigningCert() -> CkoCert
This method is deprecated.

Return the certificate that will be used to digitally sign this email. This is the cerficate that was previously set by calling the SetSigningCert method.

This returns the certificate configured for a future signing operation. It does not return the signer of an already received message.

Returns nil on failure

top