XQuery Function Documentation

Search and Browse

http://exist-db.org/xquery/mail

java:org.exist.xquery.modules.mail.MailModule

A module for performing email related functions

mail:close-mail-folder

mail:close-mail-folder($mail-folder-handle as xs:integer, $expunge as xs:boolean) as item()

Closes a mail folder.

Parameters:
$mail-folder-handle The mail folder handle retrieved from mail:get-mail-folder()
$expunge A boolean that specifies whether to expunge the folder on close.
Returns:
item()

mail:close-mail-store

mail:close-mail-store($mail-store-handle as xs:integer) as item()

Closes a mail store.

Parameters:
$mail-store-handle The mail store handle retrieved from mail:get-mail-store()
Returns:
item()

mail:close-message-list

mail:close-message-list($message-list-handle as xs:integer) as item()

Closes a message list.

Parameters:
$message-list-handle The message list handle retrieved from mail:get-message-list() or mail:search-message-list()
Returns:
item()

mail:get-mail-folder

mail:get-mail-folder($mail-store-handle as xs:integer, $foldername as xs:string) as xs:long?

Opens a mail folder.

Parameters:
$mail-store-handle The mail store handle retrieved from mail:get-mail-store()
$foldername The name of the folder to open
Returns:
xs:long? : an xs:long representing the folder handle.

mail:get-mail-session

mail:get-mail-session($properties as element()?) as xs:long?

Open's a JavaMail session.

Parameters:
$properties? An optional JavaMail session properties in the form <properties><property name="" value=""/></properties>. The JavaMail properties are spelled out in Appendix A of the JavaMail specifications.
Returns:
xs:long? : an xs:long representing the session handle.

mail:get-mail-store

mail:get-mail-store($mail-handle as xs:integer) as xs:long?

Opens a mail store. Host/User/Password/Protocol values will be obtained from the session.

Parameters:
$mail-handle The JavaMail session handle retrieved from mail:get-mail-session()
Returns:
xs:long? : an xs:long representing the store handle.

mail:get-message-list

mail:get-message-list($mail-folder-handle as xs:integer) as xs:long?

Returns a message list of all messages in a folder.

Parameters:
$mail-folder-handle The mail folder handle retrieved from mail:get-mail-folder()
Returns:
xs:long? : an xs:long representing the message list handle.

mail:get-message-list-as-xml

mail:get-message-list-as-xml($message-list-handle as xs:integer, $include-headers as xs:boolean) as element()?

Returns a message list of all messages in a folder as XML. If there are no messages in the list, an empty sequence will be returned

Parameters:
$message-list-handle The message list handle retrieved from mail:get-message-list() or mail:search-message-list()
$include-headers A boolean specifying whether to include message headers
Returns:
element()? : the list of all messages in a folder as XML

mail:get-messages

mail:get-messages($message-list-handle as xs:integer, $message-numbers as xs:integer*) as element()?

Returns a sequence of emails as XML. If there are no messages-numbers in the list, an empty sequence will be returned. Please see get_messages_example.xql.

Parameters:
$message-list-handle The message list handle retrieved from mail:get-message-list() or mail:search-message-list()
$message-numbers* The messages to retrieve using the numbers from the message-list '//mail:message/@number'
Returns:
element()? : the chosen messages as XML mail:messages/mail:message

mail:search-message-list

mail:search-message-list($mail-folder-handle as xs:integer, $search-parameters as element()) as xs:long?

Searches messages in a folder. Search terms are of the form <searchTerm type="xxx">...</searchTerm>. Valid types include: not, and, or, from, subject, body, recipient, header, flag, sent, received. <searchTerm type="not"> requires a single nested child search term. <searchTerm type="and"> and <searchTerm type="or"> must have one or more nested child search terms. <searchTerm type="from" pattern="pat">, <searchTerm type="subject" pattern="pat"> and <searchTerm type="body" pattern="pat"> require a pattern attribute and will search for a substring that matches the pattern. <searchTerm type="recipient" pattern="pat" recipientType="to|cc|bcc"> requires pattern and recipientType attributes. <searchTerm type="header" pattern="pat" name="Content-Type"> requires pattern and name attributes. <searchTerm type="flag" flag="answered|deleted|draft|recent|seen" value="true|false"> requires flag and value attributes. <searchTerm type="sent" comparison="eq|gt|ge|lt|le|ne" format="format" date="date"> and <searchTerm type="received" comparison="eq|gt|ge|lt|le|ne" format="format" date="date"> require comparison, format and date attributes. The format string should conform to Java SimpleDateFormat specifications and the date string must conform to the specified format string.

Parameters:
$mail-folder-handle The mail folder handle retrieved from mail:get-mail-folder()
$search-parameters The xml fragment defining the search terms
Returns:
xs:long? : an xs:long representing the message list handle.

mail:send-email

mail:send-email($mail-handle as xs:long, $email as element()+) as item()

Sends an email using javax.mail messaging libraries.

Parameters:
$mail-handle The JavaMail session handle retrieved from mail:get-mail-session()
$email+ The email message in the following format: <mail> <from/> <reply-to/> <to/> <cc/> <bcc/> <subject/> <message> <text/> <xhtml/> </message> <attachment filename="" mimetype="">xs:base64Binary</attachment> </mail>.
Returns:
item()

mail:send-email

mail:send-email($email as element()+, $server as xs:string?, $charset as xs:string?) as xs:boolean+

Sends an email through the SMTP Server.

Parameters:
$email+ The email message in the following format: <mail> <from/> <reply-to/> <to/> <cc/> <bcc/> <subject/> <message> <text/> <xhtml/> </message> <attachment filename="" mimetype="">xs:base64Binary</attachment> </mail>.
$server? The SMTP server. If empty, then it tries to use the local sendmail program.
$charset? The charset value used in the "Content-Type" message header (Defaults to UTF-8)
Returns:
xs:boolean+ : true if the email message was successfully sent