Email Message Context

  • Access and process IMAP, POP3 email messages in rules engine
  • Easy email attachment handling
  • Context Variable: mail
  • Only applicable to Email Input Service

API Interface

//Apply the specified Search criterion to this message.
boolean match(SearchTerm term);

//Check whether the flag specified in the flag argument is set in this message
boolean isSet(Flag flag);

//Return the size of the content of this part in bytes. Return -1 if the size cannot be determined
int getSize();

//Return an input stream for this part's "content". Any mail-specific transfer encodings will be decoded before the input stream is provided.
InputStream getInputStream();

//Return the content as a Java object. The type of the returned object is of course dependent on the content itself. For example, the object returned for "text/plain" content is usually a String object. The object returned for a "multipart" content is always a Multipart subclass. For content-types that are unknown to the DataHandler system, an input stream is returned as the content
Object getContent();

//Get the filename associated with this part, if possible. Useful if this part represents an "attachment" that was loaded from a file. The filename will usually be a simple name, not including directory components
String getFileName();

//Get all the headers for this header name. Returns null if no headers for this header name are available.
String[] getHeader(String header_name);

//Output a bytestream for this Part. This bytestream is typically an aggregration of the Part attributes and an appropriately encoded bytestream from its 'content'.
void writeTo(OutputStream os);

//Returns a Flags object containing the flags for this message.
Flags getFlags();

//Returns the "From" attribute. The "From" attribute contains the identity of the person(s) who wished this message to be sent
Address[] getFrom();

//List all the string parts of the incoming email
List<String> listStringParts();

//Get the specified BodyPart. BodyParts are numbered starting at 0.
BodyPart getPart(int part);

//Return the disposition of this part. The disposition describes how the part should be presented to the user. (See RFC 2183.)
String getDisposition();

//Return the number of enclosed BodyPart objects.
int getPartsCount();

//List all the attached files
List<byte[]> listAttachments();

//List all the attached files and return their names too
List<byte[]> listAttachments(List<String> fileNames);

//Check if the email is multipart mail
boolean isMultiPart();

//Return the number of lines in the content of this part. Return -1 if the number cannot be determined. Note that this number may not be an exact measure of the content length and may or may not account for any transfer encoding of the content
int getLineCount();

//Returns the Content-Type of the content of this part. Returns null if the Content-Type could not be determined
String getContentType();

//Is this Part of the specified MIME type? This method compares only the primaryType and subType. The parameters of the content types are ignored.
boolean isMimeType(String mimeType);

//Return a description String for this part. This typically associates some descriptive information with this part. Returns null if none is available
String getDescription();

//Get all the recipient addresses of the given type
Address[] getRecipients(RecipientType type);

//Get all the recipient addresses for the message. The default implementation extracts the TO, CC, and BCC recipients using the getRecipients method.
Address[] getAllRecipients();

//Return a DataHandler for the content within this part. The DataHandler allows clients to operate on as well as retrieve the content.
DataHandler getDataHandler();

//Get's the content as string object
String getContentString();

//Get the addresses to which replies should be directed. This will usually be the sender of the message, but some messages may direct replies to a different address.
Address[] getReplyTo();

//Get the subject of this message.
String getSubject();

//Get the date this message was sent.
Date getSentDate();

//Get the date this message was received.
Date getReceivedDate();

//Return all the headers from this part as an Enumeration of Header objects.
Enumeration<?> getAllHeaders();

//Return matching headers from this part as an Enumeration of Header objects
Enumeration<?> getMatchingHeaders(String[] header_names);

//Return non-matching headers from this envelope as an Enumeration of Header objects
Enumeration<?> getNonMatchingHeaders(String[] header_names);

//Get the Message number for this Message. A Message object's message number is the relative position of this Message in its Folder. Note that the message number for a particular Message can change during a session if other messages in the Folder are deleted and expunged
int getMessageNumber();

//Get the folder from which this message was obtained. If this is a new message or nested message, this method returns null
Folder getFolder();

//Checks whether this message is expunged. All other methods except getMessageNumber() are invalid on an expunged Message object
boolean isExpunged();

//Marks the message as SEEN
void markAsRead();

//Marks the message as UNSEEN
void markAsUnRead();

API's Inherited

Context Base

See Also

Email Input