Email C Library Reference
Email
Represents a complete Email object.
Create/Dispose
HCkEmail CkEmail_Create(void);
Creates an instance of the CkEmail object and returns a handle (i.e. a "void *" pointer). The handle is passed in the 1st argument for the functions listed on this page.
void CkEmail_Dispose(HCkEmail handle);
Objects created by calling CkEmail_Create must be freed by calling this method. A memory leak occurs if a handle is not disposed by calling this function.
C "Properties"
void CkEmail_getBody(HCkEmail cHandle, HCkString retval); void CkEmail_putBody(HCkEmail cHandle, const char *newVal);
The body of the email. If the email has both HTML and plain-text bodies, this property returns the HTML body. The GetHtmlBody and GetPlainTextBody methods can be used to access a specific body. The HasHtmlBody and HasPlainTextBody methods can be used to determine the presence of a body.
void CkEmail_getBounceAddress(HCkEmail cHandle, HCkString retval); void CkEmail_putBounceAddress(HCkEmail cHandle, const char *newVal);
The "return-path" address of the email. Bounces (i.e. delivery status notifications, or DSN's) will go to this address.
void CkEmail_getCharset(HCkEmail cHandle, HCkString retval); void CkEmail_putCharset(HCkEmail cHandle, const char *newVal);
Sets the charset for the entire email. The header fields and plain-text/HTML bodies will be converted and sent in this charset. (This includes parsing and updating the HTML with the appropriate META tag specifying the charset.) All formatting and encoding of the email MIME is handled automatically by the Chilkat Mail component. If your application wants to send a Shift_JIS email, you simply set the Charset property to "Shift_JIS". Note: If a charset property is not explicitly set, the Chilkat component automatically detects the charset and chooses the appropriate charset. If all characters are 7bit (i.e. us-ascii) the charset is left blank. If the email contain a mix of languages such that no one charset can be chosen, or if the language cannot be determined without ambiguity, then the "utf-8" charset will be chosen.
BOOL CkEmail_getDecrypted(HCkEmail cHandle);
true if the email arrived encrypted and was successfully decrypted, otherwise false.
void CkEmail_getEmailDate(HCkEmail cHandle, SYSTEMTIME *retval); void CkEmail_putEmailDate(HCkEmail cHandle, SYSTEMTIME *newVal);
The date and time in UTC/GMT standard. Use the LocalDate property to get the local date and time.
void CkEmail_getEncryptedBy(HCkEmail cHandle, HCkString retval);
If the email was received encrypted, this contains the details of the certificate used for encryption.
void CkEmail_getFileDistList(HCkEmail cHandle, HCkString retval); void CkEmail_putFileDistList(HCkEmail cHandle, const char *newVal);
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. Chilkat Mail 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, Chilkat Mail 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).
void CkEmail_getFrom(HCkEmail cHandle, HCkString retval); void CkEmail_putFrom(HCkEmail cHandle, const char *newVal);
The combined name and email address of the sender, such as "John Smith"
void CkEmail_getFromAddress(HCkEmail cHandle, HCkString retval); void CkEmail_putFromAddress(HCkEmail cHandle, const char *newVal);
The email address of the sender.
void CkEmail_getFromName(HCkEmail cHandle, HCkString retval); void CkEmail_putFromName(HCkEmail cHandle, const char *newVal);
The name of the sender.
void CkEmail_getHeader(HCkEmail cHandle, HCkString retval);
The complete MIME header of the email.
void CkEmail_getLanguage(HCkEmail cHandle, HCkString retval);
A read-only property that identifies the primary language group for the email. Possible values are:
- "latin1" (for English and all Western European languages)
- "central" (for Central European languages such as Polish, Czech, Hungarian, etc.)
- "russian" (for Cyrillic languages)
- "greek"
- "turkish"
- "hebrew"
- "arabic"
- "baltic"
- "thai"
- "vietnamese"
- "chinese"
- "japanese"
- "korean"
- "unknown"
The language group determination is made soley on the subject and plain-text/HTML email bodies. Characters in the FROM, TO, CC, and other header fields are not considered.
The primary determining factor is the characters found in the Subject header field. For example, if an email contains Japanese in the Subject, but the body contains Russian characters, it will be considered "japanese".
void CkEmail_getLastErrorHtml(HCkEmail cHandle, HCkString retval);
Error information in HTML format for the last method called.
void CkEmail_getLastErrorText(HCkEmail cHandle, HCkString retval);
Error information in plain-text format for the last method called.
void CkEmail_getLastErrorXml(HCkEmail cHandle, HCkString retval);
Error information in XML format for the last method called.
void CkEmail_getLocalDate(HCkEmail cHandle, SYSTEMTIME *retval); void CkEmail_putLocalDate(HCkEmail cHandle, SYSTEMTIME *newVal);
The local date and time of when the email was sent or created.
void CkEmail_getMailer(HCkEmail cHandle, HCkString retval); void CkEmail_putMailer(HCkEmail cHandle, const char *newVal);
Identifies the email software that sent the email.
long CkEmail_getNumAlternatives(HCkEmail cHandle);
The number of alternative bodies present in the email. An email that is not "multipart/alternative"will return 0 alternatives. An email that is "multipart/alternative" will return a number greater than or equal to 1.
long CkEmail_getNumAttachedMessages(HCkEmail cHandle);
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. More about Attached Email Messages
long CkEmail_getNumAttachments(HCkEmail cHandle);
The number of attachments contained in the email.
long CkEmail_getNumBcc(HCkEmail cHandle);
The number of blind carbon-copy email recipients.
long CkEmail_getNumCC(HCkEmail cHandle);
The number of carbon-copy email recipients.
int CkEmail_getNumDaysOld(HCkEmail cHandle);
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.)
long CkEmail_getNumHeaderFields(HCkEmail cHandle);
The number of header fields.
long CkEmail_getNumRelatedItems(HCkEmail cHandle);
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.
long CkEmail_getNumReplacePatterns(HCkEmail cHandle);
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.
int CkEmail_getNumReports(HCkEmail cHandle);
(For multipart/report emails that have sub-parts with Content-Types such as message/feedback-report.) Any MIME sub-part within the email that has a Content-Type of "message/*", but is not a "message/rfc822", is considered to be a "report" and is included in this count. (A "message/rfc822" is considered an attached message and is handled by the NumAttachedMessages property and the GetAttachedMessage method.)
Any MIME sub-part having a Content-Type equal to "text/rfc822-headers" is also considered to be a "report".
The GetReport method may be called to get the body content of each "report" contained within a multipart/report email.
long CkEmail_getNumTo(HCkEmail cHandle);
The number of direct email recipients.
BOOL CkEmail_getOverwriteExisting(HCkEmail cHandle); void CkEmail_putOverwriteExisting(HCkEmail cHandle, BOOL newVal);
When true (the default) the methods to save email attachments and related items will overwrite files if they already exist. If false, then 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.
void CkEmail_getPkcs7CryptAlg(HCkEmail cHandle, HCkString retval); void CkEmail_putPkcs7CryptAlg(HCkEmail cHandle, const char *newVal);
When an email is sent encrypted (using PKCS7 public-key encryption), this selects the underlying symmetric encryption algorithm. Possible values are: "aes", "des", "3des", and "rc2".
int CkEmail_getPkcs7KeyLength(HCkEmail cHandle); void CkEmail_putPkcs7KeyLength(HCkEmail cHandle, int newVal);
When the email is sent encrypted (using PKCS7 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.
void CkEmail_getPreferredCharset(HCkEmail cHandle, HCkString retval); void CkEmail_putPreferredCharset(HCkEmail cHandle, const char *newVal);
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.
BOOL CkEmail_getPrependHeaders(HCkEmail cHandle); void CkEmail_putPrependHeaders(HCkEmail cHandle, BOOL newVal);
If true, then 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.
BOOL CkEmail_getReceivedEncrypted(HCkEmail cHandle);
true if this email was originally received with encryption, otherwise false.
BOOL CkEmail_getReceivedSigned(HCkEmail cHandle);
true if this email was originally received with a digital signature, otherwise false.
void CkEmail_getReplyTo(HCkEmail cHandle, HCkString retval); void CkEmail_putReplyTo(HCkEmail cHandle, const char *newVal);
The email address to be used when a recipient replies.
BOOL CkEmail_getReturnReceipt(HCkEmail cHandle); void CkEmail_putReturnReceipt(HCkEmail cHandle, BOOL newVal);
Set to true if you want the email to request a return-receipt when received by the recipient. The default value is false.
BOOL CkEmail_getSendEncrypted(HCkEmail cHandle); void CkEmail_putSendEncrypted(HCkEmail cHandle, BOOL newVal);
Set to true if this email should be sent encrypted.
BOOL CkEmail_getSendSigned(HCkEmail cHandle); void CkEmail_putSendSigned(HCkEmail cHandle, BOOL newVal);
Set to true if this email should be sent with a digital signature.
BOOL CkEmail_getSignaturesValid(HCkEmail cHandle);
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.
void CkEmail_getSignedBy(HCkEmail cHandle, HCkString retval);
If the email was received digitally signed, this property contains the details of the signer.
void CkEmail_getSigningHashAlg(HCkEmail cHandle, HCkString retval); void CkEmail_putSigningHashAlg(HCkEmail cHandle, const char *newVal);
Selects the underlying hash algorithm used when sending signed (PKCS7) email. Possible values are "sha1", "sha256", "sha384", "sha512", "md5", and "md2".
long CkEmail_getSize(HCkEmail cHandle);
The size in bytes of the email, including all parts and attachments.
void CkEmail_getSubject(HCkEmail cHandle, HCkString retval); void CkEmail_putSubject(HCkEmail cHandle, const char *newVal);
The email subject.
void CkEmail_getUidl(HCkEmail cHandle, HCkString retval);
This is the unique ID assigned by the POP3 server. Emails can be retrieved or deleted from the POP3 server via the UIDL. The header field for this property is "X-UIDL".
Important: Emails downloaded via the IMAP protocol do not have UIDL's. UIDL's are specific to the POP3 protocol. IMAP servers use UID's (notice the spelling difference -- "UIDL" vs. "UID"). An email downloaded via the Chilkat IMAP component will contain a "ckx-imap-uid" header field that contains the UID. This may be accessed via the GetHeaderField method.
BOOL CkEmail_getUnpackUseRelPaths(HCkEmail cHandle); void CkEmail_putUnpackUseRelPaths(HCkEmail cHandle, BOOL newVal);
Applies to the UnpackHtml method. If true, then 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.
BOOL CkEmail_getUtf8(HCkEmail cHandle); void CkEmail_putUtf8(HCkEmail cHandle, BOOL newVal);
When set to true, all "const char *" arguments are expected to be utf-8 strings. If set to false, the "const char *" arguments are expected to be ANSI strings.
BOOL CkEmail_getVerboseLogging(HCkEmail cHandle); void CkEmail_putVerboseLogging(HCkEmail cHandle, BOOL newVal);
If set to true, then the contents of LastErrorText (or LastErrorXml, or LastErrorHtml) may contain more verbose information. The default value is false.
C "Methods"
void CkEmail_AddAttachmentHeader(HCkEmail cHandle, int index, const char *fieldName, const char *fieldValue);
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.
BOOL CkEmail_AddBcc(HCkEmail cHandle, const char *friendlyName, const char *emailAddress);
Adds a recipient to the blind carbon-copy list. address is required, but name may be empty. Returns True if successful. Why BCC email addresses do not appear in the email header.
BOOL CkEmail_AddCC(HCkEmail cHandle, const char *friendlyName, const char *emailAddress);
Adds a recipient to the carbon-copy list. address is required, but name may be empty. Returns True if successful.
BOOL CkEmail_AddDataAttachment(HCkEmail cHandle, const char *fileName, const unsigned char *data, unsigned long dataLen);
Adds an attachment directly from data in memory to the email.
BOOL CkEmail_AddDataAttachment2(HCkEmail cHandle, const char *fileName, HCkByteData content, const char *contentType);
Adds an attachment to an email from in-memory data. Same as AddDataAttachment but allows the content-type to be specified.
BOOL CkEmail_AddEncryptCert(HCkEmail cHandle, HCkCert cert);
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. The Chilkat email component will automatically search the registry-based Current-User and Local-Machine certificate stores for certs matching each of the recipients (To, CC, and BCC recipients).
Note: The SentEncryptCert method is equivalent to calling ClearEncryptCerts followed by AddEncryptCert. Returns TRUE for success, FALSE for failure.
BOOL CkEmail_AddFileAttachment(HCkEmail cHandle, const char *fileName, HCkString outStrContentType);
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.
BOOL CkEmail_AddFileAttachment2(HCkEmail cHandle, const char *fileName, const char *contentType);
Same as AddFileAttachment, but the content type can be explicitly specified.
void CkEmail_AddHeaderField(HCkEmail cHandle, const char *fieldName, const char *fieldValue);
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).
void CkEmail_AddHeaderField2(HCkEmail cHandle, const char *fieldName, const char *fieldValue);
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.
BOOL CkEmail_AddHtmlAlternativeBody(HCkEmail cHandle, const char *body);
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.
BOOL CkEmail_AddMultipleBcc(HCkEmail cHandle, const char *commaSeparatedAddresses);
Adds multiple recipients to the blind carbon-copy list. The parameter is a string containing a comma separated list of full email addresses. Returns True if successful. Why BCC email addresses do not appear in the email header.
BOOL CkEmail_AddMultipleCC(HCkEmail cHandle, const char *commaSeparatedAddresses);
Adds multiple recipients to the carbon-copy list. The parameter is a string containing a comma separated list of full email addresses. Returns True if successful.
BOOL CkEmail_AddMultipleTo(HCkEmail cHandle, const char *commaSeparatedAddresses);
Adds multiple recipients to the "to" list. The parameter is a string containing a comma separated list of full email addresses. Returns True if successful.
BOOL CkEmail_AddPfxSourceData(HCkEmail cHandle, HCkByteData pfxData, const char *password);
Adds a PFX to the object's internal list of sources to be searched for certificates and private keys when decrypting. Multiple PFX sources can be added by calling this method once for each. (On the Windows operating system, the registry-based certificate stores are also automatically searched, so it is commonly not required to explicitly add PFX sources.)
The pfxBytes contains the bytes of a PFX file (also known as PKCS12 or .p12).
BOOL CkEmail_AddPfxSourceFile(HCkEmail cHandle, const char *pfxFilePath, const char *password);
Adds a PFX file to the object's internal list of sources to be searched for certificates and private keys when decrypting. Multiple PFX files can be added by calling this method once for each. (On the Windows operating system, the registry-based certificate stores are also automatically searched, so it is commonly not required to explicitly add PFX sources.)
The pfxFilePath contains the bytes of a PFX file (also known as PKCS12 or .p12).
BOOL CkEmail_AddPlainTextAlternativeBody(HCkEmail cHandle, const char *body);
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.
BOOL CkEmail_AddRelatedData(HCkEmail cHandle, const char *nameInHtml, const unsigned char *data, unsigned long dataLen, HCkString outStrContentId);
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.)
void CkEmail_AddRelatedData2(HCkEmail cHandle, const unsigned char *data, unsigned long dataLen, const char *fileNameInHtml);
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.
BOOL CkEmail_AddRelatedFile(HCkEmail cHandle, const char *fileName, HCkString outStrContentID);
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.)
BOOL CkEmail_AddRelatedFile2(HCkEmail cHandle, const char *fileNameOnDisk, const char *filenameInHtml);
Adds a related item to the email from a file. 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 AddRelatedFile in that it does not use or return a Content-ID. 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.
void CkEmail_AddRelatedHeader(HCkEmail cHandle, int index, const char *fieldName, const char *fieldValue);
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.
BOOL CkEmail_AddRelatedString(HCkEmail cHandle, const char *nameInHtml, const char *str, const char *charset, HCkString outCid);
Adds a related item to the email. A related item is typically an image or style sheet referenced by an HTML tag within the HTML email body. The contents of the related item are passed str. nameInHtml specifies the filename that should be used within the HTML, and not an actual filename on the local filesystem. charset specifies the charset that should be used for the text content of the related item. Returns the content-ID generated for the added item.
void CkEmail_AddRelatedString2(HCkEmail cHandle, const char *str, const char *charset, const char *filenameInHtml);
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.
BOOL CkEmail_AddStringAttachment(HCkEmail cHandle, const char *fileName, const char *str);
Adds an attachment directly from a string in memory to the email.
BOOL CkEmail_AddStringAttachment2(HCkEmail cHandle, const char *fileName, const char *str, const char *charset);
Adds an attachment to an email. The filename argument specifies the filename to be used for the attachment and is not an actual filename existing on the local filesystem. The "str" argument contains the text data for the attachment. The string will be converted to the charset specified in the last argument before being added to the email.
BOOL CkEmail_AddTo(HCkEmail cHandle, const char *friendlyName, const char *emailAddress);
Adds a recipient to the "to" list. address is required, but name may be empty. Returns True if successful. Emails that have no "To" recipients will be sent to <undisclosed-recipients>.
BOOL CkEmail_AddiCalendarAlternativeBody(HCkEmail cHandle, const char *body, const char *methodName);
Adds an iCalendar (text/calendar) alternative body to the email. The icalContent contains the content of the iCalendar data. A sample is shown here:
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
The methodName is the "method" attribute used in the Content-Type header field in the alternative body. For example, if set to "REQUEST", then the alternative body's header would look like this:
Content-Type: text/calendar; method=REQUEST
Content-Transfer-Encoding: base64
BOOL CkEmail_AesDecrypt(HCkEmail cHandle, const char *password);
Decrypts and restores an email message that was previously encrypted using AesEncrypt. The password must match the password used for encryption.
BOOL CkEmail_AesEncrypt(HCkEmail cHandle, const char *password);
Encrypts the email body, all alternative bodies, all message sub-parts and attachments using 128-bit AES (Rijndael, CBC mode) encryption. To decrypt, you must use the AesDecrypt method with the same password. The AesEncrypt/Decrypt methods use symmetric password-based greatly simplify sending and receiving encrypted emails because certificates and public/private key issues do not have to be dealt with. However, the sending and receiving applications must both be using Chilkat Email .NET or ActiveX components.
void CkEmail_AppendToBody(HCkEmail cHandle, const char *str);
Appends a string to the plain-text body.
BOOL CkEmail_AspUnpack(HCkEmail cHandle, const char *prefix, const char *saveDir, const char *urlPath, BOOL cleanFiles);
Please see the examples at the following pages for detailed information: Returns TRUE for success, FALSE for failure. Display HTML Email in Web Page Display HTML Email in IFrame (or Frame)
BOOL CkEmail_AspUnpack2(HCkEmail cHandle, const char *prefix, const char *saveDir, const char *urlPath, BOOL cleanFiles, HCkByteData outHtml);
Please see the examples at the following pages for detailed information: Display HTML Email in Web Page Display HTML Email in IFrame (or Frame)
BOOL CkEmail_AttachMessage(HCkEmail cHandle, HCkByteData mimeBytes);
Attaches a MIME message to the email object. The attached MIME will be encapsulated in an message/rfc822 sub-part. To attach one email object to another, pass the output of GetMimeBinary to the input of this method. Returns TRUE for success, FALSE for failure.
BOOL CkEmail_BEncodeBytes(HCkEmail cHandle, const unsigned char *data, unsigned long dataLen, const char *charset, HCkString outEncodedStr);
Takes a byte array of multibyte (non-Unicode) data and returns a Unicode B-Encoded string.
BOOL CkEmail_BEncodeString(HCkEmail cHandle, const char *str, const char *charset, HCkString outEncodedStr);
Takes a Unicode string, converts it to the charset specified in the 2nd parameter, B-Encodes the converted multibyte data, and returns the encoded Unicode string.
void CkEmail_ClearBcc(HCkEmail cHandle);
Clears the list of blind carbon-copy recipients.
void CkEmail_ClearCC(HCkEmail cHandle);
Clears the list of carbon-copy recipients.
void CkEmail_ClearEncryptCerts(HCkEmail cHandle);
Clears the internal list of explicitly specified certificates to be used for this encrypted email.
void CkEmail_ClearTo(HCkEmail cHandle);
Clears the list of "to" recipients.
HCkEmail CkEmail_Clone(HCkEmail cHandle);
Creates and returns an identical copy of the Email object. Returns a null reference on failure
BOOL CkEmail_ComputeGlobalKey(HCkEmail cHandle, const char *encoding, BOOL bFold, HCkString outStr);
Computes a global unique key for the email that may be used as a key for a relational database table (or anything else). The key is created by a digest-MD5 hash of the concatenation of the following header fields: Message-ID, Subject, From, Date, To. (The header fields are Q/B decoded if necessary, converted to the utf-8 encoding, concatenated, and hashed using MD5.) The 16-byte MD5 hash is returned as an encoded string. The 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.
HCkEmail CkEmail_CreateDsn(HCkEmail cHandle, const char *explanation, const char *xmlDeliveryStatus, BOOL bHeaderOnly);
Creates a new DSN (Delivery Status Notification) email having the format as specified in RFC 3464. See the example (below) for more detailed information. Returns a null reference on failure
HCkEmail CkEmail_CreateForward(HCkEmail cHandle);
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. Returns a null reference on failure
HCkEmail CkEmail_CreateMdn(HCkEmail cHandle, const char *explanation, const char *xmlMdnFields, BOOL bHeaderOnly);
Creates a new MDN (Message Disposition Notification) email having the format as specified in RFC 3798. See the example (below) for more detailed information. Returns a null reference on failure
HCkEmail CkEmail_CreateReply(HCkEmail cHandle);
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. Returns a null reference on failure
BOOL CkEmail_CreateTempMht(HCkEmail cHandle, const char *inFilename, HCkString tempMhtFilenameInOut);
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.
void CkEmail_DropAttachments(HCkEmail cHandle);
Removes all attachments from the email.
void CkEmail_DropRelatedItem(HCkEmail cHandle, long index);
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.
void CkEmail_DropRelatedItems(HCkEmail cHandle);
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.
BOOL CkEmail_DropSingleAttachment(HCkEmail cHandle, long index);
Drops a single attachment from the email. Returns True if successful.
void CkEmail_GenerateFilename(HCkEmail cHandle, HCkString outStrFilename);
Generates a unique filename for this email. The filename will be different each time the method is called.
BOOL CkEmail_GetAltHeaderField(HCkEmail cHandle, int index, const char *fieldName, HCkString outStr);
Returns the value of a header field within the Nth alternative body's MIME sub-part.
BOOL CkEmail_GetAlternativeBody(HCkEmail cHandle, long index, HCkString outStrBody);
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.
BOOL CkEmail_GetAlternativeBodyByContentType(HCkEmail cHandle, const char *contentType, HCkString outStr);
Returns the alternative body by content-type, such as "text/plain", "text/html", "text/xml", etc.
BOOL CkEmail_GetAlternativeContentType(HCkEmail cHandle, long index, HCkString outStrContentType);
Returns the content type of the Nth alternative body. The NumAlternatives property tells the number of alternative bodies present.
HCkEmail CkEmail_GetAttachedMessage(HCkEmail cHandle, long index);
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. Returns a null reference on failure
BOOL CkEmail_GetAttachedMessageFilename(HCkEmail cHandle, int index, HCkString outStr);
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.
BOOL CkEmail_GetAttachmentContentID(HCkEmail cHandle, long index, HCkString outStrContentID);
Returns the ContentID header field for the Nth attachment. The first attachment is at index 0.
BOOL CkEmail_GetAttachmentContentType(HCkEmail cHandle, long index, HCkString outStrContentType);
Returns the Content-Type header field for the Nth attachment. Indexing of attachments begins at 0.
BOOL CkEmail_GetAttachmentData(HCkEmail cHandle, long index, HCkByteData outData);
Retrieves an attachment's binary data for in-memory access.
BOOL CkEmail_GetAttachmentFilename(HCkEmail cHandle, long index, HCkString outStrFilename);
Retrieves an attachment's filename.
BOOL CkEmail_GetAttachmentHeader(HCkEmail cHandle, long index, const char *fieldName, HCkString outFieldValue);
Returns the value of a header field (by name) of an attachment.
long CkEmail_GetAttachmentSize(HCkEmail cHandle, long index);
Returns the size (in bytes) of the Nth attachment.
BOOL CkEmail_GetAttachmentString(HCkEmail cHandle, long index, const char *charset, HCkString outStr);
Retrieves an attachment's data as a String. All CRLF sequences will be translated to single newline characters.
BOOL CkEmail_GetAttachmentStringCrLf(HCkEmail cHandle, long index, const char *charset, HCkString outStrData);
Retrieves an attachment's data as a String. All end-of-lines will be translated to CRLF sequences.
BOOL CkEmail_GetBcc(HCkEmail cHandle, long index, HCkString outStr);
Returns a blind carbon-copy recipient's full email address.
BOOL CkEmail_GetBccAddr(HCkEmail cHandle, long index, HCkString outStr);
Returns the Nth BCC address (only the address part, not the friendly-name part).
BOOL CkEmail_GetBccName(HCkEmail cHandle, long index, HCkString outStr);
Returns the Nth BCC name (only the friendly-name part, not the address part).
BOOL CkEmail_GetCC(HCkEmail cHandle, long index, HCkString outStr);
Returns a carbon-copy recipient's full email address.
BOOL CkEmail_GetCcAddr(HCkEmail cHandle, long index, HCkString outStr);
Returns the Nth CC address (only the address part, not the friendly-name part).
BOOL CkEmail_GetCcName(HCkEmail cHandle, long index, HCkString outStr);
Returns the Nth CC name (only the friendly-name part, not the address part).
BOOL CkEmail_GetDeliveryStatusInfo(HCkEmail cHandle, const char *fieldName, HCkString outFieldValue);
If the email is a multipart/report, then it is a delivery status notification. This method can be used to get individual pieces of information from the message/delivery-status part of the email. This method should only be called if the IsMultipartReport method returns true.
The fieldName should be set a string such as "Final-Recipient", "Status", "Action", "Reporting-MTA", etc.
Reporting-MTA: dns; XYZ.abc.nl
Final-recipient: RFC822; someEmailAddr@doesnotexist123.nl
Action: failed
Status: 5.4.4
X-Supplementary-Info: < #5.4.4 smtp;554 5.4.4
SMTPSEND.DNS.NonExistentDomain; nonexistent domain>
HCkStringArray CkEmail_GetDsnFinalRecipients(HCkEmail cHandle);
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. Returns a null reference on failure
HCkCert CkEmail_GetEncryptCert(HCkEmail cHandle);
Returns the certificate that was previously set by SetEncryptCert.
HCkCert CkEmail_GetEncryptedByCert(HCkEmail cHandle);
Returns the certificate associated with a received encrypted email.
BOOL CkEmail_GetFileContent(HCkEmail cHandle, const char *filename, HCkByteData outData);
Reads a file and returns the contents as a String. This is here purely for convenience.
BOOL CkEmail_GetHeaderField(HCkEmail cHandle, const char *fieldName, HCkString outStrFieldData);
Returns the value of a header field.
BOOL CkEmail_GetHeaderFieldName(HCkEmail cHandle, long index, HCkString outStrFieldName);
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.
BOOL CkEmail_GetHeaderFieldValue(HCkEmail cHandle, long index, HCkString outStrFieldValue);
Returns the value of the Nth header field. (Indexing begins at 0) The number of header fields can be obtained from the NumHeaderFields property.
BOOL CkEmail_GetHtmlBody(HCkEmail cHandle, HCkString outStrBody);
Returns the body having the "text/html" content type.
int CkEmail_GetImapUid(HCkEmail cHandle);
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 -1.
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.
If this method is not yet available in your version of the Chilkat Email object, you may also call GetHeaderField("ckx-imap-uid") to fetch the UID as a string, and then convert it to an integer.
void CkEmail_GetLinkedDomains(HCkEmail cHandle, HCkStringArray array);
Parses an HTML email and returns the set of domain names that occur in hyperlinks within the HTML body.
BOOL CkEmail_GetMbHeaderField(HCkEmail cHandle, const char *fieldName, HCkByteData outData);
Returns a header field's data in a byte array. If the field was Q or B encoded, this is automatically decoded, and the raw bytes of the field are returned. Call GetHeaderField to retrieve the header field as a Unicode string.
BOOL CkEmail_GetMbHeaderField2(HCkEmail cHandle, const char *charset, const char *fieldName, HCkByteData outData);
Returns the value of a header field converted to a specified charset.
BOOL CkEmail_GetMbHtmlBody(HCkEmail cHandle, const char *charset, HCkByteData outData);
Returns the HTML body converted to a specified charset. If no HTML body exists, the returned byte array is empty. The returned data will be such that not only is the character data converted (if necessary) to the convertToCharset, but the HTML is edited to add or modify the META tag that specifies the charset within the HTML.
BOOL CkEmail_GetMbPlainTextBody(HCkEmail cHandle, const char *charset, HCkByteData outData);
Returns the plain-text body converted to a specified charset. The return value is a byte array containing multibyte character data.
void CkEmail_GetMime(HCkEmail cHandle, HCkString outStrMime);
Return the email as MIME text containing the email header, body (or bodies), related items (if any), and all attachments
BOOL CkEmail_GetMimeBinary(HCkEmail cHandle, HCkByteData outBytes);
Returns the full MIME of an email.
HCkMime CkEmail_GetMimeObject(HCkEmail cHandle);
Creates and returns a Mime object containing the contents of the email. This method is provided for those users that need full access to every aspect of the MIME message, such as manipulation of the message headers of attachments and related items contained within message subparts.(The returned Mime object returned is locked, and needs to be unlocked with a Chilkat S/MIME .NET unlock code, which can be obtained by purchasing a Chilkat S/MIME .NET license.)
BOOL CkEmail_GetPlainTextBody(HCkEmail cHandle, HCkString outStrBody);
Returns the email body having the "text/plain" content type.
BOOL CkEmail_GetRelatedContentID(HCkEmail cHandle, long index, HCkString outStrContentID);
Returns the content ID of a related item contained with the email. Related items are typically images and style-sheets embedded within HTML emails.
BOOL CkEmail_GetRelatedContentLocation(HCkEmail cHandle, int index, HCkString outStr);
Returns the Content-Location of a related item contained with the email. Related items are typically images and style-sheets embedded within HTML emails.
BOOL CkEmail_GetRelatedContentType(HCkEmail cHandle, long index, HCkString outStrContentType);
Returns the content-type of the Nth related content item in an email message.
BOOL CkEmail_GetRelatedData(HCkEmail cHandle, long index, HCkByteData outBuffer);
Returns the content of a related item contained with the email. Related items are typically images and style-sheets embedded within HTML emails.
BOOL CkEmail_GetRelatedFilename(HCkEmail cHandle, long index, HCkString outStrFilename);
Returns the filename of a related item contained with the email. Related items are typically images and style-sheets embedded within HTML emails.
BOOL CkEmail_GetRelatedString(HCkEmail cHandle, long index, const char *charset, HCkString outStrData);
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.
BOOL CkEmail_GetRelatedStringCrLf(HCkEmail cHandle, long index, const char *charset, HCkString outStr);
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.
BOOL CkEmail_GetReplacePattern(HCkEmail cHandle, long index, HCkString outStrPattern);
Returns a replacement pattern previously defined for mail-merge operations.
BOOL CkEmail_GetReplaceString(HCkEmail cHandle, long index, HCkString outStr);
Returns a replacement string for a previously defined pattern/replacement string pair. (This is a mail-merge feature.)
BOOL CkEmail_GetReplaceString2(HCkEmail cHandle, const char *pattern, HCkString outStr);
Returns a replacement string for a previously defined pattern/replacement string pair. (This is a mail-merge feature.)
BOOL CkEmail_GetReport(HCkEmail cHandle, int index, HCkString outStr);
(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
HCkCert CkEmail_GetSignedByCert(HCkEmail cHandle);
Return the certificate used to digitally sign this email.
HCkCert CkEmail_GetSigningCert(HCkEmail cHandle);
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.
BOOL CkEmail_GetTo(HCkEmail cHandle, long index, HCkString outStr);
Returns a "to" recipient's full email address.
BOOL CkEmail_GetToAddr(HCkEmail cHandle, long index, HCkString outStr);
Returns the Nth To address (only the address part, not the friendly-name part).
BOOL CkEmail_GetToName(HCkEmail cHandle, long index, HCkString outStr);
Returns the Nth To name (only the friendly-name part, not the address part).
void CkEmail_GetXml(HCkEmail cHandle, HCkString outStrXml);
Convert the email object to an XML document in memory
BOOL CkEmail_HasHeaderMatching(HCkEmail cHandle, const char *fieldName, const char *valuePattern, BOOL caseInsensitive);
Returns true if the email has a header field with the specified fieldName with a value matching valuePattern. Case sensitivity is controlled by caseSensitive. The valuePattern may include 0 or more asterisk (wildcard) characters which match 0 or more of any character.
BOOL CkEmail_HasHtmlBody(HCkEmail cHandle);
Returns true if the email has an HTML body.
BOOL CkEmail_HasPlainTextBody(HCkEmail cHandle);
Returns true if the email has a plain-text body.
BOOL CkEmail_IsMultipartReport(HCkEmail cHandle);
Returns true if the email is a multipart/report email.
BOOL CkEmail_LoadEml(HCkEmail cHandle, const char *mimeFilename);
Loads a complete email from a .EML file. (EML files are simply RFC822 MIME text files.)
BOOL CkEmail_LoadXml(HCkEmail cHandle, const char *xmlFilename);
Loads an email with the contents of an XML email file.
BOOL CkEmail_LoadXmlString(HCkEmail cHandle, const char *xmlStr);
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.
BOOL CkEmail_QEncodeBytes(HCkEmail cHandle, const unsigned char *data, unsigned long dataLen, const char *charset, HCkString outEncodedStr);
Takes a byte array of multibyte (non-Unicode) data and returns a Unicode Q-Encoded string.
BOOL CkEmail_QEncodeString(HCkEmail cHandle, const char *str, const char *charset, HCkString outEncodedStr);
Takes a Unicode string, converts it to the charset specified in the 2nd parameter, Q-Encodes the converted multibyte data, and returns the encoded Unicode string.
void CkEmail_RemoveAttachedMessage(HCkEmail cHandle, long index);
Removes the Nth message/rfc822 sub-part of the email. Indexing begins at 0.
void CkEmail_RemoveAttachedMessages(HCkEmail cHandle);
Removes all message/rfc822 sub-parts of the email object.
void CkEmail_RemoveAttachmentPaths(HCkEmail cHandle);
Removes path information from all attachment filenames.
void CkEmail_RemoveHeaderField(HCkEmail cHandle, const char *fieldName);
Removes by name all occurances of a header field.
void CkEmail_RemoveHtmlAlternative(HCkEmail cHandle);
Removes the HTML body from the email (if an HTML body exists).
void CkEmail_RemovePlainTextAlternative(HCkEmail cHandle);
Removes the plain-text body from the email (if a plain-text body exists).
BOOL CkEmail_SaveAllAttachments(HCkEmail cHandle, const char *directory);
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.
BOOL CkEmail_SaveAttachedFile(HCkEmail cHandle, long index, const char *directory);
Saves the Nth email attachment to the directory specified by dirPath. The 1st attachment is at index 0. The OverwriteExisting property controls whether existing files are allowed to be overwritten.
BOOL CkEmail_SaveEml(HCkEmail cHandle, const char *filename);
Convert this email object to EML and save it to a file.
BOOL CkEmail_SaveLastError(HCkEmail cHandle, const char *filename);
Saves the last error information to an XML formatted file.
BOOL CkEmail_SaveRelatedItem(HCkEmail cHandle, long index, const char *directory);
Saves the Nth related item to the directory specified by dirPath. (The 1st 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.
BOOL CkEmail_SaveXml(HCkEmail cHandle, const char *filename);
Convert this email object to XML and save it to a file.
BOOL CkEmail_SetAttachmentCharset(HCkEmail cHandle, int index, const char *charset);
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 us-ascii charset such as Shift_JIS, iso-8859-2, big5, iso-8859-5, etc. Returns TRUE for success, FALSE for failure.
BOOL CkEmail_SetAttachmentDisposition(HCkEmail cHandle, int index, const char *disposition);
Set's an attachment's disposition. The default disposition of an attachment is "attachment". This method is typically called to change the disposition to "inline". The 1st attachment is at ARG1 0. Returns TRUE for success, FALSE for failure.
BOOL CkEmail_SetAttachmentFilename(HCkEmail cHandle, long index, const char *filename);
Renames a email attachment's filename. The 1st attachment is at index 0. Returns TRUE for success, FALSE for failure.
BOOL CkEmail_SetCSP(HCkEmail cHandle, HCkCSP csp);
(Only applies to the Microsoft Windows OS) Sets the Cryptographic Service Provider (CSP) to be used for encryption or digital signing.
This is not commonly used becaues the default Microsoft CSP is typically appropriate.
One instance where SetCSP is necessary is when using the Crypto-Pro CSP for the GOST R 34.10-2001 and GOST R 34.10-94 providers. Returns TRUE for success, FALSE for failure.
BOOL CkEmail_SetEncryptCert(HCkEmail cHandle, HCkCert cert);
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.
BOOL CkEmail_SetFromMimeBytes(HCkEmail cHandle, HCkByteData mimeBytes);
To be documented soon. Returns TRUE for success, FALSE for failure.
BOOL CkEmail_SetFromMimeObject(HCkEmail cHandle, HCkMime mime);
Loads and replaces the contents of this email object with the contents of a Mime object
BOOL CkEmail_SetFromMimeText(HCkEmail cHandle, const char *mimeText);
Replace the contents of this email object with that found in the MIME text
BOOL CkEmail_SetFromMimeText2(HCkEmail cHandle, const char *mimeText, int numBytes);
Same as SetFromMimeText, but accepts two arguments: a pointer to the byte data containing the MIME text and a size (in bytes). This is helpful for MIME text that may contain binary data, including NULL bytes. Returns TRUE for success, FALSE for failure.
BOOL CkEmail_SetFromXmlText(HCkEmail cHandle, const char *xmlStr);
Loads an email from an XML string.
void CkEmail_SetHtmlBody(HCkEmail cHandle, const char *html);
Sets the HTML body of an email.
BOOL CkEmail_SetMbHtmlBody(HCkEmail cHandle, const char *charset, const unsigned char *data, unsigned long dataLen);
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.
BOOL CkEmail_SetMbPlainTextBody(HCkEmail cHandle, const char *charset, const unsigned char *data, unsigned long dataLen);
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.
BOOL CkEmail_SetReplacePattern(HCkEmail cHandle, const char *pattern, const char *replaceString);
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. Do 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.
BOOL CkEmail_SetSigningCert(HCkEmail cHandle, HCkCert cert);
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.
BOOL CkEmail_SetSigningCert2(HCkEmail cHandle, HCkCert cert, HCkPrivateKey key);
Explicitly sets the certificate and private key to be used for sending digitally signed email. If the certificate's private key is already installed on the computer, then one may simply call SetSigningCert because the Chilkat component will automatically locate and use the corresponding private key (stored in the Windows Protected Store). In most cases, if the digital certificate is already installed w/ private key on the computer, it is not necessary to explicitly set the signing certificate at all. The Chilkat component will automatically locate and use the certificate containing the FROM email address (from the registry-based certificate store where it was installed). Returns TRUE for success, FALSE for failure.
void CkEmail_SetTextBody(HCkEmail cHandle, const char *bodyText, const char *contentType);
Sets the body of the email and also sets the Content-Type header field of the 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.
BOOL CkEmail_UidlEquals(HCkEmail cHandle, HCkEmail e);
True if the caller email has a UIDL that equals the email passed in the argument.
void CkEmail_UnSpamify(HCkEmail cHandle);
Unobfuscates emails by undoing what spammers do to obfuscate email. It removes comments from HTML bodies and unobfuscates hyperlinked URLs.
BOOL CkEmail_UnlockComponent(HCkEmail cHandle, const char *unlockCode);
Added as a convenience so that Chilkat Email.NET can be unlocked without necessarily having to create a MailMan object and calling MailMan.UnlockComponent. Either one of MailMan.UnlockComponent or Email.UnlockComponent can be called once at the beginning of your program to unlock the entire Chilkat Email.NET component.
BOOL CkEmail_UnpackHtml(HCkEmail cHandle, const char *unpackDir, const char *htmlFilename, const char *partsSubdir);
Unpacks an HTML email into an HTML file and related files (images and style sheets). The links within the HTML are updated to point to the files unpacked and saved to disk. Returns TRUE for success, FALSE for failure.
BOOL CkEmail_UnzipAttachments(HCkEmail cHandle);
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.
BOOL CkEmail_ZipAttachments(HCkEmail cHandle, const char *zipFilename);
Replaces all the attachments of an email with a single Zip file attachment having the filename specified.
const char *CkEmail_addFileAttachment(HCkEmail cHandle, const char *fileName);
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 a null on failure
const char *CkEmail_addRelatedData(HCkEmail cHandle, const char *nameInHtml, const unsigned char *data, unsigned long dataLen);
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.) Returns a null on failure
const char *CkEmail_addRelatedFile(HCkEmail cHandle, const char *fileName);
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 a null on failure
const char *CkEmail_addRelatedString(HCkEmail cHandle, const char *nameInHtml, const char *str, const char *charset);
Adds a related item to the email. A related item is typically an image or style sheet referenced by an HTML tag within the HTML email body. The contents of the related item are passed str. nameInHtml specifies the filename that should be used within the HTML, and not an actual filename on the local filesystem. charset specifies the charset that should be used for the text content of the related item. Returns the content-ID generated for the added item. Returns a null on failure
const char *CkEmail_bEncodeBytes(HCkEmail cHandle, const unsigned char *data, unsigned long dataLen, const char *charset);
Takes a byte array of multibyte (non-Unicode) data and returns a Unicode B-Encoded string. Returns a null on failure
const char *CkEmail_bEncodeString(HCkEmail cHandle, const char *str, const char *charset);
Takes a Unicode string, converts it to the charset specified in the 2nd parameter, B-Encodes the converted multibyte data, and returns the encoded Unicode string. Returns a null on failure
const char *CkEmail_body(HCkEmail cHandle);
The body of the email. If the email has both HTML and plain-text bodies, this property returns the HTML body. The GetHtmlBody and GetPlainTextBody methods can be used to access a specific body. The HasHtmlBody and HasPlainTextBody methods can be used to determine the presence of a body. Returns a null on failure
const char *CkEmail_bounceAddress(HCkEmail cHandle);
The "return-path" address of the email. Bounces (i.e. delivery status notifications, or DSN's) will go to this address. Returns a null on failure
const char *CkEmail_charset(HCkEmail cHandle);
Sets the charset for the entire email. The header fields and plain-text/HTML bodies will be converted and sent in this charset. (This includes parsing and updating the HTML with the appropriate META tag specifying the charset.) All formatting and encoding of the email MIME is handled automatically by the Chilkat Mail component. If your application wants to send a Shift_JIS email, you simply set the Charset property to "Shift_JIS". Note: If a charset property is not explicitly set, the Chilkat component automatically detects the charset and chooses the appropriate charset. If all characters are 7bit (i.e. us-ascii) the charset is left blank. If the email contain a mix of languages such that no one charset can be chosen, or if the language cannot be determined without ambiguity, then the "utf-8" charset will be chosen. Returns a null on failure
const char *CkEmail_ck_from(HCkEmail cHandle);
To be documented soon...
const char *CkEmail_computeGlobalKey(HCkEmail cHandle, const char *encoding, BOOL bFold);
Computes a global unique key for the email that may be used as a key for a relational database table (or anything else). The key is created by a digest-MD5 hash of the concatenation of the following header fields: Message-ID, Subject, From, Date, To. (The header fields are Q/B decoded if necessary, converted to the utf-8 encoding, concatenated, and hashed using MD5.) The 16-byte MD5 hash is returned as an encoded string. The 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 a null on failure
const char *CkEmail_createTempMht(HCkEmail cHandle, const char *inFilename);
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 a null on failure
const char *CkEmail_encryptedBy(HCkEmail cHandle);
If the email was received encrypted, this contains the details of the certificate used for encryption. Returns a null on failure
const char *CkEmail_fileDistList(HCkEmail cHandle);
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. Chilkat Mail 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, Chilkat Mail 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). Returns a null on failure
const char *CkEmail_fromAddress(HCkEmail cHandle);
The email address of the sender. Returns a null on failure
const char *CkEmail_fromName(HCkEmail cHandle);
The name of the sender. Returns a null on failure
const char *CkEmail_generateFilename(HCkEmail cHandle);
Generates a unique filename for this email. The filename will be different each time the method is called. Returns a null on failure
const char *CkEmail_getAltHeaderField(HCkEmail cHandle, int index, const char *fieldName);
Returns the value of a header field within the Nth alternative body's MIME sub-part. Returns a null on failure
const char *CkEmail_getAlternativeBody(HCkEmail cHandle, long index);
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 a null on failure
const char *CkEmail_getAlternativeBodyByContentType(HCkEmail cHandle, const char *contentType);
Returns the alternative body by content-type, such as "text/plain", "text/html", "text/xml", etc. Returns a null on failure
const char *CkEmail_getAlternativeContentType(HCkEmail cHandle, long index);
Returns the content type of the Nth alternative body. The NumAlternatives property tells the number of alternative bodies present. Returns a null on failure
const char *CkEmail_getAttachedMessageFilename(HCkEmail cHandle, int index);
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. Returns a null on failure
const char *CkEmail_getAttachmentContentID(HCkEmail cHandle, long index);
Returns the ContentID header field for the Nth attachment. The first attachment is at index 0. Returns a null on failure
const char *CkEmail_getAttachmentContentType(HCkEmail cHandle, long index);
Returns the Content-Type header field for the Nth attachment. Indexing of attachments begins at 0. Returns a null on failure
const char *CkEmail_getAttachmentFilename(HCkEmail cHandle, long index);
Retrieves an attachment's filename. Returns a null on failure
const char *CkEmail_getAttachmentHeader(HCkEmail cHandle, long index, const char *fieldName);
Returns the value of a header field (by name) of an attachment. Returns a null on failure
const char *CkEmail_getAttachmentString(HCkEmail cHandle, long index, const char *charset);
Retrieves an attachment's data as a String. All CRLF sequences will be translated to single newline characters. Returns a null on failure
const char *CkEmail_getAttachmentStringCrLf(HCkEmail cHandle, long index, const char *charset);
Retrieves an attachment's data as a String. All end-of-lines will be translated to CRLF sequences. Returns a null on failure
const char *CkEmail_getBcc(HCkEmail cHandle, long index);
Returns a blind carbon-copy recipient's full email address. Returns a null on failure
const char *CkEmail_getBccAddr(HCkEmail cHandle, long index);
Returns the Nth BCC address (only the address part, not the friendly-name part). Returns a null on failure
const char *CkEmail_getBccName(HCkEmail cHandle, long index);
Returns the Nth BCC name (only the friendly-name part, not the address part). Returns a null on failure
const char *CkEmail_getCC(HCkEmail cHandle, long index);
Returns a carbon-copy recipient's full email address. Returns a null on failure
const char *CkEmail_getCcAddr(HCkEmail cHandle, long index);
Returns the Nth CC address (only the address part, not the friendly-name part). Returns a null on failure
const char *CkEmail_getCcName(HCkEmail cHandle, long index);
Returns the Nth CC name (only the friendly-name part, not the address part). Returns a null on failure
const char *CkEmail_getDeliveryStatusInfo(HCkEmail cHandle, const char *fieldName);
If the email is a multipart/report, then it is a delivery status notification. This method can be used to get individual pieces of information from the message/delivery-status part of the email. This method should only be called if the IsMultipartReport method returns true.
The fieldName should be set a string such as "Final-Recipient", "Status", "Action", "Reporting-MTA", etc.
Reporting-MTA: dns; XYZ.abc.nl
Final-recipient: RFC822; someEmailAddr@doesnotexist123.nl
Action: failed
Status: 5.4.4
X-Supplementary-Info: < #5.4.4 smtp;554 5.4.4
SMTPSEND.DNS.NonExistentDomain; nonexistent domain>
Returns a null on failure
const char *CkEmail_getHeaderField(HCkEmail cHandle, const char *fieldName);
Returns the value of a header field. Returns a null on failure
const char *CkEmail_getHeaderFieldName(HCkEmail cHandle, long index);
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. Returns a null on failure
const char *CkEmail_getHeaderFieldValue(HCkEmail cHandle, long index);
Returns the value of the Nth header field. (Indexing begins at 0) The number of header fields can be obtained from the NumHeaderFields property. Returns a null on failure
const char *CkEmail_getHtmlBody(HCkEmail cHandle);
Returns the body having the "text/html" content type. Returns a null on failure
const char *CkEmail_getMime(HCkEmail cHandle);
Return the email as MIME text containing the email header, body (or bodies), related items (if any), and all attachments Returns a null on failure
const char *CkEmail_getPlainTextBody(HCkEmail cHandle);
Returns the email body having the "text/plain" content type. Returns a null on failure
const char *CkEmail_getRelatedContentID(HCkEmail cHandle, long index);
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 a null on failure
const char *CkEmail_getRelatedContentLocation(HCkEmail cHandle, int index);
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 a null on failure
const char *CkEmail_getRelatedContentType(HCkEmail cHandle, long index);
Returns the content-type of the Nth related content item in an email message. Returns a null on failure
const char *CkEmail_getRelatedFilename(HCkEmail cHandle, long index);
Returns the filename of a related item contained with the email. Related items are typically images and style-sheets embedded within HTML emails. Returns a null on failure
const char *CkEmail_getRelatedString(HCkEmail cHandle, long index, const char *charset);
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 a null on failure
const char *CkEmail_getRelatedStringCrLf(HCkEmail cHandle, long index, const char *charset);
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 a null on failure
const char *CkEmail_getReplacePattern(HCkEmail cHandle, long index);
Returns a replacement pattern previously defined for mail-merge operations. Returns a null on failure
const char *CkEmail_getReplaceString(HCkEmail cHandle, long index);
Returns a replacement string for a previously defined pattern/replacement string pair. (This is a mail-merge feature.) Returns a null on failure
const char *CkEmail_getReplaceString2(HCkEmail cHandle, const char *pattern);
Returns a replacement string for a previously defined pattern/replacement string pair. (This is a mail-merge feature.) Returns a null on failure
const char *CkEmail_getReport(HCkEmail cHandle, int index);
(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 a null on failure
const char *CkEmail_getTo(HCkEmail cHandle, long index);
Returns a "to" recipient's full email address. Returns a null on failure
const char *CkEmail_getToAddr(HCkEmail cHandle, long index);
Returns the Nth To address (only the address part, not the friendly-name part). Returns a null on failure
const char *CkEmail_getToName(HCkEmail cHandle, long index);
Returns the Nth To name (only the friendly-name part, not the address part). Returns a null on failure
const char *CkEmail_getXml(HCkEmail cHandle);
Convert the email object to an XML document in memory Returns a null on failure
const char *CkEmail_header(HCkEmail cHandle);
The complete MIME header of the email. Returns a null on failure
const char *CkEmail_language(HCkEmail cHandle);
A read-only property that identifies the primary language group for the email. Possible values are:
- "latin1" (for English and all Western European languages)
- "central" (for Central European languages such as Polish, Czech, Hungarian, etc.)
- "russian" (for Cyrillic languages)
- "greek"
- "turkish"
- "hebrew"
- "arabic"
- "baltic"
- "thai"
- "vietnamese"
- "chinese"
- "japanese"
- "korean"
- "unknown"
The language group determination is made soley on the subject and plain-text/HTML email bodies. Characters in the FROM, TO, CC, and other header fields are not considered.
The primary determining factor is the characters found in the Subject header field. For example, if an email contains Japanese in the Subject, but the body contains Russian characters, it will be considered "japanese". Returns a null on failure
const char *CkEmail_lastErrorHtml(HCkEmail cHandle);
Error information in HTML format for the last method called.Returns a null on failure
const char *CkEmail_lastErrorText(HCkEmail cHandle);
Error information in plain-text format for the last method called.Returns a null on failure
const char *CkEmail_lastErrorXml(HCkEmail cHandle);
Error information in XML format for the last method called.Returns a null on failure
const char *CkEmail_mailer(HCkEmail cHandle);
Identifies the email software that sent the email. Returns a null on failure
const char *CkEmail_pkcs7CryptAlg(HCkEmail cHandle);
When an email is sent encrypted (using PKCS7 public-key encryption), this selects the underlying symmetric encryption algorithm. Possible values are: "aes", "des", "3des", and "rc2". Returns a null on failure
const char *CkEmail_preferredCharset(HCkEmail cHandle);
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. Returns a null on failure
const char *CkEmail_qEncodeBytes(HCkEmail cHandle, const unsigned char *data, unsigned long dataLen, const char *charset);
Takes a byte array of multibyte (non-Unicode) data and returns a Unicode Q-Encoded string. Returns a null on failure
const char *CkEmail_qEncodeString(HCkEmail cHandle, const char *str, const char *charset);
Takes a Unicode string, converts it to the charset specified in the 2nd parameter, Q-Encodes the converted multibyte data, and returns the encoded Unicode string. Returns a null on failure
const char *CkEmail_replyTo(HCkEmail cHandle);
The email address to be used when a recipient replies. Returns a null on failure
const char *CkEmail_signedBy(HCkEmail cHandle);
If the email was received digitally signed, this property contains the details of the signer. Returns a null on failure
const char *CkEmail_signingHashAlg(HCkEmail cHandle);
Selects the underlying hash algorithm used when sending signed (PKCS7) email. Possible values are "sha1", "sha256", "sha384", "sha512", "md5", and "md2". Returns a null on failure
const char *CkEmail_subject(HCkEmail cHandle);
The email subject. Returns a null on failure
const char *CkEmail_uidl(HCkEmail cHandle);
This is the unique ID assigned by the POP3 server. Emails can be retrieved or deleted from the POP3 server via the UIDL. The header field for this property is "X-UIDL".
Important: Emails downloaded via the IMAP protocol do not have UIDL's. UIDL's are specific to the POP3 protocol. IMAP servers use UID's (notice the spelling difference -- "UIDL" vs. "UID"). An email downloaded via the Chilkat IMAP component will contain a "ckx-imap-uid" header field that contains the UID. This may be accessed via the GetHeaderField method. Returns a null on failure
|