Email Pascal Reference Documentation

Email

Current Version: 11.5.0

Create / Free

uses
  Chilkat.Email;

var
  obj: TEmail;
begin
  obj := TEmail.Create;
  try
    if not obj.IsValid then
      raise Exception.Create('Failed to create a TEmail instance.');

    // ... use obj ...

  finally
    obj.Free;
  end;
end;
constructor Create;

Allocates the underlying CkEmail object and returns a new TEmail instance. Simply adding Chilkat.Email to the unit's uses clause is enough to locate and bind to the Chilkat shared library (DLL / .so / .dylib) at runtime — no separate load step is required. Check obj.IsValid after calling Create; it is False if the underlying library could not be found/loaded or the object could not be allocated (for example, when unlicensed).

destructor Destroy; override;

Every TEmail created by calling Create should eventually be released by calling .Free (inherited from TObject). The destructor automatically disposes the underlying CkEmail handle. A native (unmanaged) memory leak occurs if the object is never freed.

Properties

Body
property Body: string read GetBody write SetBody;

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.

More Information and Examples
top
Charset
property Charset: string read GetCharset write SetCharset;

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.

More Information and Examples
top
DebugLogFilePath
property DebugLogFilePath: string read GetDebugLogFilePath write SetDebugLogFilePath;

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
property Decrypted: Boolean read GetDecrypted;

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.

top
EmailDateStr
property EmailDateStr: string read GetEmailDateStr write SetEmailDateStr;

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.

top
EncryptedBy
property EncryptedBy: string read GetEncryptedBy;

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

top
FileDistList
property FileDistList: string read GetFileDistList write SetFileDistList;

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).

top
From
property From: string read GetFrom write SetFrom;

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.

top
FromAddress
property FromAddress: string read GetFromAddress write SetFromAddress;

The email address of the sender.

top
FromName
property FromName: string read GetFromName write SetFromName;

The name of the sender.

top
Header
property Header: string read GetHeader;

The complete MIME header of the email.

top
Language
property Language: string read GetLanguage;

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.

top
LastErrorHtml
property LastErrorHtml: string read GetLastErrorHtml;

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
property LastErrorText: string read GetLastErrorText;

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
property LastErrorXml: string read GetLastErrorXml;

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
property LastMethodSuccess: Boolean read GetLastMethodSuccess write SetLastMethodSuccess;

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
property LocalDateStr: string read GetLocalDateStr write SetLocalDateStr;

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.

top
Mailer
property Mailer: string read GetMailer write SetMailer;

Identifies the email software that sent the email.

top
NumAlternatives
property NumAlternatives: Integer read GetNumAlternatives;

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.

top
NumAttachedMessages
property NumAttachedMessages: Integer read GetNumAttachedMessages;

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.

top
NumAttachments
property NumAttachments: Integer read GetNumAttachments;

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.

top
NumBcc
property NumBcc: Integer read GetNumBcc;

The number of blind carbon-copy email recipients.

top
NumCC
property NumCC: Integer read GetNumCC;

The number of carbon-copy email recipients.

More Information and Examples
top
NumDaysOld
property NumDaysOld: Integer read GetNumDaysOld;

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.)

top
NumDigests
property NumDigests: Integer read GetNumDigests;
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.

More Information and Examples
top
NumHeaderFields
property NumHeaderFields: Integer read GetNumHeaderFields;

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.)

top
NumRelatedItems
property NumRelatedItems: Integer read GetNumRelatedItems;

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.

top
NumReplacePatterns
property NumReplacePatterns: Integer read GetNumReplacePatterns;

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.

More Information and Examples
top
NumReports
property NumReports: Integer read GetNumReports;

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.

top
NumTo
property NumTo: Integer read GetNumTo;

The number of direct email recipients.

More Information and Examples
top
OaepHash
property OaepHash: string read GetOaepHash write SetOaepHash;
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,

