Class CachedMailController
- extends BaseMailController
CachedMailController provides methods to access all server-side mail-related
functions and data. The Mail Controller provides an out-of-the-box caching mechanism
that caches the currently selected/ opened folder.
Methods
void
addFolder
(
options
,
options.fn
,
options.pfid
)
Add a new mail folder
- Parameters:
-
options
<Object>
Object literal of parameter values containing:
-
options.fn
<String>
Folder name
-
options.pfid
<String>
Folder's Parent id (if folder being added is a sub-folder)
- Returns:
void
void
deleteFolder
(
options
,
options.fid
)
Delete the specified mail folder
- Parameters:
-
options
<Object>
Object literal of parameter values containing:
-
options.fid
<String>
Folder id
- Returns:
void
void
deleteMessages
(
options
,
options.fid
,
options.mid
)
Delete the given messages for the specified folder id
- Parameters:
-
options
<Object>
Object literal of parameter values containing:
-
options.fid
<String>
Folder id
-
options.mid
<String []>
Message id(s)
- Returns:
void
void
emptyFolder
(
options
,
options.fid
)
Empty the specified mail folder
- Parameters:
-
options
<Object>
Object literal of parameter values containing:
-
options.fid
<String>
Folder id
- Returns:
void
object
getAttachmentURI
(
options
,
attachment
)
Takes an attachment object (property of a Message object) and returns a URI to the attachment.
- Parameters:
-
options
<Object>
Object literal of parameter values containing:
-
attachment
<Object>
An Attachment object to generate a URL for
- Returns:
object
- Returns an attachment
void
getExternalEmail
(
)
POP Account Aggregation. Initiates a POP account aggregation request.
Array
getFolderList
(
)
Returns a list of mail Folder objects belonging to the currently logged-in user.
- Returns:
Array
- Array of folder objects
Object | Boolean
getFolderObject
(
options
,
options.fid
)
Returns a Folder object for the specified folder id
- Parameters:
-
options
<Object>
Object literal of parameter values containing:
-
options.fid
<String>
Folder id
- Returns:
Object | Boolean
- specified folder (Folder) or
false
if none found.
object
getMessage
(
options
)
Returns the specified message from the controller's cache
- Parameters:
-
options
<Object>
Object literal of parameter values. NB: This is the same
configuration object passed into loadMessage.
- Returns:
object
- A Message object with the following properties:
attachments, bcc, bodyhtml, cc, date, fn, mid, msgheaders, sender, subject, timezone, to, etc.
Array
getMessageIds
(
)
Returns a list of message IDs for the current folder
- Returns:
Array
- Array of folder objects
void
getMessages
(
options
)
Returns a list of Mail Messages (from start to end index) for the specified folder.
- Parameters:
-
options
<Object>
Object literal of parameter values. NB: This is the same
configuration object passed into loadMessages.
- Returns:
void
Object
getSelectedFolder
(
)
Returns the currently selected/opened Folder object
- Returns:
Object
- The selected Folder object
object
getUsage
(
)
Get the mail quota for the currently logged-in user
- Returns:
object
- Mail Quota object. The object's properties are:
percentage, total
void
loadFolderCount
(
options
,
options.ignoreError
)
Loads the folder count (total/unread messages) of user's mail folders into the cache.
- Parameters:
-
options
<Object>
Object literal of parameter values containing:
-
options.ignoreError
<Boolean>
(Optional) indicates whether to ignore the server response containing an error code.
- Returns:
void
void
loadFolderList
(
options
,
options.ignoreError
)
Load the currently logged-in user's mail folders into the cache.
- Parameters:
-
options
<Object>
Object literal of parameter values containing:
-
options.ignoreError
<Boolean>
(Optional) indicates whether to ignore the server response containing an error code.
- Returns:
void
void
loadMessage
(
options
,
options.fid
,
options.mid
)
Load the specified message. If the specified message exists in the controller cache, it is
returned instead of re-requesting it from the server.
- Parameters:
-
options
<Object>
Object literal of parameter values containing:
-
options.fid
<String>
Folder id
-
options.mid
<String>
Message id
- Returns:
void
void
loadMessages
(
options
,
options.fid
,
options.start
,
options.end
,
options.sc
,
options.so
,
options.sk
,
options.check
,
options.pop
,
options.invalidateCache
)
Load messages for the given folder from start to end indices. However,
if invalidateCache is true, a request to load the messages from the server
is made regardless of whether the specified messages exist in the cache.
- Parameters:
-
options
<Object>
Object literal of parameter values containing:
-
options.fid
<String>
Folder id
-
options.start
<Number>
Start position/index of the messages to load
-
options.end
<Number>
End position/index of the messages to load
-
options.sc
<String>
Sort column
-
options.so
<String>
Sort order (one of 2 values: asc or desc)
-
options.sk
<Object>
(Optional) Search keyword(s). Uses the following format:
Example:
subject:"test",
sender: "wau@nitido.com"
-
options.check
<Boolean>
(Optional) Indicates whether to just perform a "check mail" operation
-
options.pop
<Boolean>
(Optional) Indicates whether to perform a POP account check/download
-
options.invalidateCache
<Boolean>
(Optional) Tells the controller to bypass the cache and request
messages from the server
- Returns:
void
void
loadUsage
(
options
,
options.ignoreError
)
Load the mail quota from the server for the currently active user
- Parameters:
-
options
<Object>
Object literal of parameter values containing:
-
options.ignoreError
<Boolean>
(Optional) indicates whether to ignore the server response containing an error code.
- Returns:
void
void
markAsSpam
(
options
,
options.fid
,
options.mid
)
Mark the given message as spam/not spam
- Parameters:
-
options
<Object>
Object literal of parameter values containing:
-
options.fid
<String>
Folder id the message(s) belong to
-
options.mid
<String []>
Message id(s)
- Returns:
void
void
moveMessages
(
options
,
options.sfid
,
options.tfid
,
options.mid
)
Move the specified messages from the source folder to the target folder
- Parameters:
-
options
<Object>
Object literal of parameter values containing:
-
options.sfid
<String>
Source folder id
-
options.tfid
<String>
Target folder id
-
options.mid
<String []>
Message id(s)
- Returns:
void
void
renameFolder
(
options
,
options.nfn
,
options.ofid
,
options.pfid
)
Rename the given (existing) folder
- Parameters:
-
options
<Object>
Object literal of parameter values containing:
-
options.nfn
<String>
New folder name
-
options.ofid
<String>
Folder id
-
options.pfid
<String>
(Optional) Folder's Parent id (if folder being renamed is a sub-folder)
- Returns:
void
void
saveAsDraft
(
options
,
options.msg
)
Save the given message as a draft.
- Parameters:
-
options
<Object>
Object literal of parameter values containing:
-
options.msg
<Object>
Message object
- Returns:
void
void
sendMessage
(
options
,
options.msg
,
options.action
,
options.omid
,
options.fid
)
Send a message. At least one recipient must be specified in order to successfully
send the message.
- Parameters:
-
options
<Object>
Object literal of parameter values containing:
-
options.msg
<Object>
Message object
-
options.action
<String>
(Optional) Indicates if email being sent is a reply or a forward
to an original email. Can have one of the following two values:
- f - Indicates this is a forward action
- r - Indicates this is a reply action
-
options.omid
<String>
(Optional) The original message id (when replying to, or forwarding, a message)
-
options.fid
<String>
(Optional) The original folder id (when replying to, or forwarding, a message)
- Returns:
void
void
setMessageFlag
(
options
,
options.mid
,
options.fid
,
options.flag
)
Set a flag for the given messages
- Parameters:
-
options
<Object>
Object literal of parameter values containing:
-
options.mid
<String []>
Message's ID(s)
-
options.fid
<String>
Folder id
-
options.flag
<Number>
The following flags are available:
- 0 - mark messages as unread
- 1 - mark messages as read
- 2 - mark messages as "flagged"
- 3 - unmark messages as "flagged"
- on|<tagname> - Adds a user-defined tag to the message. <tagname> is a custom user-
defined tag. | is the Unix pipe character.
- off|<tagname> - Removes a user-defined tag from the message. <tagname> is a
custom user-defined tag. | is the Unix pipe character.
- Returns:
void
void
subscribe
(
options
,
options.name
,
options.callback
)
Subscribe to a custom event from the Mail Controller
- Parameters:
-
options
<Object>
Object literal of parameter values containing:
-
options.name
<String>
The event name to subscribe to
-
options.callback
<Function>
The callback method to call when the event fires
- Returns:
void
void
unsubscribe
(
options
,
options.name
,
options.callback
)
Subscribe to a custom event from the Mail Controller
- Parameters:
-
options
<Object>
Object literal of parameter values containing:
-
options.name
<String>
The event name to unsubscribe from
-
options.callback
<Function>
The callback method associated to the original subscription
- Returns:
void
addFolder,
deleteFolder,
deleteMessages,
destroy,
emptyFolder,
filterMessages,
getFolderObject,
getMessage,
getMessages,
getPOPEmails,
getSelectedFolder,
getSelectedFolderObject,
getSelectedMessage,
loadFolderCount,
loadFolderList,
loadMessage,
loadMessages,
loadUsage,
markAsSpam,
moveMessages,
renameFolder,
saveAsDraft,
sendMessage,
setMessageFlag,
setSelectedFolder,
setSelectedMessage