Class Email
- All Implemented Interfaces:
AutoCloseable
Create, inspect, modify, secure, load, and save complete email messages.
Chilkat.Email represents a complete MIME email message,
including headers, sender and recipient fields, subject, plain-text and HTML
bodies, attachments, embedded HTML resources, attached messages, custom
headers, and security-related information such as S/MIME signing and
encryption status. It is the message object used throughout Chilkat when
composing, parsing, modifying, saving, sending, receiving, or processing
email.
Compose messages
Build email messages with sender, recipients, subject, text body, HTML body, reply-to fields, custom headers, and MIME structure.
Attachments and embedded content
Add, inspect, extract, remove, or save file attachments, embedded images, related HTML resources, and attached email messages.
Load and save MIME
Load email from MIME text, files, byte data, or strings, and save the message back to MIME, XML, files, or other supported forms.
Inspect received email
Read headers, addresses, dates, message IDs, body alternatives, attachments, encodings, and other fields from downloaded or parsed messages.
S/MIME security
Work with signed, encrypted, or signed-and-encrypted messages, including certificate-related information and security status.
Works with mail transports
Use Email objects with MailMan,
Imap, EmailBundle, and related Chilkat classes
for sending, receiving, downloading, and organizing mail.
Common pattern:
Use Chilkat.Email to represent and manipulate the message
itself. Use transport classes such as MailMan or
Imap to send, receive, fetch, or manage messages on mail
servers. After downloading or creating an email, use this class to inspect
headers, modify content, handle attachments, save MIME, or prepare the
message for further processing.
For an extended overview, see Email Class Overview.
</section>
Instances hold a native Chilkat object: close them with ChilkatObject.close() (try-with-resources) when
done; an unclosed instance is freed when it becomes unreachable.
- See Also:
- Online reference
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAttachmentBd(String filename, BinData binData, String contentType)Adds an attachment using the contents of aBinDataobject.voidaddAttachmentHeader(int index, String fieldName, String fieldValue)Adds or replaces a MIME header field in one of the email attachments.voidAdds a recipient to the blind carbon-copy (BCC) list.voidAdds a recipient to the carbon-copy list.voidaddEncryptCert(Cert cert)Allows for certificates to be explicitly specified for sending encrypted email to one or more recipients.addFileAttachment(String path)Adds a file as an attachment to the email.voidaddFileAttachment2(String path, String contentType)Same as, but the content type can be explicitly specified.addFileAttachment(String)voidaddHeaderField(String fieldName, String fieldValue)Any standard or non-standard (custom) header field can be added to the email with this method.voidaddHeaderField2(String fieldName, String fieldValue)This method is the same as, except that if the header field already exists, it is not replaced.addHeaderField(String, String)voidaddHtmlAlternativeBody(String body)Adds or replaces the HTML body representation of the email.voidaddiCalendarAlternativeBody(String icalContent, String methodName)Adds or replaces an iCalendar body as atext/calendaralternative.voidaddMultipleBcc(String commaSeparatedAddresses)Parses the mailbox list incommaSeparatedAddressesand appends the results to the blind carbon-copy (Bcc) recipient list.voidaddMultipleCC(String commaSeparatedAddresses)Parses the mailbox list incommaSeparatedAddressesand appends the results to the carbon-copy (Cc) recipient list.voidaddMultipleTo(String commaSeparatedAddresses)Parses the mailbox list incommaSeparatedAddressesand appends the results to the direct-recipient (To) list.voidaddPfxSourceBd(BinData bd, String password)Adds the PFX data inbdto the list of certificate and private-key sources used during decryption or signing.voidaddPfxSourceFile(String pfxFilePath, String pfxPassword)Adds the PFX file specified bypfxFilePathto the internal list of certificate and private-key sources used during decryption.voidAdds or replaces the plain-text body representation of the email.addRelatedBd(String filename, BinData binData)Adds a related item using the contents of aBinDataobject.voidaddRelatedBd2(BinData binData, String fileNameInHtml)Adds a related item using the binary data inbinData.addRelatedFile(String path)Adds the contents of the local file inpathas a related MIME resource and returns the generatedContent-ID.voidaddRelatedFile2(String filenameOnDisk, String filenameInHtml)Adds the local file infilenameOnDiskas a related MIME resource addressed byContent-Locationrather thanContent-ID.voidaddRelatedHeader(int index, String fieldName, String fieldValue)Adds or replaces a MIME header field in one of the email's related items.addRelatedString(String nameInHtml, String str, String charset)Adds a text-based related MIME resource, such as a style sheet, and returns the generatedContent-ID.voidaddRelatedString2(String fileNameInHtml, String content, String charset)Adds a related item to the email from an in-memory string.voidaddStringAttachment(String path, String content)Adds an attachment directly from a string in memory to the email.voidaddStringAttachment2(String path, String content, String charset)Adds a text attachment using the in-memory string incontent.voidAdds a recipient to thetolist.voidaesDecrypt(String password)Decrypts and restores an email message that was previously encrypted using.aesEncrypt(String)voidaesEncrypt(String password)Encrypts the email body, all alternative bodies, all message sub-parts, and attachments using 128-bit AES CBC encryption.voidappendToBody(String str)Appends a string to the plain-text body.voidapplyFixups(String fixups)Repairs selected MIME-formatting problems commonly found in email produced by other software.voidUnpacks an HTML email's body and its related items (images, style sheets, and the like) to the filesystem: each related part is written as a separate file, and the HTML is rewritten so those parts load as ordinary files instead ofcid:references.voidattachEmail(Email email)Attaches a copy ofemailto this email object.bEncodeString(String str, String charset)Converts the Unicode string instrto the charset specified bycharset, B-encodes the resulting multibyte data, and returns the encoded string.voidclear()Removes the current message content, including recipients, headers, body representations, attachments, related items, and embedded messages.voidclearBcc()Clears the list of blind carbon-copy recipients.voidclearCC()Clears the list of carbon-copy recipients.voidClears the internal list of explicitly specified certificates to be used for this encrypted email.voidclearTo()Clears the list oftorecipients.computeGlobalKey2(String encoding, boolean bFold)Computes a global unique key for the email.voidConverts images embedded inline within HTML to multipart/related MIME parts referenced from the HTML by CID.createTempMht(String inFilename)Prepares the email for display in a web browser and saves it as a temporary MHT (MIME HTML) file, returning the path to the file.voidRemoves all attachments from the email.voiddropRelatedItem(int index)A related item is typically an embedded image referenced from the HTML in the email via aCIDhyperlink.voidA related item is typically an embedded image referenced from the HTML in the email via aCIDhyperlink.voiddropSingleAttachment(int index)Removes the attachment at the zero-based index specified byindex.Generates a unique filename for this email.getAlternativeBody(int index)Returns the Nth alternative body.voidgetAlternativeBodyBd(int index, BinData binData)Returns the contents of the Nth alternative body tobinData.getAlternativeBodyByContentType(String contentType)Returns the alternative body byContent-Type, such astext/plain,text/html,text/xml, etc.getAlternativeContentType(int index)Returns the content type of the Nth alternative body.getAltHeaderField(int index, String fieldName)Returns the value of a header field within the Nth alternative body's MIME sub-part.voidgetAttachedEmail(int index, Email email)Copies the Nth embeddedmessage/rfc822MIME part intoemail.getAttachedMessageAttr(int index, String fieldName, String attrName)Returns a header field attribute value for the Nth attached (embedded) email.getAttachedMessageFilename(int index)Returns the filename of the Nth attached (embedded) email.getAttachmentAttr(int index, String fieldName, String attrName)Returns a header field attribute value from the header field of the Nth attachment.voidgetAttachmentBd(int index, BinData binData)Copies an attachment's binary data intobinData.getAttachmentContentID(int index)Returns the ContentID header field for the Nth attachment.getAttachmentContentType(int index)Returns theContent-Typeheader field for the Nth attachment.getAttachmentFilename(int index)Retrieves an attachment's filename.getAttachmentHeader(int attachIndex, String fieldName)Returns the value of a header field (by name) of an attachment.intgetAttachmentSize(int index)Returns the size, in bytes, of the attachment at the zero-based index specified byindex.getAttachmentString(int index, String charset)Returns the attachment at the zero-based index specified byindexas text.getAttachmentStringCrLf(int index, String charset)Retrieves an attachment's data as a String.getBcc(int index)Returns a blind carbon-copy recipient's full email address.getBccAddr(int index)Returns the Nth BCC address (only the address part, not the friendly-name part).getBccName(int index)Returns the Nth BCC name (only the friendly-name part, not the address part).getBody()Gets or sets the primary body of the email.getCC(int index)Returns a carbon-copy recipient's full email address.getCcAddr(int index)Returns the Nth CC address (only the address part, not the friendly-name part).getCcName(int index)Returns the Nth CC name (only the friendly-name part, not the address part).Represents the main charset of the email, such asutf-8,iso-8859-1,Shift_JIS,US-ASCII, etc.booleantrueif the email arrived encrypted and was successfully decrypted, otherwisefalse.getDeliveryStatusInfo(String fieldName)Returns a field from themessage/delivery-statuspart of a delivery-status notification.voidgetDigestEmail(int index, Email email)Returns inemailthe Nth digest email contained within a multipart/digest.voidgetDsnInfo(JsonObject json)If themethod indicates that the email isisMultipartReport()multipart/report, use this method to obtain the delivery-status information, including the final recipients, as JSON that is easy to parse.The date/time from theDateheader in the UTC/GMT timezone in RFC822 string form.If the email was received encrypted, this contains the details of the certificate used for encryption.Set this property to send an email to a list of recipients stored in a plain text file.getFrom()Contains the sender name and email address as they appear in theFromheader, such asJohn Smith <john.smith@mail.com>.The email address of the sender.The name of the sender.The complete MIME header of the email.getHeaderField(String fieldName)Returns the value of a header field.getHeaderFieldName(int index)Returns the name of the Nth header field.getHeaderFieldValue(int index)Returns the value of the Nth header field.Returns the body having thetext/htmlcontent type.voidgetHtmlBodySb(boolean inlineImageData, StringBuilder sb)Returns the body having thetext/htmlcontent type.longWhen email headers are downloaded from an IMAP server (using Chilkat IMAP), ackx-imap-uidheader field is added.Identifies the primary language group detected in the email subject and body text.The date/time found in theDateheader field returned in the local timezone in RFC822 string form.Identifies the email software that sent the email.getMime()Returns the email as RFC822/MIME text containing the headers, body representations, related items, and attachments.voidSerializes the complete RFC822/MIME message and appends the bytes tobindat.voidgetMimeSb(StringBuilder sb)Returns the email as MIME text containing the email header, body (or bodies), related items (if any), and all attachments.voidgetNthBinaryPartOfTypeBd(int index, String contentType, boolean inlineOnly, boolean excludeAttachments, BinData bd)Loadsbdwith the binary bytes of the Nth MIME sub-part matchingcontentType, which can be an exactContent-Typesuch asapplication/pdf, or a wildcardedContent-Typesuch asapplication/*, or*/*.getNthContentType(int index, String contentType, boolean inlineOnly, boolean excludeAttachments)Returns theContent-Typeof the Nth non-multipart MIME part matching the pattern incontentType.getNthTextPartOfType(int index, String contentType, boolean inlineOnly, boolean excludeAttachments)Returns the text content of the Nth non-multipart MIME part matching theContent-Typepattern incontentType.intThe number of body representations present in the email.intThe number of embedded emails represented bymessage/rfc822MIME parts.intThe number of ordinary attachments contained in the email.intThe number of blind carbon-copy email recipients.intgetNumCC()The number of carbon-copy email recipients.intReturns the number of days old from the current system date/time.intReturns the number of message/rfc822 parts contained within the multipart/digest enclosure.intThe number of header fields.intgetNumPartsOfType(String contentType, boolean inlineOnly, boolean excludeAttachments)Returns the number of non-multipart MIME parts matching theContent-Typepattern incontentType.intThe number of related MIME items present in the email.intReturns the number of replacement patterns previously set by calling themethod 1 or more times.setReplacePattern(String, String)intContains the number of report parts in amultipart/reportemail.intgetNumTo()The number of direct email recipients.Selects the hash algorithm used by OAEP padding when encrypting email with RSAES-OAEP.Selects the mask-generation function (MGF) hash algorithm used by OAEP padding when encrypting email with RSAES-OAEP.booleanSelects the RSA encryption scheme when encrypting email.booleanWhentrue(the default) the methods to save email attachments and related items will overwrite files if they already exist.When an email is sent encrypted (using PKCS#7 public-key encryption), this selects the underlying symmetric encryption algorithm.intWhen the email is sent encrypted using PKCS#7 public-key encryption, this selects the key length of the underlying symmetric encryption algorithm.Returns the email body having thetext/plaincontent type.Only applies when building an email with non-English characters where the charset is not explicitly set.booleanWhentrue, header fields added via theoraddHeaderField(String, String)methods are prepended to the top of the header as opposed to appended to the bottom.addHeaderField2(String, String)booleantrueif this email was originally received with encryption, otherwisefalse.booleantrueif this email was originally received with a digital signature, otherwisefalse.getRelatedAttr(int index, String fieldName, String attrName)Returns a header field attribute value from the header field of the Nth related item.getRelatedContentID(int index)Returns the content ID of a related item contained with the email.getRelatedContentLocation(int index)Returns theContent-Locationof a related item contained with the email.getRelatedContentType(int index)Returns theContent-Typeof the Nth related content item in an email message.getRelatedFilename(int index)Returns the filename of a related item contained with the email.getRelatedHeader(int index, String fieldName)Returns the value of a header field (by name) of a related item.getRelatedString(int index, String charset)Returns the text with CR line-endings of a related item contained with the email.getRelatedStringCrLf(int index, String charset)Returns the text with CRLF line-endings of a related item contained with the email.getReplacePattern(int index)Returns a replacement pattern previously defined for mail-merge operations.getReplaceString(int index)Returns a replacement string for a previously defined pattern/replacement string pair.getReplaceString2(String pattern)Returns a replacement string for a previously defined pattern/replacement string pair.Sets theReply-Toheader field to the specified email address such asjohn@example.com.getReport(int index)(See theproperty.) Returns the body content of the Nth report within a multipart/report email.getNumReports()booleanSet totrueif you want the email to request a return-receipt when received by the recipient.booleanSet totrueif this email should be sent encrypted.booleanSet totrueif this email should be sent with a digital signature.booleantrueif the email was received with one or more digital signatures, and if all the signatures were validated indicating that the email was not altered.If the email was received digitally signed, this property contains the fields of the certificate's SubjectDN.Selects the signature algorithm to be used when sending signed (PKCS#7) email.Selects the underlying hash algorithm used when sending signed (PKCS#7) email.intgetSize()The size in bytes of the email, including all parts and attachments.The email subject.getTo(int index)Returns atorecipient's full email address.getToAddr(int index)Returns the Nth To address (only the address part, not the friendly-name part).getToName(int index)Returns the Nth To name (only the friendly-name part, not the address part).getUidl()Contains the unique message identifier assigned by a POP3 server.This is a catch-all property to be used for uncommon needs.booleanApplies to themethod.unpackHtml(String, String, String)getXml()Convert the email object to an XML document in memorybooleanhasHeaderMatching(String fieldName, String valuePattern, boolean caseSensitive)Returnstruewhen the email contains a header field namedfieldNamewhose value matches the wildcard pattern invaluePattern.booleanReturnstrueif the email has an HTML body.booleanReturnstrueif the email has a plain-text body.booleanReturnstrueif the email is a multipart/report email.voidlastDecryptCert(Cert cert)Returns incertthe certificate used to decrypt this email.voidlastSignerCert(int index, Cert cert)Copies the certificate for the signer at the zero-based index specified byindexintocert.voidlinkedDomains(StringTable domains)Extracts domain names from hyperlinks in an HTML email.voidLoads a complete email from an.emlfile.voidLoads an email from a Chilkat XML email file.voidloadXmlString(String xmlStr)Loads an email from the Chilkat XML representation inxmlStr, typically obtained from.getXml()voidCopies the entire state of this email intodestEmail, including all message content, recipients, headers, body representations, attachments, related items, embedded messages, replacement patterns, certificates, certificate sources, and configuration properties.qEncodeString(String str, String charset)Converts the Unicode string instrto the charset specified bycharset, Q-encodes the resulting multibyte data, and returns the encoded string.voidremoveAttachedMessage(int idx)Removes the Nth message/rfc822 sub-part of the email.voidRemoves all message/rfc822 sub-parts of the email object.voidRemoves relative or absolute path information from attachment filenames stored in the MIME, leaving only each final filename component.voidremoveHeaderField(String fieldName)Removes by name all occurrences of a header field.voidRemoves the HTML body from the email (if an HTML body exists).voidRemoves the plain-text body from the email (if a plain-text body exists).voidsaveAllAttachments(String dirPath)Saves all attachments to the directory specified bydirPath.voidsaveAttachedFile(int index, String dirPath)Saves the attachment at the zero-based index specified byindexto the directory specified bydirPath.voidConvert this email object to EML and save it to a file.voidsaveRelatedItem(int index, String dirPath)Saves the related item at the zero-based index specified byindexto the directory specified bydirPath.voidConvert this email object to XML and save it to a file.voidsetAttachmentCharset(int index, String charset)Sets thecharsetparameter of theContent-Typeheader field for the attachment at the zero-based index specified byindex.voidsetAttachmentDisposition(int index, String disposition)Sets theContent-Dispositionvalue for the attachment at the zero-based index specified byindex.voidsetAttachmentFilename(int index, String filename)Changes the filename of the attachment at the zero-based index specified byindex.voidSets theBodyproperty; seegetBody().voidSets the main email body from the binary data inbd.voidsetCharset(String value)Sets theCharsetproperty; seegetCharset().voidsetDecryptCert(Cert cert)Allows for a certificate to be explicitly provided for decryption.voidsetDecryptCert2(Cert cert, PrivateKey key)Explicitly provides the certificate incertand the corresponding private key inkeyfor decryption.voidSets theDateheader field of the email to have the value of the date/time object provided.voidsetEdifactBody(String message, String name, String filename, String charset)Creates a typical email used to send EDIFACT messages.voidsetEmailDateStr(String value)Sets theEmailDateStrproperty; seegetEmailDateStr().voidsetEncryptCert(Cert cert)Sets the certificate incertas the explicit recipient encryption certificate.voidsetFileDistList(String value)Sets theFileDistListproperty; seegetFileDistList().voidSets theFromproperty; seegetFrom().voidsetFromAddress(String value)Sets theFromAddressproperty; seegetFromAddress().voidsetFromMimeBd(BinData bindat)Loads an email with the MIME stored in aBinDataobject.voidLoads an email with the MIME stored in aStringBuilderobject.voidsetFromMimeText(String mimeText)Loads the email from MIME text contained inmimeText, such as the contents of an.emlfile.voidsetFromName(String value)Sets theFromNameproperty; seegetFromName().voidsetFromXmlText(String xmlStr)Loads an email from an XML string.voidsetHtmlBody(String html)Sets the HTML body of an email.voidsetLocalDateStr(String value)Sets theLocalDateStrproperty; seegetLocalDateStr().voidSets theMailerproperty; seegetMailer().voidsetOaepHash(String value)Sets theOaepHashproperty; seegetOaepHash().voidsetOaepMgfHash(String value)Sets theOaepMgfHashproperty; seegetOaepMgfHash().voidsetOaepPadding(boolean value)Sets theOaepPaddingproperty; seegetOaepPadding().voidsetOverwriteExisting(boolean value)Sets theOverwriteExistingproperty; seegetOverwriteExisting().voidsetPkcs7CryptAlg(String value)Sets thePkcs7CryptAlgproperty; seegetPkcs7CryptAlg().voidsetPkcs7KeyLength(int value)Sets thePkcs7KeyLengthproperty; seegetPkcs7KeyLength().voidsetPreferredCharset(String value)Sets thePreferredCharsetproperty; seegetPreferredCharset().voidsetPrependHeaders(boolean value)Sets thePrependHeadersproperty; seegetPrependHeaders().voidsetRelatedFilename(int index, String path)Sets the filename for a related item within the email.voidsetReplacePattern(String pattern, String replaceString)Defines a mail-merge replacement pair.voidsetReplyTo(String value)Sets theReplyToproperty; seegetReplyTo().voidsetReturnReceipt(boolean value)Sets theReturnReceiptproperty; seegetReturnReceipt().voidsetSendEncrypted(boolean value)Sets theSendEncryptedproperty; seegetSendEncrypted().voidsetSendSigned(boolean value)Sets theSendSignedproperty; seegetSendSigned().voidsetSigningAlg(String value)Sets theSigningAlgproperty; seegetSigningAlg().voidsetSigningCert(Cert cert)Sets the certificate incertfor creating a digital signature.voidsetSigningCert2(Cert cert, PrivateKey key)Explicitly sets the certificate incertand the corresponding private key inkeyfor sending digitally signed email.voidsetSigningHashAlg(String value)Sets theSigningHashAlgproperty; seegetSigningHashAlg().voidsetSubject(String value)Sets theSubjectproperty; seegetSubject().voidsetTextBody(String bodyText, String contentType)Sets the body of the email and also sets theContent-Typeheader field ofcontentType.voidsetUncommonOptions(String value)Sets theUncommonOptionsproperty; seegetUncommonOptions().voidsetUnpackUseRelPaths(boolean value)Sets theUnpackUseRelPathsproperty; seegetUnpackUseRelPaths().voidCreates a new Delivery Status Notification (DSN) email in the format specified by RFC 3464.voidCreates an inline-forward email infwdEmailbased on this email.voidCreates a new MDN (Message Disposition Notification) email inmdnusing the format specified by RFC 3798.voidGenerates a reply email inreplywith updated header and body fields to enable sending as a reply.booleanuidlEquals(Email e)Returnstrueif this email's UIDL equals the UIDL of the email passed ine.voidunpackHtml(String unpackDir, String htmlFilename, String partsSubdir)Unpacks an HTML email into an HTML file and separate related files, such as images and style sheets.voidUnobfuscates emails by undoing what spammers do to obfuscate email.voidUnzips and replaces any Zip file attachments with the expanded contents.voiduseCertVault(XmlCertVault vault)Adds the XML certificate vault invaultto the object's internal certificate and private-key lookup sources for encryption, decryption, signing, and verification.voidzipAttachments(String zipFilename)Replaces all the attachments of an email with a single Zip file attachment having the filename specified.Methods inherited from class com.chilkatsoft.chilkat2.ChilkatObject
close, getDebugLogFilePath, getLastErrorHtml, getLastErrorText, getLastErrorXml, getLastMethodSuccess, getVerboseLogging, getVersion, isClosed, setDebugLogFilePath, setLastMethodSuccess, setVerboseLogging, toString
-
Constructor Details
-
Email
public Email()Creates a newEmailobject.
-
-
Method Details
-
getBody
Gets or sets the primary body of the email.When reading this property, an email containing both plain-text and HTML alternatives returns the HTML body. Use
orgetHtmlBody()to retrieve a specific representation, and usegetPlainTextBody()orhasHtmlBody()to determine which representations are present.hasPlainTextBody()When setting this property, Chilkat inspects the supplied content to determine the body type. If the content is recognized as HTML, the HTML body is set. Otherwise, the plain-text body is set. If the email contains both plain-text and HTML alternatives, the corresponding alternative is replaced and the other alternative is left unchanged.
For explicit control, use
,setTextBody(String, String),setHtmlBody(String), oraddPlainTextAlternativeBody(String).addHtmlAlternativeBody(String)- Returns:
- the value of the
Bodyproperty
-
setBody
Sets theBodyproperty; seegetBody().- Parameters:
value- the new value (notnull)
-
getCharset
Represents the main charset of the email, such asutf-8,iso-8859-1,Shift_JIS,US-ASCII, etc. This property can be empty if there is no explicit charset, such as for emails with only US-ASCII.Setting this property causes Chilkat to use the new charset in HTML and plain-text bodies, where possible. This can include updating the HTML META tag in HTML bodies to agree with the charset specified in the email header and also the byte representation of the HTML body in the email.
Chilkat stores text internally as Unicode. This property mainly controls how body text is converted to bytes and labeled when MIME is generated.
- Returns:
- the value of the
Charsetproperty
-
setCharset
Sets theCharsetproperty; seegetCharset().- Parameters:
value- the new value (notnull)
-
getDecrypted
public boolean getDecrypted()trueif the email arrived encrypted and was successfully decrypted, otherwisefalse. This property is only meaningful when theproperty is equal togetReceivedEncrypted()true.Check
first. A value ofgetReceivedEncrypted()falsecan mean either that the message was not encrypted or that decryption did not succeed.- Returns:
- the value of the
Decryptedproperty (read-only)
-
getEmailDateStr
The date/time from theDateheader in the UTC/GMT timezone in RFC822 string form.For example:
Fri, 10 Jul 2026 20:15:30 GMT.Setting this property updates the email's
Dateheader.- Returns:
- the value of the
EmailDateStrproperty
-
setEmailDateStr
Sets theEmailDateStrproperty; seegetEmailDateStr().- Parameters:
value- the new value (notnull)
-
getEncryptedBy
If the email was received encrypted, this contains the details of the certificate used for encryption.This property is meaningful only when
isgetReceivedEncrypted()true. To obtain a certificate object rather than descriptive text, useorGetEncryptedByCert.lastDecryptCert(Cert)- Returns:
- the value of the
EncryptedByproperty (read-only)
-
getFileDistList
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 aCKX-FileDistListheader field to the email.MailMantreats header fields beginning withCKX-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 aCKX-FileDistListheader field,MailManwill 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 theMailMan.SendIndividualproperty.)The distribution-list file is read when the message is sent, so the file must still exist and be accessible at that time. This feature is separate from the recipients stored in the normal To, Cc, and Bcc lists.
- Returns:
- the value of the
FileDistListproperty
-
setFileDistList
Sets theFileDistListproperty; seegetFileDistList().- Parameters:
value- the new value (notnull)
-
getFrom
Contains the sender name and email address as they appear in theFromheader, such asJohn Smith <john.smith@mail.com>.If the sender identified by the
Senderheader field should differ from the visibleFromaddress, callto set theaddHeaderField(String, String)Senderheader field.From,, andgetFromName()are different views of the same MIMEgetFromAddress()Fromheader.- Returns:
- the value of the
Fromproperty
-
setFrom
Sets theFromproperty; seegetFrom().- Parameters:
value- the new value (notnull)
-
getFromAddress
The email address of the sender.Changing this property updates the address portion of the MIME
Fromheader while preserving the sender name when possible.- Returns:
- the value of the
FromAddressproperty
-
setFromAddress
Sets theFromAddressproperty; seegetFromAddress().- Parameters:
value- the new value (notnull)
-
getFromName
The name of the sender.Changing this property updates the display-name portion of the MIME
Fromheader while preserving the email address.- Returns:
- the value of the
FromNameproperty
-
setFromName
Sets theFromNameproperty; seegetFromName().- Parameters:
value- the new value (notnull)
-
getHeader
The complete MIME header of the email.This is the header generated from the current in-memory email object. Modify individual fields through the corresponding properties or header methods rather than attempting to assign to this read-only property.
- Returns:
- the value of the
Headerproperty (read-only)
-
getLanguage
Identifies the primary language group detected in the email subject and body text.latin1— English and Western European languagescentral— Central European languages, such as Polish, Czech, and Hungarianrussian— Cyrillic languagesgreek,turkish,hebrew,arabic,thai, orvietnamesechinese,japanese, orkoreandevanagari,bengali,gurmukhi,gujarati,oriya,tamil,telugu,kannada,malayalam, orsinhalalao,tibetan,myanmar, orgeorgianunknown
Characters in address and other MIME header fields are not considered. The
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 asgetSubject()japanese.The classification is based on the Unicode blocks containing the characters found in the email.
This is a character-based heuristic intended to help choose encodings. It is not taken from the MIME
Content-Languageheader and should not be treated as formal language detection.- Returns:
- the value of the
Languageproperty (read-only)
-
getLocalDateStr
The date/time found in theDateheader field returned in the local timezone in RFC822 string form.For example:
Fri, 10 Jul 2026 15:15:30 -0500.Setting this property updates the email's
Dateheader. Usewhen a native local date/time value is preferred.LocalDate- Returns:
- the value of the
LocalDateStrproperty
-
setLocalDateStr
Sets theLocalDateStrproperty; seegetLocalDateStr().- Parameters:
value- the new value (notnull)
-
getMailer
Identifies the email software that sent the email.This corresponds to the MIME
X-Mailerheader, which is informational and may be absent or supplied by the sending application.- Returns:
- the value of the
Mailerproperty
-
setMailer
Sets theMailerproperty; seegetMailer().- Parameters:
value- the new value (notnull)
-
getNumAlternatives
public int getNumAlternatives()The number of body representations present in the email. A representation may be plain text, HTML, iCalendar, or another body format.A normal email with one body generally returns
1. Amultipart/alternativeemail returns the number of alternatives contained in that enclosure. A newly created or clearedEmailobject also reports1for its default empty text body.An alternative is one of multiple representations of the same email body, such as plain text and HTML, within a
multipart/alternativemessage.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/pdfIn this example, the
text/plainpart and themultipart/relatedpart are alternatives. Themultipart/relatedpart contains the HTML body and an inline image, while the PDF is a separate attachment.Alternative indexes used by methods such as
are zero-based.getAlternativeBody(int)- Returns:
- the value of the
NumAlternativesproperty (read-only)
-
getNumAttachedMessages
public int getNumAttachedMessages()The number of embedded emails represented bymessage/rfc822MIME parts.Some mail clients attach a forwarded message as a complete nested email. These parts are counted separately from ordinary attachments and related items.
Attached-message indexes are zero-based. Use
to copy an embedded message into anothergetAttachedEmail(int, Email)Emailobject. The deprecatedmethod also returns an independent copy.GetAttachedMessage- Returns:
- the value of the
NumAttachedMessagesproperty (read-only)
-
getNumAttachments
public int getNumAttachments()The number of ordinary attachments contained in the email.Attachment indexes are zero-based. Related resources contained within a
multipart/relatedenclosure are counted separately by, and embeddedgetNumRelatedItems()message/rfc822emails are counted by.getNumAttachedMessages()A MIME part outside a
multipart/relatedenclosure may be classified as an attachment even when it does not explicitly containContent-Disposition: attachment. MIME structure, content type, and disposition are considered together.Note: If an email is downloaded from an
Imapserver without attachment data, use theImapmethod that reports attachment information for the server message. This property reports only the attachments actually present in the currentEmailobject.- Returns:
- the value of the
NumAttachmentsproperty (read-only)
-
getNumBcc
public int getNumBcc()The number of blind carbon-copy email recipients.Bcc recipient indexes are zero-based and can be inspected with
,getBcc(int), andgetBccAddr(int).getBccName(int)- Returns:
- the value of the
NumBccproperty (read-only)
-
getNumCC
public int getNumCC()The number of carbon-copy email recipients.Cc recipient indexes are zero-based and can be inspected with
,getCC(int), andgetCcAddr(int).getCcName(int)- Returns:
- the value of the
NumCCproperty (read-only)
-
getNumDaysOld
public int getNumDaysOld()Returns the number of days old from the current system date/time. The email's date is obtained from theDateheader field. If theDateheader field is missing, or invalid, then -9999 is returned. A negative number may be returned if theDateheader field contains a future date/time. (However, -9999 represents an error condition.)The calculation uses the parsed
Dateheader, not the time when the message was downloaded or loaded into the object.- Returns:
- the value of the
NumDaysOldproperty (read-only)
-
getNumDigests
public int getNumDigests()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. Themethod is called to get the Nth digest as an email object.GetDigestDigest indexes are zero-based. Use
to retrieve an individual message from the digest.getDigestEmail(int, Email)- Returns:
- the value of the
NumDigestsproperty (read-only)
-
getNumHeaderFields
public int 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.)Repeated header fields are counted separately. Use
andgetHeaderFieldName(int)to enumerate them by zero-based index.getHeaderFieldValue(int)- Returns:
- the value of the
NumHeaderFieldsproperty (read-only)
-
getNumRelatedItems
public int getNumRelatedItems()The number of related MIME items present in the email. Related items are resources, such as images or style sheets, contained with an HTML body in amultipart/relatedenclosure.Related-item indexes are zero-based. These parts are distinct from ordinary attachments and are commonly referenced by HTML using a
cid:URL or aContent-Locationvalue.Classification is based primarily on the MIME structure. An inline disposition or
Content-IDalone does not necessarily make a part a related item if it is outside the relevantmultipart/relatedenclosure.- Returns:
- the value of the
NumRelatedItemsproperty (read-only)
-
getNumReplacePatterns
public int getNumReplacePatterns()Returns the number of replacement patterns previously set by calling themethod 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.setReplacePattern(String, String)Pattern indexes are zero-based. Replacement patterns are retained in the email object and applied later during supported mail-merge sending operations.
- Returns:
- the value of the
NumReplacePatternsproperty (read-only)
-
getNumReports
public int getNumReports()Contains the number of report parts in amultipart/reportemail.A MIME part is counted as a report when its
Content-Typeismessage/*, except formessage/rfc822, or when itsContent-Typeistext/rfc822-headers. Amessage/rfc822part is treated as an attached email and is counted by.getNumAttachedMessages()Use
to retrieve the body of each report part.getReport(int)Report indexes are zero-based. Use
to retrieve the content of an individual report part.getReport(int)- Returns:
- the value of the
NumReportsproperty (read-only)
-
getNumTo
public int getNumTo()The number of direct email recipients.To-recipient indexes are zero-based and can be inspected with
,getTo(int), andgetToAddr(int).getToName(int)- Returns:
- the value of the
NumToproperty (read-only)
-
getOaepHash
Selects the hash algorithm used by OAEP padding when encrypting email with RSAES-OAEP. Valid values aresha1,sha256,sha384, andsha512. The default issha256.This property is used only when
isgetOaepPadding()true.- Returns:
- the value of the
OaepHashproperty
-
setOaepHash
Sets theOaepHashproperty; seegetOaepHash().- Parameters:
value- the new value (notnull)
-
getOaepMgfHash
Selects the mask-generation function (MGF) hash algorithm used by OAEP padding when encrypting email with RSAES-OAEP. Valid values aresha1,sha256,sha384, andsha512. The default issha256.This property is used only when
isgetOaepPadding()true. Some recipients require the MGF hash to match.getOaepHash()- Returns:
- the value of the
OaepMgfHashproperty
-
setOaepMgfHash
Sets theOaepMgfHashproperty; seegetOaepMgfHash().- Parameters:
value- the new value (notnull)
-
getOaepPadding
public boolean getOaepPadding()Selects the RSA encryption scheme when encrypting email. The default value isfalse, which selects RSAES_PKCS1-V1_5. When set totrue, RSAES_OAEP is used.This affects the RSA key-encryption step used for S/MIME encryption; it does not change the symmetric content-encryption algorithm selected by
.getPkcs7CryptAlg()- Returns:
- the value of the
OaepPaddingproperty
-
setOaepPadding
public void setOaepPadding(boolean value)Sets theOaepPaddingproperty; seegetOaepPadding().- Parameters:
value- the new value
-
getOverwriteExisting
public boolean getOverwriteExisting()Whentrue(the default) the methods to save email attachments and related items will overwrite files if they already exist. Whenfalse, the methods that save email attachments and related items will append a string of 4 characters to create a unique filename if a file already exists. The filename of the attachment (or related item) within the email object is updated and can be retrieved by the program to determine the actual file(s) created.This setting applies only when attachments or related items are written to the filesystem. When
falseand a name collision occurs during a save operation, Chilkat chooses a unique filename and updates the corresponding filename stored in the email object.- Returns:
- the value of the
OverwriteExistingproperty
-
setOverwriteExisting
public void setOverwriteExisting(boolean value)Sets theOverwriteExistingproperty; seegetOverwriteExisting().- Parameters:
value- the new value
-
getPkcs7CryptAlg
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, andrc2. The default value isaes.Note: The
aes-gcmoption was added in Chilkat v10.0.0This setting is used when S/MIME encryption is generated, typically after
is set togetSendEncrypted()trueand recipient encryption certificates have been supplied.- Returns:
- the value of the
Pkcs7CryptAlgproperty
-
setPkcs7CryptAlg
Sets thePkcs7CryptAlgproperty; seegetPkcs7CryptAlg().- Parameters:
value- the new value (notnull)
-
getPkcs7KeyLength
public int getPkcs7KeyLength()When the email is sent encrypted using PKCS#7 public-key encryption, this selects the key length of the underlying symmetric encryption algorithm. The default value is128.The allowed values depend on
:getPkcs7CryptAlg()- For
aes, use128,192, or256. - For
3des, use192. - For
des, use40. - For
rc2, use40,56,64, or128.
An unsupported algorithm and key-length combination causes the encryption operation to fail.
- Returns:
- the value of the
Pkcs7KeyLengthproperty
- For
-
setPkcs7KeyLength
public void setPkcs7KeyLength(int value)Sets thePkcs7KeyLengthproperty; seegetPkcs7KeyLength().- Parameters:
value- the new value
-
getPreferredCharset
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 theproperty). The default charset chosen for each language is:getCharset()Chinese:
gb2312
Japanese:shift_JIS
Korean:ks_c_5601-1987
Thai:windows-874
All others:iso-8859-*This allows for charsets such as iso-2022-jp to be chosen instead of the default. If the preferred charset does not apply to the situation, it is not used. For example, if the preferred charset is iso-2022-jp, but the email contains Greek characters, then the preferred charset is ignored.
This is a preference, not a forced conversion. It is ignored when the message already specifies a charset or when the requested charset cannot represent the email text.
- Returns:
- the value of the
PreferredCharsetproperty
-
setPreferredCharset
Sets thePreferredCharsetproperty; seegetPreferredCharset().- Parameters:
value- the new value (notnull)
-
getPrependHeaders
public boolean getPrependHeaders()Whentrue, header fields added via theoraddHeaderField(String, String)methods are prepended to the top of the header as opposed to appended to the bottom. The default value isaddHeaderField2(String, String)false.This affects header fields added after the property is set. It does not reorder fields that are already present.
- Returns:
- the value of the
PrependHeadersproperty
-
setPrependHeaders
public void setPrependHeaders(boolean value)Sets thePrependHeadersproperty; seegetPrependHeaders().- Parameters:
value- the new value
-
getReceivedEncrypted
public boolean getReceivedEncrypted()trueif this email was originally received with encryption, otherwisefalse.This records how the message was originally received. It remains useful after successful automatic decryption, when the visible body is already the decrypted content.
- Returns:
- the value of the
ReceivedEncryptedproperty (read-only)
-
getReceivedSigned
public boolean getReceivedSigned()trueif this email was originally received with a digital signature, otherwisefalse.This records whether the original message contained one or more digital signatures. Use
to determine whether the signed content verified successfully.getSignaturesValid()- Returns:
- the value of the
ReceivedSignedproperty (read-only)
-
getReplyTo
Sets theReply-Toheader field to the specified email address such asjohn@example.com. TheReply-Toheader automatically defaults to theemail address. You would only set this property if you wish for thegetFrom()Reply-Toemail address to be different from theaddress.getFrom()There is usually only a single
Reply-Toemail address. If multipleReply-Toaddresses are needed, then set with a comma-separated list of email addresses such asjohn@example.com, mary@somewhere.com.This changes the MIME
Reply-Toheader only; it does not change the SMTP envelope sender or the visibleFromheader.- Returns:
- the value of the
ReplyToproperty
-
setReplyTo
Sets theReplyToproperty; seegetReplyTo().- Parameters:
value- the new value (notnull)
-
getReturnReceipt
public boolean getReturnReceipt()Set totrueif you want the email to request a return-receipt when received by the recipient. The default value isfalse.Setting this property causes the
Disposition-Notification-Toemail header to be added when the email is sent.A return receipt is only a request. The recipient's mail client or server may ignore it, and a receipt is not proof that the message was read by a person.
- Returns:
- the value of the
ReturnReceiptproperty
-
setReturnReceipt
public void setReturnReceipt(boolean value)Sets theReturnReceiptproperty; seegetReturnReceipt().- Parameters:
value- the new value
-
getSendEncrypted
public boolean getSendEncrypted()Set totrueif this email should be sent encrypted. The default value isfalse.Encryption requires one or more recipient certificates, supplied with methods such as
oraddEncryptCert(Cert). Setting this property alone does not provide a certificate.setEncryptCert(Cert)- Returns:
- the value of the
SendEncryptedproperty
-
setSendEncrypted
public void setSendEncrypted(boolean value)Sets theSendEncryptedproperty; seegetSendEncrypted().- Parameters:
value- the new value
-
getSendSigned
public boolean getSendSigned()Set totrueif this email should be sent with a digital signature. The default value isfalse.Signing requires a certificate with access to its private key, supplied with
orsetSigningCert(Cert).setSigningCert2(Cert, PrivateKey)Note: Please be aware of the Apple Mail bug explained in the webpage at the link below.
- Returns:
- the value of the
SendSignedproperty
-
setSendSigned
public void setSendSigned(boolean value)Sets theSendSignedproperty; seegetSendSigned().- Parameters:
value- the new value
-
getSignaturesValid
public boolean getSignaturesValid()trueif 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 tofalse. (This property is only meaningful when theproperty is equal togetReceivedSigned()true.)This indicates cryptographic integrity of the signed content. Applications that also require certificate trust should separately examine the signer certificate and its chain.
- Returns:
- the value of the
SignaturesValidproperty (read-only)
-
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=, andCN=, preceding each value.This is intended for display or diagnostics. Use
when the signer certificate itself is needed.lastSignerCert(int, Cert)- Returns:
- the value of the
SignedByproperty (read-only)
-
getSigningAlg
Selects the signature algorithm to be used when sending signed (PKCS#7) email. The default value isPKCS1-v1_5. This can be set toRSASSA-PSS(or simplypss) to use the RSASSA-PSS signature scheme.Note: This property only applies when signing with an RSA private key. It does not apply for ECC or DSA private keys.
This setting is used only for RSA signing. The selected scheme must also be supported by the private key provider.
- Returns:
- the value of the
SigningAlgproperty
-
setSigningAlg
Sets theSigningAlgproperty; seegetSigningAlg().- Parameters:
value- the new value (notnull)
-
getSigningHashAlg
Selects the underlying hash algorithm used when sending signed (PKCS#7) email. Possible values aresha1,sha256,sha384,sha512,md5, andmd2. The default issha1.This property controls the message-digest algorithm placed in the signature. It is used only when a signed message is generated.
- Returns:
- the value of the
SigningHashAlgproperty
-
setSigningHashAlg
Sets theSigningHashAlgproperty; seegetSigningHashAlg().- Parameters:
value- the new value (notnull)
-
getSize
public int 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.
This value describes the email data currently present in the object. It should not be used as the server-reported full message size when only a partial message was downloaded.
- Returns:
- the value of the
Sizeproperty (read-only)
-
getSubject
The email subject.This property reads or writes the MIME
Subjectheader. Chilkat performs the required MIME header encoding when the subject contains non-ASCII characters.- Returns:
- the value of the
Subjectproperty
-
setSubject
Sets theSubjectproperty; seegetSubject().- Parameters:
value- the new value (notnull)
-
getUidl
Contains the unique message identifier assigned by a POP3 server. The value is also represented by theX-UIDLheader field.Important: UIDLs are specific to POP3. IMAP uses UIDs instead. An email downloaded through
Chilkat.Imapstores its IMAP identifier in theckx-imap-uidheader. Theckx-imap-isUidheader containsYESwhen that value is an IMAP UID, orNOwhen it is a mailbox sequence number.A UIDL identifies a POP3 message within the server's mailbox and is normally used to avoid downloading the same message repeatedly.
- Returns:
- the value of the
Uidlproperty (read-only)
-
getUncommonOptions
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 theBccMIME header for BCC email addresses. Note: TheNoBccHeaderkeyword must be present before callingoraddBcc(String, String)addMultipleBcc(String)NO_FORMAT_FLOWED- Don't automatically addformat=flowedto anyContent-Typeheader.
Leave this property empty unless a documented compatibility option is specifically required. Unrecognized keywords should not be assumed to have any effect.
- Returns:
- the value of the
UncommonOptionsproperty
-
setUncommonOptions
Sets theUncommonOptionsproperty; seegetUncommonOptions().- Parameters:
value- the new value (notnull)
-
getUnpackUseRelPaths
public boolean getUnpackUseRelPaths()Applies to themethod. WhenunpackHtml(String, String, String)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 istrue.Relative paths are usually preferable when the unpacked HTML directory will be moved or deployed as a unit. Absolute paths can be useful for immediate local viewing.
- Returns:
- the value of the
UnpackUseRelPathsproperty
-
setUnpackUseRelPaths
public void setUnpackUseRelPaths(boolean value)Sets theUnpackUseRelPathsproperty; seegetUnpackUseRelPaths().- Parameters:
value- the new value
-
addAttachmentBd
Adds an attachment using the contents of aBinDataobject. IfcontentTypeis empty, then theContent-Typewill be inferred fromfilenameextension.filenameis the filename stored in MIME, not a filesystem path. The bytes are taken frombinData.- Parameters:
filename- thefilenameargument (notnull)binData- thebinDataargument (notnull)contentType- thecontentTypeargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
addAttachmentHeader
Adds or replaces a MIME header field in one of the email attachments. If the header field does not exist, it is added. Otherwise it is replaced.Indexing:
indexis zero-based and must identify an existing attachment. This changes the attachment MIME header in the current email object; it does not modify the original source file.- Parameters:
index- theindexargumentfieldName- thefieldNameargument (notnull)fieldValue- thefieldValueargument (notnull)
-
addBcc
Adds a recipient to the blind carbon-copy (BCC) list.emailAddressis required;friendlyNameis 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
BCCheader before delivering the message to regular recipients. TheNoBccHeaderkeyword can be used into prevent BCC email addresses in the MIME passed to the SMTP server. If your application specifiesgetUncommonOptions()NoBccHeader, do so before adding BCC addresses.The recipient is added to the in-memory message only. The message is not transmitted until it is passed to a sending method of
MailMan.- Parameters:
friendlyName- thefriendlyNameargument (notnull)emailAddress- theemailAddressargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
addCC
Adds a recipient to the carbon-copy list.emailAddressis required, butfriendlyNamemay be empty.To add multiple CC recipients, call this method once per recipient.
The recipient is added to the in-memory message only. Use
and the Cc getter methods to inspect the resulting list.getNumCC()- Parameters:
friendlyName- thefriendlyNameargument (notnull)emailAddress- theemailAddressargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
addEncryptCert
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. Themethod may be called to clear the list of explicitly-specified certificates.clearEncryptCerts()Note: It is possible to send encrypted email without explicitly specifying the certificates. On Windows, the registry-based Current-User and Local-Machine certificate stores are automatically searched for certificates matching each recipient in the To, CC, and BCC lists. On macOS, the Keychain is automatically searched for matching recipient certificates.
Note: The
method is equivalent to callingsetEncryptCert(Cert)followed by AddEncryptCert.clearEncryptCerts()Use this method when encrypting for multiple recipients: add each recipient certificate separately. For a single explicitly selected certificate,
may be simpler.setEncryptCert(Cert)- Parameters:
cert- thecertargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
addFileAttachment
Adds a file as an attachment to the email. Returns the MIMEContent-Typeof the attachment, which is inferred based on the filename extension.pathis a local filesystem path. The file is read and incorporated into the current email object, and the attachment filename placed in MIME is derived frompath.- Parameters:
path- thepathargument (notnull)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
addFileAttachment2
Same as, but the content type can be explicitly specified.addFileAttachment(String)Use this form when filename-based MIME type inference is unsuitable.
contentTypeshould be a MIME media type such asapplication/octet-stream.- Parameters:
path- thepathargument (notnull)contentType- thecontentTypeargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
addHeaderField
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 withCKX-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
(see below).addHeaderField2(String, String)This changes the MIME header stored in the current email object. It does not change the SMTP envelope, except where another component explicitly interprets a particular header.
- Parameters:
fieldName- thefieldNameargument (notnull)fieldValue- thefieldValueargument (notnull)
-
addHeaderField2
This method is the same as, except that if the header field already exists, it is not replaced. A duplicate header will be added.addHeaderField(String, String)Use this method for headers that may legally occur more than once, such as
Received. For a single-valued field that should be replaced, use.addHeaderField(String, String)- Parameters:
fieldName- thefieldNameargument (notnull)fieldValue- thefieldValueargument (notnull)
-
addHtmlAlternativeBody
Adds or replaces the HTML body representation of the email.If no HTML alternative exists, one is added. If an HTML alternative already exists, it is replaced rather than duplicated. Repeated calls therefore leave at most one HTML alternative.
When paired with
, Chilkat creates aaddPlainTextAlternativeBody(String)multipart/alternativebody so mail clients can choose the representation they support. Usewhen a multipart alternative is not needed.setHtmlBody(String)- Parameters:
body- thebodyargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
addMultipleBcc
Parses the mailbox list incommaSeparatedAddressesand appends the results to the blind carbon-copy (Bcc) recipient list.Recipients may be separated by commas or semicolons. Each item may be a bare address or a mailbox with a display name. Quoted display names may contain commas.
Empty items are ignored. Duplicate addresses are retained.
Note: Before v11.0.0, BCC addresses were not added to the MIME header. Starting in v11.0.0, BCC addresses are included in the MIME header. Most email servers remove the
Bccheader before delivering the message to regular recipients. To omit BCC addresses from generated MIME, place theNoBccHeaderkeyword inbefore adding BCC recipients.getUncommonOptions()- Parameters:
commaSeparatedAddresses- thecommaSeparatedAddressesargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
addMultipleCC
Parses the mailbox list incommaSeparatedAddressesand appends the results to the carbon-copy (Cc) recipient list.Recipients may be separated by commas or semicolons. Each item may be a bare address or a mailbox with a display name. Quoted display names may contain commas.
Empty items are ignored. Duplicate addresses are retained.
- Parameters:
commaSeparatedAddresses- thecommaSeparatedAddressesargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
addMultipleTo
Parses the mailbox list incommaSeparatedAddressesand appends the results to the direct-recipient (To) list.Recipients may be separated by commas or semicolons. Each item may be a bare address or a mailbox with a display name. Quoted display names may contain commas.
Empty items are ignored. Duplicate addresses are retained.
- Parameters:
commaSeparatedAddresses- thecommaSeparatedAddressesargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
addPfxSourceBd
Adds the PFX data inbdto the list of certificate and private-key sources used during decryption or signing.passwordcontains the PFX password.Call this method once for each additional PFX source.
The PFX data becomes a lookup source for subsequent cryptographic operations by this object. Adding it does not immediately decrypt or sign the message.
- Parameters:
bd- thebdargument (notnull)password- thepasswordargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
addPfxSourceFile
Adds the PFX file specified bypfxFilePathto the internal list of certificate and private-key sources used during decryption.pfxPasswordcontains the PFX password.Call this method once for each additional PFX file. On Windows, Chilkat automatically searches the system certificate stores. On macOS, Chilkat automatically searches the Keychain. Therefore, explicitly adding a PFX source is often unnecessary when the required certificate and private key are already installed.
The PFX file becomes a certificate source for later operations performed by this email object. The file must be readable when this method is called.
- Parameters:
pfxFilePath- thepfxFilePathargument (notnull)pfxPassword- thepfxPasswordargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
addPlainTextAlternativeBody
Adds or replaces the plain-text body representation of the email.If no plain-text alternative exists, one is added. If a plain-text alternative already exists, it is replaced rather than duplicated. Repeated calls therefore leave at most one plain-text alternative.
When paired with
, Chilkat creates aaddHtmlAlternativeBody(String)multipart/alternativebody so text-only clients have a suitable representation. Usewhen a multipart alternative is not needed.setTextBody(String, String)- Parameters:
body- thebodyargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
addRelatedBd
Adds a related item using the contents of aBinDataobject. Returns theContent-IDfor the newly added related item.The returned
Content-IDcan be used in the HTML body ascid:returnedContentId.- Parameters:
filename- thefilenameargument (notnull)binData- thebinDataargument (notnull)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
addRelatedBd2
Adds a related item using the binary data inbinData.fileNameInHtmlspecifies the filename, path, or URL used by the corresponding HTML reference, such as animgelement'ssrcattribute.This form is useful when the HTML already contains a filename, URL, or path reference that Chilkat should associate with the new related MIME part.
- Parameters:
binData- thebinDataargument (notnull)fileNameInHtml- thefileNameInHtmlargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
addRelatedFile
Adds the contents of the local file inpathas a related MIME resource and returns the generatedContent-ID.The returned value is the bare
Content-ID. It does not include angle brackets or thecid:prefix. For example, if the method returnsCID-123@example, the HTML reference iscid:CID-123@example.This method does not modify the HTML body. The application must add or update the corresponding
cid:reference itself.The file becomes a related MIME resource rather than an ordinary attachment.
- Parameters:
path- thepathargument (notnull)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
addRelatedFile2
Adds the local file infilenameOnDiskas a related MIME resource addressed byContent-Locationrather thanContent-ID.filenameInHtmlbecomes the related item's MIME filename andContent-Locationvalue. It should match the filename, path, or URL already used by the corresponding HTML reference, such as animgelement'ssrcattribute.This method does not generate a
Content-IDand does not modify the HTML body. The HTML must already refer tofilenameInHtml.Note: Outlook.com may fail to display embedded images when
filenameInHtmlcontains a path. For best compatibility, use only a filename when targeting Outlook.com.- Parameters:
filenameOnDisk- thefilenameOnDiskargument (notnull)filenameInHtml- thefilenameInHtmlargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
addRelatedHeader
Adds or replaces a MIME header field in one of the email's related items. If the header field does not exist, it is added. Otherwise it is replaced.Indexing:
indexis zero-based and must identify an existing related item. The change applies to the related item's MIME sub-header.- Parameters:
index- theindexargumentfieldName- thefieldNameargument (notnull)fieldValue- thefieldValueargument (notnull)
-
addRelatedString
Adds a text-based related MIME resource, such as a style sheet, and returns the generatedContent-ID.nameInHtmlis the MIME filename or resource name,strcontains the text content, andcharsetspecifies the charset used to encode that content.The returned value is the bare
Content-ID. It does not include angle brackets or thecid:prefix. This method does not modify the HTML body; the application must add or update the correspondingcid:reference itself.- Parameters:
nameInHtml- thenameInHtmlargument (notnull)str- thestrargument (notnull)charset- thecharsetargument (notnull)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
addRelatedString2
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.fileNameInHtmlshould be set to the filename used in an HTMLimgtag'ssrcattribute, or to the URL referenced by an HTMLlinktag for a style sheet.contentcontains the Unicode text to add.charsetspecifies the charset to whichcontentis converted before the MIME part is created, such asiso-8859-1,utf-8, orShift_JIS.The resource is added as related content, not as a normal file attachment.
- Parameters:
fileNameInHtml- thefileNameInHtmlargument (notnull)content- thecontentargument (notnull)charset- thecharsetargument (notnull)
-
addStringAttachment
Adds an attachment directly from a string in memory to the email.pathsupplies the filename placed in MIME, not a file to be read.contentis the text content that becomes the attachment body.- Parameters:
path- thepathargument (notnull)content- thecontentargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
addStringAttachment2
Adds a text attachment using the in-memory string incontent.pathspecifies the attachment filename; it is not a path to an existing local file.charsetspecifies the charset used to encode the string before it is added to the email.Note:
charsetmay begin withbom-orno-bom-to require or suppress a byte-order mark for encodings such as UTF-8 or UTF-16. Examples includebom-utf-8andno-bom-utf-8.This method is appropriate for text data already held in memory. For arbitrary binary bytes, use a
BinData- or byte-based attachment method instead.- Parameters:
path- thepathargument (notnull)content- thecontentargument (notnull)charset- thecharsetargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
addTo
Adds a recipient to thetolist.emailAddressis required, butfriendlyNamemay be empty. Emails that have noTorecipients will be sent to _LT_undisclosed-recipients_GT_.To add multiple recipients, call this method once per TO recipient.
The recipient is added to the current in-memory message. Use
and the To getter methods to inspect the resulting list.getNumTo()- Parameters:
friendlyName- thefriendlyNameargument (notnull)emailAddress- theemailAddressargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
addiCalendarAlternativeBody
Adds or replaces an iCalendar body as atext/calendaralternative.If an iCalendar alternative already exists, it is replaced rather than duplicated. Repeated calls therefore leave at most one calendar alternative.
icalContentcontains the iCalendar data.methodNamespecifies themethodparameter placed in the alternative body'sContent-Typeheader, such asREQUESTorCANCEL.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
methodNameisREQUEST, the MIME headers for the alternative body include:Content-Type: text/calendar; method=REQUEST Content-Transfer-Encoding: base64
Calendar-aware mail clients may display this part as a meeting invitation, cancellation, or published event according to the iCalendar
METHODvalue and the contents oficalContent.- Parameters:
icalContent- theicalContentargument (notnull)methodName- themethodNameargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
aesDecrypt
Decrypts and restores an email message that was previously encrypted using.aesEncrypt(String)passwordmust be the same password that was passed aspasswordto.aesEncrypt(String)This is Chilkat's password-based email-object encryption counterpart to
; it is not S/MIME certificate-based decryption.aesEncrypt(String)- Parameters:
password- thepasswordargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
aesEncrypt
Encrypts the email body, all alternative bodies, all message sub-parts, and attachments using 128-bit AES CBC encryption. To decrypt the email, calland pass the same value foraesDecrypt(String)password.The
AesEncrypt/methods use symmetric password-based AES encryption and do not use certificates or private keys. The sending and receiving applications must both use Chilkat, and the value ofaesDecrypt(String)passwordmust be known by both applications.This is separate from S/MIME encryption controlled by
.getSendEncrypted()- Parameters:
password- thepasswordargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
appendToBody
Appends a string to the plain-text body.If the message has only an HTML body, this method does not append HTML. Use
or retrieve and reset the HTML body when HTML content must be extended.setHtmlBody(String)- Parameters:
str- thestrargument (notnull)
-
applyFixups
Repairs selected MIME-formatting problems commonly found in email produced by other software.fixupsis a comma-separated list of fixup keywords. The following keyword is currently defined:FixRelated— Relocates HTML-related items, such as embedded images, into the appropriate MIME structure so they are not incorrectly presented as ordinary attachments.
Fixups modify the current in-memory MIME structure. Apply them only when the input message exhibits the corresponding formatting problem.
- Parameters:
fixups- thefixupsargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
aspUnpack
Unpacks an HTML email's body and its related items (images, style sheets, and the like) to the filesystem: each related part is written as a separate file, and the HTML is rewritten so those parts load as ordinary files instead ofcid:references.Despite the "Asp" in the name (a historical artifact), this method is not limited to classic ASP. It is useful whenever an HTML email must be displayed or processed outside of a mail client, including:
- Web display — rendering a message in webmail or any web application (PHP, ASP.NET, Node, Java, Python, and so on), where the browser loads the saved images and style sheets from a URL.
- Archiving — saving an email as a self-contained, browsable HTML folder for long-term storage or compliance, viewable later without the original mail client.
- Embedded viewers — loading the unpacked HTML into a desktop application's built-in browser or WebView control, which renders local files.
- Format conversion — feeding the HTML to an HTML-to-PDF (or image) renderer that needs the
related files present on disk.
The arguments control the output:
prefixis prepended to each saved filename,saveDiris the filesystem directory where files are written,urlPathis the URL base substituted into the rewritten HTML, andcleanFilesremoves previously unpacked files first when set to true.For purely local viewing using relative paths rather than a web
urlPath, seeUnpackHtml. To instead produce a single self-contained MHT file that a WebBrowser control can display, seeCreateTempMht.- Parameters:
prefix- theprefixargument (notnull)saveDir- thesaveDirargument (notnull)urlPath- theurlPathargument (notnull)cleanFiles- thecleanFilesargument- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
attachEmail
Attaches a copy ofemailto this email object. The attached email is encapsulated in amessage/rfc822subpart.A copy is attached, so later changes to
emaildo not change the embedded message. The new part is counted by.getNumAttachedMessages()- Parameters:
email- theemailargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
bEncodeString
Converts the Unicode string instrto the charset specified bycharset, B-encodes the resulting multibyte data, and returns the encoded string.B-encoding is commonly used in RFC 2047 encoded words for non-ASCII MIME header text.
charsetcontrols the byte charset used before Base64 encoding.- Parameters:
str- thestrargument (notnull)charset- thecharsetargument (notnull)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
clear
public void clear()Removes the current message content, including recipients, headers, body representations, attachments, related items, and embedded messages. It does not delete or alter a message on a mail server.This method does not reset every configurable property. It resets message-oriented state such as
,getCharset(),getSendSigned(),getSendEncrypted(), andgetOverwriteExisting()to their defaults.getReturnReceipt()Other settings remain unchanged. In particular, replacement patterns and settings such as
,getSigningHashAlg(),getPkcs7KeyLength(),getOaepMgfHash(), andgetPrependHeaders()are preserved.getUncommonOptions()After clearing, the email has one default empty text body. When serialized, Chilkat can emit the standard headers for an empty email.
-
clearBcc
public void clearBcc()Clears the list of blind carbon-copy recipients.This changes only the current email object and does not affect messages already sent.
-
clearCC
public void clearCC()Clears the list of carbon-copy recipients.This changes only the current email object and does not affect messages already sent.
-
clearEncryptCerts
public void clearEncryptCerts()Clears the internal list of explicitly specified certificates to be used for this encrypted email.This removes certificates added explicitly for future encryption operations. It does not remove certificates from the Windows certificate stores, the macOS Keychain, or any PFX source.
-
clearTo
public void clearTo()Clears the list oftorecipients.This changes only the current email object and does not affect messages already sent.
-
computeGlobalKey2
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 Message-ID header field. subject contains the contents of the Subject 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 From header email address. date contains the contents of the Date 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.
encodingdetermines the encoding: base64, hex, url, etc. IfbFoldistrue, then the 16-byte MD5 hash is folded to 8 bytes with an XOR to produce a shorter key.The result is intended as a deterministic message key for indexing or duplicate detection. It is separate from the MIME
Message-IDand does not modify the email.- Parameters:
encoding- theencodingargument (notnull)bFold- thebFoldargument- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
convertInlineImages
public void convertInlineImages()Converts images embedded inline within HTML to multipart/related MIME parts referenced from the HTML by CID.This is useful for producing conventional HTML email where image data is stored in MIME parts rather than directly in the HTML. Review the resulting HTML and related-item collection after conversion.
- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
createTempMht
Prepares the email for display in a web browser and saves it as a temporary MHT (MIME HTML) file, returning the path to the file. IfinFilenameis empty, a temporary filename is generated automatically.To make the message viewable as a standalone web page, this method transforms the email as follows:
- All attachments are dropped.
- If the email has both HTML and plain-text alternatives, the plain-text alternative is dropped.
- If the email has only a plain-text body, that body is converted to HTML.
The resulting MHT file can be loaded by a WebBrowser control (or any viewer that understands MHT) to render the message, inline images and all. To instead unpack the HTML and its related files to loose files served by a web application, see
AspUnpack.- Parameters:
inFilename- theinFilenameargument (notnull)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
dropAttachments
public void dropAttachments()Removes all attachments from the email.This removes ordinary file attachments from the in-memory message. Related items and attached
message/rfc822emails are separate and are not described by this method. -
dropRelatedItem
public void dropRelatedItem(int index)A related item is typically an embedded image referenced from the HTML in the email via aCIDhyperlink. This method removes the Nth embedded image from the email. Note: If the HTML tries to reference the removed image, it will be displayed as a broken image link.This changes only the current in-memory
Emailobject and does not delete or alter a message on a mail server.- Parameters:
index- theindexargument
-
dropRelatedItems
public void dropRelatedItems()A related item is typically an embedded image referenced from the HTML in the email via aCIDhyperlink. This method removes all the embedded images from the email.This removes related MIME resources from the in-memory message. It does not remove ordinary attachments.
-
dropSingleAttachment
public void dropSingleAttachment(int index)Removes the attachment at the zero-based index specified byindex.indexis zero-based; valid values are from0through.getNumAttachments()- 1- Parameters:
index- theindexargument- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
generateFilename
Generates a unique filename for this email. The filename will be different each time the method is called.This method returns a filename only; it does not create a file. It is useful when saving many messages and a collision-resistant local name is needed.
- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getAltHeaderField
Returns the value of a header field within the Nth alternative body's MIME sub-part.indexis zero-based and refers to an alternative counted by.getNumAlternatives()fieldNamenames the MIME header field within that alternative part.- Parameters:
index- theindexargumentfieldName- thefieldNameargument (notnull)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getAlternativeBody
Returns the Nth alternative body. Theproperty tells the number of alternative bodies present. Use thegetNumAlternatives()andgetHtmlBody()methods to easily get the HTML or plain text alternative bodies.getPlainTextBody()indexis zero-based; valid values are from0through.getNumAlternatives()- 1- Parameters:
index- theindexargument- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getAlternativeBodyBd
Returns the contents of the Nth alternative body tobinData. The first alternative body is at index 0. This method should only be called when theproperty has a value greater than 0.getNumAlternatives()indexis zero-based; valid values are from0through.getNumAlternatives()- 1binDatareceives the body bytes.- Parameters:
index- theindexargumentbinData- thebinDataargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getAlternativeBodyByContentType
Returns the alternative body byContent-Type, such astext/plain,text/html,text/xml, etc.The lookup is useful when the alternative order is not known. Typical values for
contentTypearetext/plainandtext/html.- Parameters:
contentType- thecontentTypeargument (notnull)- Returns:
- the result, or
nullif not found (no exception is thrown in that case)
-
getAlternativeContentType
Returns the content type of the Nth alternative body. Theproperty tells the number of alternative bodies present.getNumAlternatives()indexis zero-based; valid values are from0through.getNumAlternatives()- 1- Parameters:
index- theindexargument- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getAttachedEmail
Copies the Nth embeddedmessage/rfc822MIME part intoemail.indexis zero-based; valid values are from0through.getNumAttachedMessages()- 1emailis replaced with an independent copy of the embedded message. Modifyingemaildoes not change the embedded message stored in the caller.- Parameters:
index- theindexargumentemail- theemailargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getAttachedMessageAttr
Returns a header field attribute value for the Nth attached (embedded) email. For example, to get the value of thenameattribute in theContent-Typeheader for the first attached message:Content-Type: message/rfc822; name="md75000024149.eml"
then the method arguments should contain the values 0,
Content-Type,name.indexis a zero-based attached-message index.fieldNamenames a MIME header field andattrNamenames one of that field's parameters.- Parameters:
index- theindexargumentfieldName- thefieldNameargument (notnull)attrName- theattrNameargument (notnull)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getAttachedMessageFilename
Returns the filename of the Nth attached (embedded) email. The filename is thefilenameattribute of theContent-Dispositionheader 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-Dispositionheader exists AND contains afilenameattribute. If questions arise, one could open the email in a text editor to examine the MIME sub-header for the attached message (where theContent-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
indexis zero-based. The returned value comes from MIME metadata and should be sanitized before it is used as a local filesystem name.- Parameters:
index- theindexargument- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getAttachmentAttr
Returns a header field attribute value from the header field of the Nth attachment.indexis a zero-based attachment index.fieldNamenames a header field such asContent-Type, andattrNamenames one of that field's parameters, such ascharsetorname.- Parameters:
index- theindexargumentfieldName- thefieldNameargument (notnull)attrName- theattrNameargument (notnull)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getAttachmentBd
Copies an attachment's binary data intobinData. The first attachment is at index 0.indexis zero-based.binDatareceives the attachment bytes.- Parameters:
index- theindexargumentbinData- thebinDataargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getAttachmentContentID
Returns the ContentID header field for the Nth attachment. The first attachment is at index 0.indexis zero-based. The returned value is the identifier used bycid:references when the attachment is referenced inline.- Parameters:
index- theindexargument- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getAttachmentContentType
Returns theContent-Typeheader field for the Nth attachment. Indexing of attachments begins at 0.indexis zero-based. The result is the MIME media type without implying that the filename extension is trustworthy.- Parameters:
index- theindexargument- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getAttachmentFilename
Retrieves an attachment's filename.indexis zero-based. The returned value is the filename stored in MIME. It may contain path information or characters that are not valid in a local filesystem filename. WhenorsaveAllAttachments(String)saves the attachment, Chilkat ignores MIME path components and sanitizes the final filename as described by those methods.saveAttachedFile(int, String)- Parameters:
index- theindexargument- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getAttachmentHeader
Returns the value of a header field (by name) of an attachment.attachIndexis a zero-based attachment index andfieldNameis the MIME header-field name. Header-field names are case-insensitive.- Parameters:
attachIndex- theattachIndexargumentfieldName- thefieldNameargument (notnull)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getAttachmentSize
public int getAttachmentSize(int index)Returns the size, in bytes, of the attachment at the zero-based index specified byindex. Returns-1ifindexdoes not identify an existing attachment.The returned value is the decoded attachment content size, not the number of Base64 characters in the MIME representation.
- Parameters:
index- theindexargument- Returns:
- the result (see
ChilkatObject.getLastMethodSuccess()where the description mentions failure)
-
getAttachmentString
Returns the attachment at the zero-based index specified byindexas text.charsetspecifies the charset used to interpret the attachment bytes, such asutf-8. CRLF sequences in the attachment are normalized to single newline characters in the returned string.indexis zero-based.charsetcontrols conversion of the attachment bytes to Unicode; use a binary attachment getter when the content is not text.- Parameters:
index- theindexargumentcharset- thecharsetargument (notnull)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getAttachmentStringCrLf
Retrieves an attachment's data as a String. All end-of-lines will be translated to CRLF sequences.indexis a zero-based attachment index.charsetspecifies the charset used to decode the attachment bytes to Unicode text.- Parameters:
index- theindexargumentcharset- thecharsetargument (notnull)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getBcc
Returns a blind carbon-copy recipient's full email address.indexis zero-based; valid values are from0through. The result may include both display name and address.getNumBcc()- 1- Parameters:
index- theindexargument- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getBccAddr
Returns the Nth BCC address (only the address part, not the friendly-name part).indexis zero-based; valid values are from0through.getNumBcc()- 1- Parameters:
index- theindexargument- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getBccName
Returns the Nth BCC name (only the friendly-name part, not the address part).indexis zero-based; valid values are from0through.getNumBcc()- 1- Parameters:
index- theindexargument- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getCC
Returns a carbon-copy recipient's full email address.indexis zero-based; valid values are from0through. The result may include both display name and address.getNumCC()- 1- Parameters:
index- theindexargument- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getCcAddr
Returns the Nth CC address (only the address part, not the friendly-name part).indexis zero-based; valid values are from0through.getNumCC()- 1- Parameters:
index- theindexargument- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getCcName
Returns the Nth CC name (only the friendly-name part, not the address part).indexis zero-based; valid values are from0through.getNumCC()- 1- Parameters:
index- theindexargument- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getDeliveryStatusInfo
Returns a field from themessage/delivery-statuspart of a delivery-status notification.Call this method only for an email identified as a
multipart/reportdelivery-status notification.fieldNamespecifies the field name, such asFinal-Recipient,Status,Action, orReporting-MTA.Reporting-MTA: dns; XYZ.abc.nl Final-Recipient: RFC822; someEmailAddr@doesnotexist123.nl Action: failed Status: 5.4.4
fieldNamenames a field in the delivery-status section. This method reads the report already present in the email object and performs no server query.- Parameters:
fieldName- thefieldNameargument (notnull)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getDigestEmail
Returns inemailthe Nth digest email contained within a multipart/digest. The first digest is at index 0. Use theproperty to get the number of digests available.getNumDigests()indexis zero-based; valid values are from0through.getNumDigests()- 1emailreceives a copy of the digest message.- Parameters:
index- theindexargumentemail- theemailargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getDsnInfo
If themethod indicates that the email isisMultipartReport()multipart/report, use this method to obtain the delivery-status information, including the final recipients, as JSON that is easy to parse.The JSON is derived from report data already contained in the email; the method does not contact an SMTP server for updated status.
- Parameters:
json- thejsonargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getHeaderField
Returns the value of a header field.Header-field names are case-insensitive. If a field occurs more than once, use indexed header enumeration when each occurrence must be inspected separately.
- Parameters:
fieldName- thefieldNameargument (notnull)- Returns:
- the result, or
nullif not found (no exception is thrown in that case)
-
getHeaderFieldName
Returns the name of the Nth header field. Theproperty gives the number of header fields. UsegetNumHeaderFields()to retrieve a header field value by name.getHeaderField(String)The first header field is at index 0. (All Chilkat indexing is 0-based.)
indexis zero-based; valid values are from0through. Repeated fields appear as separate entries.getNumHeaderFields()- 1- Parameters:
index- theindexargument- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getHeaderFieldValue
Returns the value of the Nth header field. (Indexing begins at 0) The number of header fields can be obtained from theproperty.getNumHeaderFields()The first header field is at index 0, the last header field is at index
-1. (All Chilkat indexing is 0-based.)getNumHeaderFields()indexis zero-based; valid values are from0through. Use the same index withgetNumHeaderFields()- 1to identify the field.getHeaderFieldName(int)- Parameters:
index- theindexargument- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getHtmlBody
Returns the body having thetext/htmlcontent type.This reads the HTML representation already present in the email object. It does not automatically inline related images; use
for that option.getHtmlBodySb(boolean, StringBuilder)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getHtmlBodySb
Returns the body having thetext/htmlcontent type. IfinlineImageDataistrue, the related images found in the MIME are inlined as base64 directly within the returned HTML. The HTML is returned insb.Inlining related images can substantially increase the size of the returned HTML because the image bytes are embedded as data URLs.
- Parameters:
inlineImageData- theinlineImageDataargumentsb- thesbargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getImapUid
public long getImapUid()When email headers are downloaded from an IMAP server (using Chilkat IMAP), ackx-imap-uidheader field is added. The content of this header is the UID or sequence number of the email on the IMAP server. In addition, ackx-imap-isUidheader field is added, and this will have the value YES or NO. If the value is YES, thenckx-imap-uidcontains a UID, if the value is NO, thenckx-imap-uidcontains the sequence number. This method returns the UID ifckx-imap-uidexists 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-uidheader field and this method would return 0xFFFFFFFF. For example, if emails are downloaded by sequence numbers via theImap.FetchSequencemethod, then UIDs are not used and therefore the email object will not contain this information.This reads Chilkat metadata stored in the email object; it does not contact the IMAP server. The accompanying Boolean output distinguishes a stable UID from a mailbox sequence number.
- Returns:
- the result (see
ChilkatObject.getLastMethodSuccess()where the description mentions failure)
-
getMime
Returns the email as RFC822/MIME text containing the headers, body representations, related items, and attachments.The result is suitable for saving as an
.emlfile or passing to an API that accepts MIME text.Serialization may normalize header whitespace,
Content-Typeparameters, transfer encodings, and other MIME formatting. Therefore, MIME that is loaded and then reserialized is not guaranteed to be byte-for-byte identical to the original input. Repeated calls without modifying the email return the same current serialized form.Headers that were explicitly removed, such as
Date,Message-ID, orMIME-Version, are not necessarily regenerated by this method.- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getMimeBd
Serializes the complete RFC822/MIME message and appends the bytes tobindat.The output includes headers, body representations, related items, and attachments. Clear
bindatfirst when replacement rather than append behavior is desired.Serialization may normalize header whitespace,
Content-Typeparameters, transfer encodings, and other MIME formatting. Loading MIME and then calling this method is therefore not guaranteed to reproduce the original input byte-for-byte.- Parameters:
bindat- thebindatargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getMimeSb
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) ofsb.Clear
sbfirst when replacement rather than append behavior is desired.- Parameters:
sb- thesbargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getNthBinaryPartOfTypeBd
public void getNthBinaryPartOfTypeBd(int index, String contentType, boolean inlineOnly, boolean excludeAttachments, BinData bd)Loadsbdwith the binary bytes of the Nth MIME sub-part matchingcontentType, which can be an exactContent-Typesuch asapplication/pdf, or a wildcardedContent-Typesuch asapplication/*, or*/*. Indexing begins at 0. Callto find out how many MIME sub-parts exist for any given content type. IfgetNumPartsOfType(String, boolean, boolean)inlineOnlyistrue, then only MIME sub-parts having aContent-Dispositionofinlineare included. IfexcludeAttachmentsistrue, then MIME sub-parts having aContent-Dispositionofattachmentare 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,
contentTypecan be wildcarded. For example, it is possible to specifytext/*, or simply*to match anyContent-Type.Note: Only non-multipart MIME parts are matched.
Use
with the same filters to determine the valid zero-based index range before loadinggetNumPartsOfType(String, boolean, boolean)bd.- Parameters:
index- theindexargumentcontentType- thecontentTypeargument (notnull)inlineOnly- theinlineOnlyargumentexcludeAttachments- theexcludeAttachmentsargumentbd- thebdargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getNthContentType
public String getNthContentType(int index, String contentType, boolean inlineOnly, boolean excludeAttachments)Returns theContent-Typeof the Nth non-multipart MIME part matching the pattern incontentType.indexis a zero-based index among the matching parts.contentTypemay be an exactContent-Type, such astext/plain, or a wildcard pattern, such astext/*or*. WheninlineOnlyistrue, only parts having aninlineContent-Dispositionare considered. WhenexcludeAttachmentsistrue, parts having anattachmentContent-Dispositionare excluded.Use
with the same filters to determine the valid zero-based index range.getNumPartsOfType(String, boolean, boolean)- Parameters:
index- theindexargumentcontentType- thecontentTypeargument (notnull)inlineOnly- theinlineOnlyargumentexcludeAttachments- theexcludeAttachmentsargument- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getNthTextPartOfType
public String getNthTextPartOfType(int index, String contentType, boolean inlineOnly, boolean excludeAttachments)Returns the text content of the Nth non-multipart MIME part matching theContent-Typepattern incontentType.indexis a zero-based index among the matching parts.contentTypemay be an exactContent-Type, such astext/plain, or a wildcard pattern, such astext/*or*. Useto determine the number of matching parts.getNumPartsOfType(String, boolean, boolean)When
inlineOnlyistrue, only parts having aninlineContent-Dispositionare considered. WhenexcludeAttachmentsistrue, parts having anattachmentContent-Dispositionare excluded.Note: A header-only email, or an email downloaded from IMAP without attachments, does not contain every MIME part from the complete message.
Use
with the same filters to determine the valid zero-based index range before retrieving a part.getNumPartsOfType(String, boolean, boolean)- Parameters:
index- theindexargumentcontentType- thecontentTypeargument (notnull)inlineOnly- theinlineOnlyargumentexcludeAttachments- theexcludeAttachmentsargument- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getNumPartsOfType
Returns the number of non-multipart MIME parts matching theContent-Typepattern incontentType.contentTypemay be an exactContent-Type, such astext/plain, or a wildcard pattern, such astext/*or*. WheninlineOnlyistrue, only parts having aninlineContent-Dispositionare counted. WhenexcludeAttachmentsistrue, parts having anattachmentContent-Dispositionare excluded.Note: A header-only email, or an email downloaded from IMAP without attachments, does not contain every MIME part from the complete message.
The count is based on the MIME parts currently loaded in the email object. No attachment or body data is fetched from a server by this method.
- Parameters:
contentType- thecontentTypeargument (notnull)inlineOnly- theinlineOnlyargumentexcludeAttachments- theexcludeAttachmentsargument- Returns:
- the result (see
ChilkatObject.getLastMethodSuccess()where the description mentions failure)
-
getPlainTextBody
Returns the email body having thetext/plaincontent type.This reads the plain-text representation already present in the email object. It does not convert the HTML body to plain text.
- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getRelatedAttr
Returns a header field attribute value from the header field of the Nth related item.indexis a zero-based related-item index.fieldNamenames a MIME header field andattrNamenames one of that field's parameters.- Parameters:
index- theindexargumentfieldName- thefieldNameargument (notnull)attrName- theattrNameargument (notnull)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getRelatedContentID
Returns the content ID of a related item contained with the email. Related items are typically images and style-sheets embedded within HTML emails.indexis zero-based; valid values are from0through. The value is normally referenced from HTML as agetNumRelatedItems()- 1cid:URL.- Parameters:
index- theindexargument- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getRelatedContentLocation
Returns theContent-Locationof a related item contained with the email. Related items are typically images and style-sheets embedded within HTML emails.indexis zero-based.Content-Locationis an alternative toContent-IDfor identifying a resource referenced by the HTML body.- Parameters:
index- theindexargument- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getRelatedContentType
Returns theContent-Typeof the Nth related content item in an email message.indexis zero-based; valid values are from0through.getNumRelatedItems()- 1- Parameters:
index- theindexargument- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getRelatedFilename
Returns the filename of a related item contained with the email. Related items are typically images and style-sheets embedded within HTML emails.indexis zero-based. The returned MIME filename should be sanitized before it is used as a local filesystem path.- Parameters:
index- theindexargument- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getRelatedHeader
Returns the value of a header field (by name) of a related item.indexis a zero-based related-item index. MIME header-field names are case-insensitive.- Parameters:
index- theindexargumentfieldName- thefieldNameargument (notnull)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getRelatedString
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.indexis zero-based andcharsetspecifies the charset used to decode the related-item bytes to Unicode text.- Parameters:
index- theindexargumentcharset- thecharsetargument (notnull)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getRelatedStringCrLf
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.indexis zero-based andcharsetspecifies the charset used to decode the related-item bytes to Unicode text.- Parameters:
index- theindexargumentcharset- thecharsetargument (notnull)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getReplacePattern
Returns a replacement pattern previously defined for mail-merge operations.indexis zero-based; valid values are from0through.getNumReplacePatterns()- 1- Parameters:
index- theindexargument- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getReplaceString
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.
indexis a zero-based pattern index. Useto determine the valid range.getNumReplacePatterns()- Parameters:
index- theindexargument- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getReplaceString2
Returns a replacement string for a previously defined pattern/replacement string pair. (This is a mail-merge feature.)patternis the previously registered pattern text, not a numeric index.- Parameters:
pattern- thepatternargument (notnull)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getReport
(See theproperty.) Returns the body content of the Nth report within a multipart/report email.getNumReports()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
indexis zero-based; valid values are from0through.getNumReports()- 1- Parameters:
index- theindexargument- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getTo
Returns atorecipient's full email address.indexis zero-based; valid values are from0through. The result may include both display name and address.getNumTo()- 1- Parameters:
index- theindexargument- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getToAddr
Returns the Nth To address (only the address part, not the friendly-name part).indexis zero-based; valid values are from0through.getNumTo()- 1- Parameters:
index- theindexargument- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getToName
Returns the Nth To name (only the friendly-name part, not the address part).indexis zero-based; valid values are from0through.getNumTo()- 1- Parameters:
index- theindexargument- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getXml
Convert the email object to an XML document in memoryThe XML is Chilkat's email-object representation, not MIME and not a standardized interchange format. Use
when an RFC822/MIME message is required.getMime()- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
hasHeaderMatching
Returnstruewhen the email contains a header field namedfieldNamewhose value matches the wildcard pattern invaluePattern.valuePatternmay contain any number of*characters, where each asterisk matches zero or more characters.caseSensitivecontrols whether matching is case-sensitive.The pattern syntax is a simple wildcard match, not a regular expression. Header-field names are compared without regard to case.
- Parameters:
fieldName- thefieldNameargument (notnull)valuePattern- thevaluePatternargument (notnull)caseSensitive- thecaseSensitiveargument- Returns:
- the result; this method never throws
ChilkatException
-
hasHtmlBody
public boolean hasHtmlBody()Returnstrueif the email has an HTML body.Returns
trueonly when atext/htmlbody is present in the current email object.- Returns:
- the result; this method never throws
ChilkatException
-
hasPlainTextBody
public boolean hasPlainTextBody()Returnstrueif the email has a plain-text body.Returns
trueonly when atext/plainbody is present in the current email object.- Returns:
- the result; this method never throws
ChilkatException
-
isMultipartReport
public boolean isMultipartReport()Returnstrueif the email is a multipart/report email.Returns
truewhen the top-level message structure is amultipart/report. UseorgetDsnInfo(JsonObject)to examine report content.getReport(int)- Returns:
- the result; this method never throws
ChilkatException
-
lastDecryptCert
Returns incertthe certificate used to decrypt this email.Call this after a successful decryption to inspect the certificate associated with the private key that decrypted the message.
- Parameters:
cert- thecertargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
lastSignerCert
Copies the certificate for the signer at the zero-based index specified byindexintocert.Most signed emails have one signer, but an email may contain multiple signatures.
Call this after parsing or verifying a signed message.
certreceives a copy of the signer certificate and can be examined independently.- Parameters:
index- theindexargumentcert- thecertargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
linkedDomains
Extracts domain names from hyperlinks in an HTML email. Lowercase domains are appended todomainswithout creating duplicates.This method parses links only; it does not perform DNS lookups or make network requests to the extracted domains.
- Parameters:
domains- thedomainsargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
loadEml
Loads a complete email from an.emlfile. An EML file contains RFC822/MIME message text.On success, the loaded message replaces the entire current email, including recipients, headers, bodies, related items, and attachments. If the file cannot be opened or parsed and the method fails, the email content that existed before the call is preserved.
The file is parsed locally; this method does not connect to an SMTP, POP3, or IMAP server.
- Parameters:
mimePath- themimePathargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
loadXml
Loads an email from a Chilkat XML email file.On success, the loaded message replaces the entire current email, including recipients, headers, bodies, related items, and attachments. If the file cannot be opened or parsed and the method fails, the email content that existed before the call is preserved.
The file must contain XML previously produced by Chilkat email serialization. It is not an arbitrary XML-to-email conversion method.
- Parameters:
xmlPath- thexmlPathargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
loadXmlString
Loads an email from the Chilkat XML representation inxmlStr, typically obtained from.getXml()On success, the loaded message replaces the entire current email, including recipients, headers, bodies, related items, and attachments. If
xmlStrcannot be parsed and the method fails, the email content that existed before the call is preserved.This is a local parsing operation and does not connect to a mail server.
- Parameters:
xmlStr- thexmlStrargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
makeCopy
Copies the entire state of this email intodestEmail, including all message content, recipients, headers, body representations, attachments, related items, embedded messages, replacement patterns, certificates, certificate sources, and configuration properties.destEmailbecomes an independent copy. Subsequent changes to either email object do not affect the other.- Parameters:
destEmail- thedestEmailargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
qEncodeString
Converts the Unicode string instrto the charset specified bycharset, Q-encodes the resulting multibyte data, and returns the encoded string.Q-encoding is commonly used in RFC 2047 encoded words for non-ASCII MIME header text.
charsetcontrols the byte charset used before Q-encoding.- Parameters:
str- thestrargument (notnull)charset- thecharsetargument (notnull)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
removeAttachedMessage
public void removeAttachedMessage(int idx)Removes the Nth message/rfc822 sub-part of the email. Indexing begins at 0.idxis zero-based; valid values are from0through. This changes only the in-memory email.getNumAttachedMessages()- 1- Parameters:
idx- theidxargument
-
removeAttachedMessages
public void removeAttachedMessages()Removes all message/rfc822 sub-parts of the email object.This does not remove ordinary file attachments or related HTML resources.
-
removeAttachmentPaths
public void removeAttachmentPaths()Removes relative or absolute path information from attachment filenames stored in the MIME, leaving only each final filename component.This changes the MIME filename metadata only. It does not affect the behavior of
orsaveAllAttachments(String), because those methods already ignore path information in MIME attachment filenames and save beneath the directory specified by the application.saveAttachedFile(int, String) -
removeHeaderField
Removes by name all occurrences of a header field.Header-field names are case-insensitive. All repeated occurrences having the specified name are removed from the current email object.
- Parameters:
fieldName- thefieldNameargument (notnull)
-
removeHtmlAlternative
public void removeHtmlAlternative()Removes the HTML body from the email (if an HTML body exists).Other body representations, attachments, and related items remain unchanged.
-
removePlainTextAlternative
public void removePlainTextAlternative()Removes the plain-text body from the email (if a plain-text body exists).Other body representations, attachments, and related items remain unchanged.
-
saveAllAttachments
Saves all attachments to the directory specified bydirPath. IfdirPathor any of its directory components do not exist, Chilkat creates them automatically. Theproperty controls whether existing files may be overwritten.getOverwriteExisting()Chilkat first uses the filename from the MIME
Content-Dispositionheader. If no filename is present there, it uses thenameparameter from theContent-Typeheader. If neither is present, the attachment is saved asattachedFile.txt.If the selected MIME filename contains relative or absolute path information, Chilkat ignores the path and uses only the final filename component. The file is always written beneath the application-specified directory in
dirPath.On Windows, Chilkat converts the final MIME filename component to a valid Windows filename. It replaces
|and a:that is not part of a drive specification with_; removes<,>,*,?, and"; and interprets/and\as path separators, so the path is omitted. If the colon belongs to a drive specification such asC:\, it is discarded with the path. For example,a<b>c:d|e?f*g.txtis saved asabc_d_efg.txt.Attachment filenames can be changed before saving. The number of attachments is available in the
property. An application can callgetNumAttachments()for each zero-based index and change a filename by callinggetAttachmentFilename(int).setAttachmentFilename(int, String)Only attachments already present in the email object are saved. A message downloaded without attachment bodies must first have those bodies fetched by the mail protocol component.
- Parameters:
dirPath- thedirPathargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
saveAttachedFile
Saves the attachment at the zero-based index specified byindexto the directory specified bydirPath. IfdirPathor any of its directory components do not exist, Chilkat creates them automatically. Theproperty controls whether an existing file may be overwritten.getOverwriteExisting()Chilkat first uses the filename from the MIME
Content-Dispositionheader. If no filename is present there, it uses thenameparameter from theContent-Typeheader. If neither is present, the attachment is saved asattachedFile.txt.If the selected MIME filename contains relative or absolute path information, Chilkat ignores the path and uses only the final filename component. The file is always written beneath the application-specified directory in
dirPath.On Windows, Chilkat converts the final MIME filename component to a valid Windows filename. It replaces
|and a:that is not part of a drive specification with_; removes<,>,*,?, and"; and interprets/and\as path separators, so the path is omitted. If the colon belongs to a drive specification such asC:\, it is discarded with the path. For example,a<b>c:d|e?f*g.txtis saved asabc_d_efg.txt.The attachment data must already be present in the current
Emailobject. This method does not retrieve missing attachment data from a mail server.- Parameters:
index- theindexargumentdirPath- thedirPathargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
saveEml
Convert this email object to EML and save it to a file.An EML file contains the complete RFC822/MIME message, including headers, bodies, related items, and attachments.
- Parameters:
emlFilePath- theemlFilePathargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
saveRelatedItem
Saves the related item at the zero-based index specified byindexto the directory specified bydirPath. IfdirPathor any of its directory components do not exist, Chilkat creates them automatically. Valid indexes are from0through. ThegetNumRelatedItems()- 1property controls whether an existing file may be overwritten.getOverwriteExisting()If the related item's MIME filename contains relative or absolute path information, Chilkat ignores the path and uses only the final filename component. The file is always written beneath the application-specified directory in
dirPath.Related items are typically images, style sheets, or other resources used by an HTML body. The related-item data must already be present in the email object.
- Parameters:
index- theindexargumentdirPath- thedirPathargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
saveXml
Convert this email object to XML and save it to a file.The generated XML is Chilkat's email-object serialization and can later be loaded with
. UseloadXml(String)for a standard MIME message file.saveEml(String)- Parameters:
path- thepathargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
setAttachmentCharset
Sets thecharsetparameter of theContent-Typeheader field for the attachment at the zero-based index specified byindex.charsetspecifies the charset, such asShift_JIS,iso-8859-2,big5, oriso-8859-5.This updates MIME metadata and does not transcode the attachment bytes. Use it only when the bytes are already encoded in the charset specified by
charset.- Parameters:
index- theindexargumentcharset- thecharsetargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
setAttachmentDisposition
Sets theContent-Dispositionvalue for the attachment at the zero-based index specified byindex.The default disposition is
attachment. Setdispositiontoinlinewhen the attachment should be presented as inline content.indexis zero-based.inlinesuggests that a mail client may display the part in the message, whileattachmentsuggests a separate downloadable file.- Parameters:
index- theindexargumentdisposition- thedispositionargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
setAttachmentFilename
Changes the filename of the attachment at the zero-based index specified byindex.filenamecontains the new filename.indexis zero-based. This changes the filename stored in MIME and does not rename any original local file.- Parameters:
index- theindexargumentfilename- thefilenameargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
setBodyBd
Sets the main email body from the binary data inbd.contentTypespecifies the MIMEContent-Type.dispositionspecifies the disposition and may be empty,inline, orattachment.filenameoptionally specifies a filename. Whenfilenameis provided,dispositionmust also be specified because the filename is an attribute of theContent-Dispositionheader.This replaces the main body using bytes already stored in
bd. It does not add a separate attachment unlessdispositionandfilenameintentionally describe the body as one.- Parameters:
bd- thebdargument (notnull)contentType- thecontentTypeargument (notnull)disposition- thedispositionargument (notnull)filename- thefilenameargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
setDecryptCert
Allows for a certificate to be explicitly provided for decryption. When an email object is loaded via any method, such as,loadEml(String),setFromMimeText(String), etc., security layers (signatures and encryption) are automatically unwrapped. This method could be called prior to calling a method that loads the email.SetFromMimeBytesConfigure the certificate before loading or unwrapping the encrypted MIME so the private key is available at decryption time.
- Parameters:
cert- thecertargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
setDecryptCert2
Explicitly provides the certificate incertand the corresponding private key inkeyfor decryption. When an email object is loaded by a method such as,loadEml(String), orsetFromMimeText(String), security layers such as signatures and encryption are automatically unwrapped. Decryption requires the private key inSetFromMimeByteskey.On Windows, Chilkat automatically searches the system certificate stores for the required certificate and private key. On macOS, Chilkat automatically searches the Keychain. When the required certificate and private key are not installed in one of these locations, provide them in
certandkey, or calloraddPfxSourceFile(String, String).AddPfxSourceDataCall this method before loading or unwrapping the encrypted MIME.
certandkeymust correspond to one another.- Parameters:
cert- thecertargument (notnull)key- thekeyargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
setDt
Sets theDateheader field of the email to have the value of the date/time object provided.The date/time is formatted as an RFC822
Dateheader when the message is serialized.- Parameters:
dt- thedtargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
setEdifactBody
Creates a typical email used to send EDIFACT messages. Does the following:- Sets the email body to the EDIFACT message passed in
message. - Sets the
Content-Transfer-Encodingto Base64. - Set the
Content-Typeequal toapplication/EDIFACT. - Sets the
Content-Typeheader's name attribute toname. - Sets the
Content-Dispositionequal toattachment. - Sets the
Content-Disposition'sfilenameattribute equal tofilename. - The EDIFACT message is converted to the charset indicated by
charset, and encoded using Base64 in the email body.
The email's subject, recipients, FROM address, and other headers are left unmodified.
This is a convenience method that constructs the customary MIME headers and body for EDIFACT transport. It replaces the existing main body configuration.
- Parameters:
message- themessageargument (notnull)name- thenameargument (notnull)filename- thefilenameargument (notnull)charset- thecharsetargument (notnull)
- Sets the email body to the EDIFACT message passed in
-
setEncryptCert
Sets the certificate incertas the explicit recipient encryption certificate. Use theCreateCS,CertStore, andCertclasses to obtain aCertobject by locating a certificate in a certificate store or loading one from a file.Use
instead when the message must be decryptable by multiple recipients.addEncryptCert(Cert)- Parameters:
cert- thecertargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
setFromMimeBd
Loads an email with the MIME stored in aBinDataobject.Note: This replaces the entire contents of the email object, including the To/CC recipients.
The MIME is parsed locally and the
BinDataitself is not modified.- Parameters:
bindat- thebindatargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
setFromMimeSb
Loads an email with the MIME stored in aStringBuilderobject.Note: This replaces the entire contents of the email object, including the To/CC recipients.
The MIME is parsed locally and the
StringBuilderitself is not modified.- Parameters:
sb- thesbargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
setFromMimeText
Loads the email from MIME text contained inmimeText, such as the contents of an.emlfile.On success, this replaces the entire current email, including recipients, headers, bodies, related items, and attachments. An empty string is accepted and clears the current message content.
mimeTextmust be interpreted as MIME, not as body text. To set a plain-text body directly, use theproperty orgetBody().setTextBody(String, String)This parses MIME already present in memory and does not contact a mail server.
- Parameters:
mimeText- themimeTextargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
setFromXmlText
Loads an email from an XML string.Note: This replaces the entire contents of the email object, including the To/CC recipients.
The XML must be in Chilkat's email serialization format, typically obtained from
.getXml()- Parameters:
xmlStr- thexmlStrargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
setHtmlBody
Sets the HTML body of an email.This creates or replaces the
text/htmlbody. It does not automatically create a plain-text alternative.- Parameters:
html- thehtmlargument (notnull)
-
setRelatedFilename
Sets the filename for a related item within the email.indexis zero-based. This changes the filename stored in the related MIME part and does not rename a local source file.- Parameters:
index- theindexargumentpath- thepathargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
setReplacePattern
Defines a mail-merge replacement pair.patterncontains the pattern to find, andreplaceStringcontains the replacement text.When the email is sent by a
MailMansending method, occurrences ofpatternare replaced withreplaceString. To define multiple replacement pairs, call this method once for each pair. TheMailManmethodRenderToMimealso performs these replacements. Methods such asandsaveEml(String)do not.getMime()patternmay occur in any header field and in either an HTML or plain-text body. Defining the pair does not immediately alter the stored body or headers; replacement occurs later during supported rendering or sending operations.- Parameters:
pattern- thepatternargument (notnull)replaceString- thereplaceStringargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
setSigningCert
Sets the certificate incertfor creating a digital signature. Use theCreateCS,CertStore, andCertclasses to obtain aCertobject by locating a certificate in a certificate store or loading one from a file.certmust have access to its private key when signing occurs. Usewhen the private key is supplied separately.setSigningCert2(Cert, PrivateKey)- Parameters:
cert- thecertargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
setSigningCert2
Explicitly sets the certificate incertand the corresponding private key inkeyfor sending digitally signed email.If
certalready has access to its private key, it is usually sufficient to call. 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.setSigningCert(Cert)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
Fromaddress, provided the certificate and private key are installed in a searchable certificate store or Keychain.Use this method when the private key is held separately from the certificate.
certandkeymust correspond to one another.- Parameters:
cert- thecertargument (notnull)key- thekeyargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
setTextBody
Sets the body of the email and also sets theContent-Typeheader field ofcontentType. If the email is already multipart/alternative, an additional alternative with the indicatedContent-Typewill be added. If an alternative with the sameContent-Typealready exists, it is replaced.Use a textual MIME type such as
text/plainortext/html. When building a plain-text/HTML pair, the dedicated alternative-body methods make the intendedmultipart/alternativestructure clearer.- Parameters:
bodyText- thebodyTextargument (notnull)contentType- thecontentTypeargument (notnull)
-
toDsn
Creates a new Delivery Status Notification (DSN) email in the format specified by RFC 3464. The DSN email is generated indsnEmail.The source email is not modified. Populate any additional sender or recipient fields on
dsnEmailbefore sending the generated notification.- Parameters:
explanation- theexplanationargument (notnull)statusFields- thestatusFieldsargument (notnull)headerOnly- theheaderOnlyargumentdsnEmail- thedsnEmailargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
toForward
Creates an inline-forward email infwdEmailbased on this email.The source email is not modified.
fwdEmailcan be edited to add recipients, introductory text, or other forwarding details before sending.- Parameters:
fwdEmail- thefwdEmailargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
toMdn
Creates a new MDN (Message Disposition Notification) email inmdnusing the format specified by RFC 3798.The source email is not modified. Populate any additional sender or recipient fields on
mdnbefore sending the generated notification.- Parameters:
message- themessageargument (notnull)statusFields- thestatusFieldsargument (notnull)headerOnly- theheaderOnlyargumentmdn- themdnargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
toReply
Generates a reply email inreplywith 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, callon the reply email object.removeAttachedMessages()The source email is not modified.
replycan be edited to add introductory text, adjust recipients, or change reply behavior before sending.- Parameters:
reply- thereplyargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
uidlEquals
Returnstrueif this email's UIDL equals the UIDL of the email passed ine.This comparison is meaningful for messages obtained through POP3. It does not compare IMAP UIDs, MIME
Message-IDvalues, or message content.- Parameters:
e- theeargument (notnull)- Returns:
- the result; this method never throws
ChilkatException
-
unSpamify
public void unSpamify()Unobfuscates emails by undoing what spammers do to obfuscate email. It removes comments from HTML bodies and unobfuscates hyperlinked URLs.This modifies the current email content. Make a copy first when the original HTML must be preserved for forensic or auditing purposes.
-
unpackHtml
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.unpackDirspecifies the destination directory for the HTML file,htmlFilenamespecifies the HTML filename, andpartsSubdirspecifies the subdirectory beneathunpackDirwhere related files are written. Chilkat creates the related-files subdirectory when necessary.Example: If
unpackDirisC:/test,htmlFilenameismyEmail.html, andpartsSubdirisimages, Chilkat writesC:/test/myEmail.htmland stores related files inC:/test/images.Note: Only related content physically contained in the email can be extracted. Images referenced by external web URLs are not downloaded.
The extracted filenames originate from message content and should be treated as untrusted when processing email from unknown senders. The method operates on data already present in the email object.
- Parameters:
unpackDir- theunpackDirargument (notnull)htmlFilename- thehtmlFilenameargument (notnull)partsSubdir- thepartsSubdirargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
unzipAttachments
public void unzipAttachments()Unzips and replaces any Zip file attachments with the expanded contents. As an example, if an email contained a single Zip file containing 3 GIF image files as an attachment, then after calling this method the email would contain 3 GIF file attachments, and the Zip attachment would be gone.If an email contains multiple Zip file attachments, each Zip is expanded and replaced with the contents.This changes the attachment collection in memory; it does not extract files directly to a filesystem directory. Save the resulting attachments separately when files are required on disk.
- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
useCertVault
Adds the XML certificate vault invaultto the object's internal certificate and private-key lookup sources for encryption, decryption, signing, and verification.Unlike
andAddPfxSourceData, only one XML certificate vault can be used. Each call replaces the vault supplied by the previous call, so only the most recentaddPfxSourceFile(String, String)vaultremains in use.vaultbecomes a lookup source for subsequent operations by this object. Adding it does not immediately sign, verify, encrypt, or decrypt anything.- Parameters:
vault- thevaultargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
zipAttachments
Replaces all the attachments of an email with a single Zip file attachment having the filename specified.The original attachments are removed from the in-memory email and their contents are placed into the new Zip attachment. Related items and attached emails are separate.
- Parameters:
zipFilename- thezipFilenameargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-