top
OaepMgfHash
property OaepMgfHash: string read GetOaepMgfHash write SetOaepMgfHash;
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,

top
OaepPadding
property OaepPadding: Boolean read GetOaepPadding write SetOaepPadding;
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.

top
OverwriteExisting
property OverwriteExisting: Boolean read GetOverwriteExisting write SetOverwriteExisting;

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.

top
Pkcs7CryptAlg
property Pkcs7CryptAlg: string read GetPkcs7CryptAlg write SetPkcs7CryptAlg;

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

top
Pkcs7KeyLength
property Pkcs7KeyLength: Integer read GetPkcs7KeyLength write SetPkcs7KeyLength;

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.

top
PreferredCharset
property PreferredCharset: string read GetPreferredCharset write SetPreferredCharset;

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.

More Information and Examples
top
PrependHeaders
property PrependHeaders: Boolean read GetPrependHeaders write SetPrependHeaders;

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.

top
ReceivedEncrypted
property ReceivedEncrypted: Boolean read GetReceivedEncrypted;

True if this email was originally received with encryption, otherwise False.

top
ReceivedSigned
property ReceivedSigned: Boolean read GetReceivedSigned;

True if this email was originally received with a digital signature, otherwise False.

More Information and Examples
top
ReplyTo
property ReplyTo: string read GetReplyTo write SetReplyTo;

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.

top
ReturnReceipt
property ReturnReceipt: Boolean read GetReturnReceipt write SetReturnReceipt;

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.

top
SendEncrypted
property SendEncrypted: Boolean read GetSendEncrypted write SetSendEncrypted;

Set to True if this email should be sent encrypted.

top
SendSigned
property SendSigned: Boolean read GetSendSigned write SetSendSigned;

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.

top
SignaturesValid
property SignaturesValid: Boolean read GetSignaturesValid;

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.)

More Information and Examples
top
SignedBy
property SignedBy: string read GetSignedBy;

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.

top
SigningAlg
property SigningAlg: string read GetSigningAlg write SetSigningAlg;
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.

top
SigningHashAlg
property SigningHashAlg: string read GetSigningHashAlg write SetSigningHashAlg;

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

top
Size
property Size: Integer read GetSize;

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.

top
Subject
property Subject: string read GetSubject write SetSubject;

The email subject.

top
Uidl
property Uidl: string read GetUidl;

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.

top
UncommonOptions
property UncommonOptions: string read GetUncommonOptions write SetUncommonOptions;
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.

top
UnpackUseRelPaths
property UnpackUseRelPaths: Boolean read GetUnpackUseRelPaths write SetUnpackUseRelPaths;

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.

top
VerboseLogging
property VerboseLogging: Boolean read GetVerboseLogging write SetVerboseLogging;

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
property Version: string read GetVersion;

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

More Information and Examples
top

Methods

AddAttachmentBd
// binData is a TBinData object.
function AddAttachmentBd(const filename: string;
    binData: TChilkatBase;
    const contentType: string): Boolean;
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 filename extension.

Returns True for success, False for failure.

More Information and Examples
top
AddAttachmentHeader
procedure AddAttachmentHeader(index: Integer;
    const fieldName: string;
    const 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.

More Information and Examples
top
AddBcc
function AddBcc(const friendlyName: string;
    const emailAddress: string): Boolean;

Adds a recipient to the blind carbon-copy (BCC) list. emailAddress is required; friendlyName 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.

Returns True for success, False for failure.

top
AddCC
function AddCC(const friendlyName: string;
    const emailAddress: string): Boolean;

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

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

Returns True for success, False for failure.

More Information and Examples
top
AddEncryptCert
// cert is a TCert object.
function AddEncryptCert(cert: TChilkatBase): Boolean;

<p>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 <code><a href="#ClearEncryptCerts">ClearEncryptCerts</a></code> method may be called to clear the list of explicitly-specified certificates.</p> <p><strong>Note:</strong> 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.</p> <p><strong>Note:</strong> The <code><a href="#SetEncryptCert">SetEncryptCert</a></code> method is equivalent to calling <code><a href="#ClearEncryptCerts">ClearEncryptCerts</a></code> followed by AddEncryptCert.</p>

Returns True for success, False for failure.

top
AddFileAttachment
function AddFileAttachment(const 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.

Returns True for success, False for failure.

top
AddFileAttachment2
function AddFileAttachment2(const path: string;
    const contentType: string): Boolean;

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

Returns True for success, False for failure.

More Information and Examples
top
AddHeaderField
procedure AddHeaderField(const fieldName: string;
    const 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).

top
AddHeaderField2
procedure AddHeaderField2(const fieldName: string;
    const 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.

top
AddHtmlAlternativeBody
function AddHtmlAlternativeBody(const body: string): Boolean;

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.

Returns True for success, False for failure.

More Information and Examples
top
AddiCalendarAlternativeBody
function AddiCalendarAlternativeBody(const icalContent: string;
    const methodName: string): Boolean;

Adds an iCalendar body as a text/calendar alternative.

icalContent 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

Returns True for success, False for failure.

top
AddMultipleBcc
function AddMultipleBcc(const commaSeparatedAddresses: string): Boolean;

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.

Returns True for success, False for failure.

top
AddMultipleCC
function AddMultipleCC(const commaSeparatedAddresses: string): Boolean;

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

Returns True for success, False for failure.

top
AddMultipleTo
function AddMultipleTo(const commaSeparatedAddresses: string): Boolean;

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

Returns True for success, False for failure.

top
AddPfxSourceBd
// bd is a TBinData object.
function AddPfxSourceBd(bd: TChilkatBase;
    const password: string): Boolean;
Introduced in version 11.0.0

Adds the PFX data in bd 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.

Returns True for success, False for failure.

top
AddPfxSourceFile
function AddPfxSourceFile(const pfxFilePath: string;
    const pfxPassword: string): Boolean;

<p>Adds the PFX file specified by pfxFilePath to the internal list of certificate and private-key sources used during decryption. pfxPassword contains the PFX password.</p> <p>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.</p>

Returns True for success, False for failure.

top
AddPlainTextAlternativeBody
function AddPlainTextAlternativeBody(const body: string): Boolean;

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.

Returns True for success, False for failure.

More Information and Examples
top
AddRelatedBd
// binData is a TBinData object.
function AddRelatedBd(const filename: string;
    binData: TChilkatBase): 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.

Returns True for success, False for failure.

top
AddRelatedBd2
// binData is a TBinData object.
function AddRelatedBd2(binData: TChilkatBase;
    const fileNameInHtml: string): Boolean;
Introduced in version 9.5.0.65

Adds a related item using the binary data in binData.

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

Returns True for success, False for failure.

top
AddRelatedFile
function AddRelatedFile(const 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.)

Returns True for success, False for failure.

top
AddRelatedFile2
function AddRelatedFile2(const filenameOnDisk: string;
    const filenameInHtml: string): Boolean;

Adds a related item from the local file specified by filenameOnDisk. 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.

Returns True for success, False for failure.

top
AddRelatedHeader
procedure AddRelatedHeader(index: Integer;
    const fieldName: string;
    const 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.

top
AddRelatedString
function AddRelatedString(const nameInHtml: string;
    const str: string;
    const charset: string): string;

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

nameInHtml 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.

Returns True for success, False for failure.

top
AddRelatedString2
procedure AddRelatedString2(const fileNameInHtml: string;
    const content: string;
    const 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.

top
AddStringAttachment
function AddStringAttachment(const path: string;
    const content: string): Boolean;

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

Returns True for success, False for failure.

More Information and Examples
top
AddStringAttachment2
function AddStringAttachment2(const path: string;
    const content: string;
    const charset: string): Boolean;

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

path 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.

Returns True for success, False for failure.

top
AddTo
function AddTo(const friendlyName: string;
    const emailAddress: string): Boolean;

Adds a recipient to the to list. emailAddress is required, but friendlyName 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.

Returns True for success, False for failure.

More Information and Examples
top
AesDecrypt
function AesDecrypt(const password: string): Boolean;

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

Returns True for success, False for failure.

top
AesEncrypt
function AesEncrypt(const password: string): Boolean;

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.

Returns True for success, False for failure.

top
AppendToBody
procedure AppendToBody(const str: string);

Appends a string to the plain-text body.

top
ApplyFixups
function ApplyFixups(const fixups: string): Boolean;
Introduced in version 9.5.0.71

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

fixups 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.

Returns True for success, False for failure.

top
AspUnpack
function AspUnpack(const prefix: string;
    const saveDir: string;
    const urlPath: string;
    cleanFiles: Boolean): Boolean;

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

Returns True for success, False for failure.

top
AttachEmail
// email is a TEmail object.
function AttachEmail(email: TChilkatBase): Boolean;
Introduced in version 9.5.0.87

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

Returns True for success, False for failure.

top
BEncodeString
function BEncodeString(const str: string;
    const 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.

Returns True for success, False for failure.

top
Clear
procedure 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.

top
ClearBcc
procedure ClearBcc;

Clears the list of blind carbon-copy recipients.

top
ClearCC
procedure ClearCC;

Clears the list of carbon-copy recipients.

top
ClearEncryptCerts
procedure ClearEncryptCerts;

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

top
ClearTo
procedure ClearTo;

Clears the list of to recipients.

top
ComputeGlobalKey2
function ComputeGlobalKey2(const encoding: string;
    bFold: Boolean): 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. encoding 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.

Returns True for success, False for failure.

top
ConvertInlineImages
function ConvertInlineImages: Boolean;
Introduced in version 9.5.0.78

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

Returns True for success, False for failure.

top
CreateTempMht
function CreateTempMht(const inFilename: 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.

Returns True for success, False for failure.

top
DropAttachments
procedure DropAttachments;

Removes all attachments from the email.

top
DropRelatedItem
procedure DropRelatedItem(index: Integer);

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.

top
DropRelatedItems
procedure 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.

top
DropSingleAttachment
function DropSingleAttachment(index: Integer): Boolean;

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

Returns True for success, False for failure.

top
GenerateFilename
function GenerateFilename: string;

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

Returns True for success, False for failure.

top
GetAlternativeBody
function GetAlternativeBody(index: Integer): 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.

Returns True for success, False for failure.

top
GetAlternativeBodyBd
// binData is a TBinData object.
function GetAlternativeBodyBd(index: Integer;
    binData: TChilkatBase): Boolean;
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.

Returns True for success, False for failure.

top
GetAlternativeBodyByContentType
function GetAlternativeBodyByContentType(const contentType: string): string;

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

Returns True for success, False for failure.

top
GetAlternativeContentType
function GetAlternativeContentType(index: Integer): string;

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

Returns True for success, False for failure.

top
GetAltHeaderField
function GetAltHeaderField(index: Integer;
    const fieldName: string): string;

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

Returns True for success, False for failure.

top
GetAttachedEmail
// email is a TEmail object.
function GetAttachedEmail(index: Integer;
    email: TChilkatBase): Boolean;
Introduced in version 11.0.0

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

Returns True for success, False for failure.

top
GetAttachedMessageAttr
function GetAttachedMessageAttr(index: Integer;
    const fieldName: string;
    const 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.

Returns True for success, False for failure.

top
GetAttachedMessageFilename
function GetAttachedMessageFilename(index: Integer): 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

Returns True for success, False for failure.

top
GetAttachmentAttr
function GetAttachmentAttr(index: Integer;
    const fieldName: string;
    const attrName: string): string;
Introduced in version 9.5.0.41

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

Returns True for success, False for failure.

top
GetAttachmentBd
// binData is a TBinData object.
function GetAttachmentBd(index: Integer;
    binData: TChilkatBase): Boolean;
Introduced in version 9.5.0.67

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

Returns True for success, False for failure.

top
GetAttachmentContentID
function GetAttachmentContentID(index: Integer): string;

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

Returns True for success, False for failure.

top
GetAttachmentContentType
function GetAttachmentContentType(index: Integer): string;

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

Returns True for success, False for failure.

top
GetAttachmentFilename
function GetAttachmentFilename(index: Integer): string;

Retrieves an attachment's filename.

Returns True for success, False for failure.

top
GetAttachmentHeader
function GetAttachmentHeader(attachIndex: Integer;
    const fieldName: string): string;

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

Returns True for success, False for failure.

top
GetAttachmentSize
function GetAttachmentSize(index: Integer): Integer;

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.

top
GetAttachmentString
function GetAttachmentString(index: Integer;
    const charset: string): string;

Returns the attachment at the zero-based index specified by index 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.

Returns True for success, False for failure.

top
GetAttachmentStringCrLf
function GetAttachmentStringCrLf(index: Integer;
    const charset: string): string;

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

Returns True for success, False for failure.

top
GetBcc
function GetBcc(index: Integer): string;

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

Returns True for success, False for failure.

More Information and Examples
top
GetBccAddr
function GetBccAddr(index: Integer): string;

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

Returns True for success, False for failure.

More Information and Examples
top
GetBccName
function GetBccName(index: Integer): string;

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

Returns True for success, False for failure.

More Information and Examples
top
GetCC
function GetCC(index: Integer): string;

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

Returns True for success, False for failure.

More Information and Examples
top
GetCcAddr
function GetCcAddr(index: Integer): string;

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

Returns True for success, False for failure.

top
GetCcName
function GetCcName(index: Integer): string;

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

Returns True for success, False for failure.

top
GetDeliveryStatusInfo
function GetDeliveryStatusInfo(const 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. fieldName 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

Returns True for success, False for failure.

top
GetDigestEmail
// email is a TEmail object.
function GetDigestEmail(index: Integer;
    email: TChilkatBase): Boolean;
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.

Returns True for success, False for failure.

top
GetDsnInfo
// json is a TJsonObject object.
function GetDsnInfo(json: TChilkatBase): Boolean;
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.

Returns True for success, False for failure.

More Information and Examples
top
GetHeaderField
function GetHeaderField(const fieldName: string): string;

Returns the value of a header field.

Returns True for success, False for failure.

top
GetHeaderFieldName
function GetHeaderFieldName(index: Integer): 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.)

Returns True for success, False for failure.

More Information and Examples
top
GetHeaderFieldValue
function GetHeaderFieldValue(index: Integer): 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.)

Returns True for success, False for failure.

top
GetHtmlBody
function GetHtmlBody: string;

Returns the body having the text/html content type.

Returns True for success, False for failure.

top
GetHtmlBodySb
// sb is a TStringBuilder object.
function GetHtmlBodySb(inlineImageData: Boolean;
    sb: TChilkatBase): Boolean;
Introduced in version 10.1.2

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

Returns True for success, False for failure.

top
GetImapUid
function GetImapUid: LongWord;

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.

top
GetMime
function GetMime: string;

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

Returns True for success, False for failure.

top
GetMimeBd
// bindat is a TBinData object.
function GetMimeBd(bindat: TChilkatBase): Boolean;
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 bindat.

Returns True for success, False for failure.

top
GetMimeSb
// sb is a TStringBuilder object.
function GetMimeSb(sb: TChilkatBase): Boolean;
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 sb.

Returns True for success, False for failure.

More Information and Examples
top
GetNthBinaryPartOfTypeBd
// bd is a TBinData object.
function GetNthBinaryPartOfTypeBd(index: Integer;
    const contentType: string;
    inlineOnly: Boolean;
    excludeAttachments: Boolean;
    bd: TChilkatBase): Boolean;
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.

Returns True for success, False for failure.

More Information and Examples
top
GetNthContentType
function GetNthContentType(index: Integer;
    const contentType: string;
    inlineOnly: Boolean;
    excludeAttachments: Boolean): string;
Introduced in version 9.5.0.95

Returns the Content-Type of the Nth non-multipart MIME part matching the pattern in contentType. index 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.

Returns True for success, False for failure.

More Information and Examples
top
GetNthTextPartOfType
function GetNthTextPartOfType(index: Integer;
    const contentType: string;
    inlineOnly: Boolean;
    excludeAttachments: Boolean): 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. index 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.

Returns True for success, False for failure.

More Information and Examples
top
GetNumPartsOfType
function GetNumPartsOfType(const contentType: string;
    inlineOnly: Boolean;
    excludeAttachments: Boolean): Integer;
Introduced in version 9.5.0.44

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

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 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.

More Information and Examples
top
GetPlainTextBody
function GetPlainTextBody: string;

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

Returns True for success, False for failure.

top
GetRelatedAttr
function GetRelatedAttr(index: Integer;
    const fieldName: string;
    const 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.

Returns True for success, False for failure.

top
GetRelatedContentID
function GetRelatedContentID(index: Integer): 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.

Returns True for success, False for failure.

top
GetRelatedContentLocation
function GetRelatedContentLocation(index: Integer): 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.

Returns True for success, False for failure.

top
GetRelatedContentType
function GetRelatedContentType(index: Integer): string;

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

Returns True for success, False for failure.

top
GetRelatedFilename
function GetRelatedFilename(index: Integer): string;

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

Returns True for success, False for failure.

top
GetRelatedHeader
function GetRelatedHeader(index: Integer;
    const fieldName: string): string;
Introduced in version 10.0.0

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

Returns True for success, False for failure.

top
GetRelatedString
function GetRelatedString(index: Integer;
    const 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.

Returns True for success, False for failure.

top
GetRelatedStringCrLf
function GetRelatedStringCrLf(index: Integer;
    const 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.

Returns True for success, False for failure.

top
GetReplacePattern
function GetReplacePattern(index: Integer): string;

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

Returns True for success, False for failure.

More Information and Examples
top
GetReplaceString
function GetReplaceString(index: Integer): 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.

Returns True for success, False for failure.

More Information and Examples
top
GetReplaceString2
function GetReplaceString2(const pattern: string): string;

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

Returns True for success, False for failure.

More Information and Examples
top
GetReport
function GetReport(index: Integer): 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

Returns True for success, False for failure.

top
GetTo
function GetTo(index: Integer): string;

Returns a to recipient's full email address.

Returns True for success, False for failure.

More Information and Examples
top
GetToAddr
function GetToAddr(index: Integer): string;

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

Returns True for success, False for failure.

top
GetToName
function GetToName(index: Integer): string;

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

Returns True for success, False for failure.

top
GetXml
function GetXml: string;

Convert the email object to an XML document in memory

Returns True for success, False for failure.

top
HasHeaderMatching
function HasHeaderMatching(const fieldName: string;
    const valuePattern: string;
    caseSensitive: Boolean): Boolean;

Returns True when the email contains a header field named fieldName 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.

top
HasHtmlBody
function HasHtmlBody: Boolean;

Returns true if the email has an HTML body.

top
HasPlainTextBody
function HasPlainTextBody: Boolean;

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

top
IsMultipartReport
function IsMultipartReport: Boolean;

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

top
LastDecryptCert
// cert is a TCert object.
function LastDecryptCert(cert: TChilkatBase): Boolean;
Introduced in version 11.0.0

Returns in cert the certificate used to decrypt this email.

Returns True for success, False for failure.

top
LastSignerCert
// cert is a TCert object.
function LastSignerCert(index: Integer;
    cert: TChilkatBase): Boolean;
Introduced in version 11.0.0

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

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

Returns True for success, False for failure.

top
LinkedDomains
// domains is a TStringTable object.
function LinkedDomains(domains: TChilkatBase): Boolean;
Introduced in version 11.0.0

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

Returns True for success, False for failure.

top
LoadEml
function LoadEml(const mimePath: string): Boolean;

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.

Returns True for success, False for failure.

top
LoadTaskResult
// task is a TTask object.
function LoadTaskResult(task: TChilkatBase): Boolean;
Introduced in version 9.5.0.52

Loads the email object from a completed asynchronous task.

Returns True for success, False for failure.

top
LoadXml
function LoadXml(const xmlPath: string): Boolean;

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.

Returns True for success, False for failure.

top
LoadXmlString
function LoadXmlString(const xmlStr: string): Boolean;

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.

Returns True for success, False for failure.

top
MakeCopy
// destEmail is a TEmail object.
function MakeCopy(destEmail: TChilkatBase): Boolean;
Introduced in version 11.0.0

Copies this email into destEmail.

Returns True for success, False for failure.

top
QEncodeString
function QEncodeString(const str: string;
    const 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.

Returns True for success, False for failure.

top
RemoveAttachedMessage
procedure RemoveAttachedMessage(idx: Integer);

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

top
RemoveAttachedMessages
procedure RemoveAttachedMessages;

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

top
RemoveAttachmentPaths
procedure RemoveAttachmentPaths;

Removes path information from all attachment filenames.

top
RemoveHeaderField
procedure RemoveHeaderField(const fieldName: string);

Removes by name all occurrences of a header field.

top
RemoveHtmlAlternative
procedure RemoveHtmlAlternative;

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

top
RemovePlainTextAlternative
procedure RemovePlainTextAlternative;

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

top
SaveAllAttachments
function SaveAllAttachments(const dirPath: string): Boolean;

Save all the attachments of an email to files in a directory specified by dirPath. 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).

Returns True for success, False for failure.

top
SaveAttachedFile
function SaveAttachedFile(index: Integer;
    const dirPath: string): Boolean;

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.

Returns True for success, False for failure.

top
SaveEml
function SaveEml(const emlFilePath: string): Boolean;

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

Returns True for success, False for failure.

top
SaveRelatedItem
function SaveRelatedItem(index: Integer;
    const dirPath: string): Boolean;

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.

Returns True for success, False for failure.

top
SaveXml
function SaveXml(const path: string): Boolean;

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

Returns True for success, False for failure.

top
SetAttachmentCharset
function SetAttachmentCharset(index: Integer;
    const charset: string): Boolean;

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.

Returns True for success, False for failure.

top
SetAttachmentDisposition
function SetAttachmentDisposition(index: Integer;
    const disposition: string): Boolean;

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

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

Returns True for success, False for failure.

top
SetAttachmentFilename
function SetAttachmentFilename(index: Integer;
    const filename: string): Boolean;

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

Returns True for success, False for failure.

More Information and Examples
top
SetBodyBd
// bd is a TBinData object.
function SetBodyBd(bd: TChilkatBase;
    const contentType: string;
    const disposition: string;
    const filename: string): Boolean;
Introduced in version 11.0.0

Sets the main email body from the binary data in bd.

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.

Returns True for success, False for failure.

top
SetDecryptCert
// cert is a TCert object.
function SetDecryptCert(cert: TChilkatBase): Boolean;
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.

Returns True for success, False for failure.

top
SetDecryptCert2
// cert is a TCert object.
// key is a TPrivateKey object.
function SetDecryptCert2(cert: TChilkatBase;
    key: TChilkatBase): Boolean;
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.

Returns True for success, False for failure.

More Information and Examples
top
SetDt
// dt is a TCkDateTime object.
function SetDt(dt: TChilkatBase): Boolean;

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

Returns True for success, False for failure.

top
SetEdifactBody
procedure SetEdifactBody(const message: string;
    const name: string;
    const filename: string;
    const 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 message.
  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.

top
SetEncryptCert
// cert is a TCert object.
function SetEncryptCert(cert: TChilkatBase): Boolean;

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.

Returns True for success, False for failure.

top
SetFromMimeBd
// bindat is a TBinData object.
function SetFromMimeBd(bindat: TChilkatBase): Boolean;
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.

Returns True for success, False for failure.

top
SetFromMimeSb
// sb is a TStringBuilder object.
function SetFromMimeSb(sb: TChilkatBase): Boolean;
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.

Returns True for success, False for failure.

top
SetFromMimeText
function SetFromMimeText(const mimeText: string): Boolean;

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.

Returns True for success, False for failure.

top
SetFromXmlText
function SetFromXmlText(const xmlStr: string): Boolean;

Loads an email from an XML string.

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

Returns True for success, False for failure.

top
SetHtmlBody
procedure SetHtmlBody(const html: string);

Sets the HTML body of an email.

More Information and Examples
top
SetRelatedFilename
function SetRelatedFilename(index: Integer;
    const path: string): Boolean;

Sets the filename for a related item within the email.

Returns True for success, False for failure.

top
SetReplacePattern
function SetReplacePattern(const pattern: string;
    const replaceString: string): Boolean;

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.

Returns True for success, False for failure.

More Information and Examples
top
SetSigningCert
// cert is a TCert object.
function SetSigningCert(cert: TChilkatBase): Boolean;

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.

Returns True for success, False for failure.

More Information and Examples
top
SetSigningCert2
// cert is a TCert object.
// key is a TPrivateKey object.
function SetSigningCert2(cert: TChilkatBase;
    key: TChilkatBase): Boolean;

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.

Returns True for success, False for failure.

top
SetTextBody
procedure SetTextBody(const bodyText: string;
    const 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.

More Information and Examples
top
ToDsn
// dsnEmail is a TEmail object.
function ToDsn(const explanation: string;
    const statusFields: string;
    headerOnly: Boolean;
    dsnEmail: TChilkatBase): Boolean;
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.

Returns True for success, False for failure.

top
ToForward
// forward is a TEmail object.
function ToForward(forward: TChilkatBase): Boolean;
Introduced in version 11.0.0

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

Returns True for success, False for failure.

top
ToMdn
// mdn is a TEmail object.
function ToMdn(const message: string;
    const statusFields: string;
    headerOnly: Boolean;
    mdn: TChilkatBase): Boolean;
Introduced in version 11.0.0

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

Returns True for success, False for failure.

top
ToReply
// reply is a TEmail object.
function ToReply(reply: TChilkatBase): Boolean;
Introduced in version 11.0.0

Generates a reply email in reply 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.

Returns True for success, False for failure.

top
UidlEquals
// e is a TEmail object.
function UidlEquals(e: TChilkatBase): Boolean;

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

top
UnpackHtml
function UnpackHtml(const unpackDir: string;
    const htmlFilename: string;
    const partsSubdir: string): Boolean;

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.

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

Example: If unpackDir 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.

Returns True for success, False for failure.

More Information and Examples
top
UnSpamify
procedure UnSpamify;

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

top
UnzipAttachments
function UnzipAttachments: Boolean;

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.

Returns True for success, False for failure.

top
UseCertVault
// vault is a TXmlCertVault object.
function UseCertVault(vault: TChilkatBase): Boolean;
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.

Returns True for success, False for failure.

top
ZipAttachments
function ZipAttachments(const zipFilename: string): Boolean;

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

Returns True for success, False for failure.

top