Class MailCache
Class that handles e-mail caching to the superoffice db
Inheritance
Namespace: SuperOffice.CRM.Mail
Assembly: SoDataBase.dll
Syntax
public static class MailCache : Object
Fields
RecipientConceptualType
Declaration
public const string RecipientConceptualType = "RecipientList"
Field Value
Type | Description |
---|---|
System.String |
Methods
CacheMailForAssociate(Int32, SoMailCredentials, String)
Cache all subscribed mail folders or specified folder for a specified associate
Declaration
public static bool CacheMailForAssociate(int associateId, SoMailCredentials credentials, string folder)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | associateId | Id of associate to cache folders for |
SoMailCredentials | credentials | Login credentials for mail server/account |
System.String | folder | If specified, cache only this folder |
Returns
Type | Description |
---|---|
System.Boolean | True if one or more new messages was found on the server. Checked against the message id. |
CacheMailForAssociate(Int32, SoMailCredentials, String, out Int32, out Int32, out Int32)
Cache all subscribed mail folders or specified folder for a specified associate
Declaration
public static bool CacheMailForAssociate(int associateId, SoMailCredentials credentials, string folder, out int folderCount, out int downloadedEnvelopeCount, out int cachedEnvelopeCount)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | associateId | Id of associate to cache folders for |
SoMailCredentials | credentials | Login credentials for mail server/account |
System.String | folder | If specified, cache only this folder |
System.Int32 | folderCount | out parameter, returns number of envelopes in selected folder |
System.Int32 | downloadedEnvelopeCount | out parameter, returns number of new elements downloaded |
System.Int32 | cachedEnvelopeCount | out parameter, returns number of envelopes in cache |
Returns
Type | Description |
---|---|
System.Boolean | True if one or more new messages was found on the server. |
ClearCachedFolderInfo(Int32, String, String)
Cache mail folder info to the database
Declaration
public static void ClearCachedFolderInfo(int assocId, string server, string username)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | assocId | Associate to cache item for |
System.String | server | Mail server |
System.String | username | Mail server account |
DeleteCachedEnvelopes(Int32, String, SoMailCredentials, Int32[])
Deletes envelopes in the cache
Declaration
public static void DeleteCachedEnvelopes(int associateId, string folder, SoMailCredentials mailCredentials, int[] messageIdList)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | associateId | Associate id |
System.String | folder | |
SoMailCredentials | mailCredentials | Mail credentials to provide information about the context |
System.Int32[] | messageIdList | list of message ids to delete |
findFolderSeparator(Int32)
Declaration
public static string findFolderSeparator(int accountId)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | accountId |
Returns
Type | Description |
---|---|
System.String |
FindMessageInIdList(MailEnvelope, Int32[])
returns true if a message exists in the given list of messageids
Declaration
public static bool FindMessageInIdList(MailEnvelope envelope, int[] idList)
Parameters
Type | Name | Description |
---|---|---|
SuperOffice.CRM.Mail.MailEnvelope | envelope | |
System.Int32[] | idList |
Returns
Type | Description |
---|---|
System.Boolean |
findOrCreateEmailFolder(Int32, MailFolder, Boolean)
Declaration
public static int[] findOrCreateEmailFolder(int accountId, MailFolder folder, bool updateAttributes = false)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | accountId | |
SuperOffice.CRM.Mail.MailFolder | folder | |
System.Boolean | updateAttributes |
Returns
Type | Description |
---|---|
System.Int32[] | An array of folder ids, with the element in the first index of the array the topmost parent |
findOrCreateEmailFolder(Int32, String, String)
Declaration
public static int[] findOrCreateEmailFolder(int accountId, string folder, string delimiter = "")
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | accountId | |
System.String | folder | |
System.String | delimiter |
Returns
Type | Description |
---|---|
System.Int32[] | An array of folder ids, with the element in the first index of the array the topmost parent |
GetCachedEnvelopes(Int32, String, String, String)
Declaration
public static MailEnvelope[] GetCachedEnvelopes(int assocId, string server, string username, string folder)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | assocId | |
System.String | server | |
System.String | username | |
System.String | folder |
Returns
Type | Description |
---|---|
SuperOffice.CRM.Mail.MailEnvelope[] |
GetCachedEnvelopes(Int32, String, String, String, out DateTime)
Get cached envelopes of a folder for a specified associate
Declaration
public static MailEnvelope[] GetCachedEnvelopes(int assocId, string server, string username, string folder, out DateTime lastMailDate)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | assocId | Id of associate |
System.String | server | Mail server |
System.String | username | Mail server account |
System.String | folder | Name of folder |
System.DateTime | lastMailDate | Date and time of arrival at mail server, of latest mail |
Returns
Type | Description |
---|---|
SuperOffice.CRM.Mail.MailEnvelope[] | Populated MailEnvelope array |
GetCachedEnvelopes(Int32, String, String, String, out Int32)
Get cached envelopes of a folder for a specified associate
Declaration
public static MailEnvelope[] GetCachedEnvelopes(int assocId, string server, string username, string folder, out int lastMailUID)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | assocId | Id of associate |
System.String | server | Mail server |
System.String | username | Mail server account |
System.String | folder | Name of folder |
System.Int32 | lastMailUID |
Returns
Type | Description |
---|---|
SuperOffice.CRM.Mail.MailEnvelope[] | Populated MailEnvelope array |
GetCachedFolderInfo(Int32, String, String, String[])
Returns the number of items in a given list of folders
Declaration
public static SoMailFolderInfo[] GetCachedFolderInfo(int assocId, string server, string username, string[] folderList)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | assocId | Id of associate to retrieve item from |
System.String | server | Mail server |
System.String | username | Mail server account |
System.String[] | folderList | List of folder names to return count from |
Returns
Type | Description |
---|---|
SuperOffice.CRM.Mail.SoMailFolderInfo[] |
GetCachedFolderList(Int32, SoMailCredentials)
Returns a cached list of folders
Declaration
public static string[] GetCachedFolderList(int assocId, SoMailCredentials credentials)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | assocId | Id of associate to retrieve item from |
SoMailCredentials | credentials | Mail server credentials |
Returns
Type | Description |
---|---|
System.String[] |
GetCachedMailItem(Int32, String, String, Int32, String, Boolean)
Look for and return a MailItem from the database. If item is not found, null is returned.
Declaration
public static MailItem GetCachedMailItem(int assocId, string server, string username, int messageId, string folder, bool includeAttachments)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | assocId | Id of associate to retrieve item from |
System.String | server | Mail server |
System.String | username | Mail server account |
System.Int32 | messageId | Id of message to retrieve |
System.String | folder | The item belongs to this folder |
System.Boolean | includeAttachments | If true, cached object need to contain all attachments |
Returns
Type | Description |
---|---|
SuperOffice.CRM.Mail.MailItem | MailItem object, or null if no object is found |
GetCachingStarted(Int32, SoMailCredentials)
Check if there is a ForeignKey record that matches the account, has the active subkey, and is between 0 and 60 minutes old
Declaration
public static bool GetCachingStarted(int associateId, SoMailCredentials credentials)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | associateId | |
SoMailCredentials | credentials |
Returns
Type | Description |
---|---|
System.Boolean |
GetDraftsFolderName(Int32)
Declaration
public static string GetDraftsFolderName(int accountId)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | accountId |
Returns
Type | Description |
---|---|
System.String |
GetEmailAccountId(Int32, String, String)
Declaration
public static int GetEmailAccountId(int assocId, string server, string username)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | assocId | |
System.String | server | |
System.String | username |
Returns
Type | Description |
---|---|
System.Int32 |
GetEnvelopeFromDataReader(SoDataReader)
Declaration
public static MailEnvelope GetEnvelopeFromDataReader(SoDataReader reader)
Parameters
Type | Name | Description |
---|---|---|
SoDataReader | reader |
Returns
Type | Description |
---|---|
SuperOffice.CRM.Mail.MailEnvelope |
GetFolderName(EmailFolderRow)
Constructs the full directory path from the given folder row to the root folder.
Declaration
public static string GetFolderName(EmailFolderRow folderRow)
Parameters
Type | Name | Description |
---|---|---|
EmailFolderRow | folderRow |
Returns
Type | Description |
---|---|
System.String |
GetFolderName(Int32)
Constructs the full directory path from the given folder to the root folder.
Declaration
public static string GetFolderName(int folderId)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | folderId |
Returns
Type | Description |
---|---|
System.String |
GetInboxFolderName(Int32, Boolean)
Declaration
public static string GetInboxFolderName(int accountId, bool create = true)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | accountId | |
System.Boolean | create |
Returns
Type | Description |
---|---|
System.String |
GetMailItemFromDataReader(SoDataReader)
Declaration
public static MailItem GetMailItemFromDataReader(SoDataReader reader)
Parameters
Type | Name | Description |
---|---|---|
SoDataReader | reader |
Returns
Type | Description |
---|---|
SuperOffice.CRM.Mail.MailItem |
GetMailItemFromDbRow(EmailItemRow, Boolean, Boolean)
Declaration
public static MailItem GetMailItemFromDbRow(EmailItemRow row, bool mime = false, bool streams = false)
Parameters
Type | Name | Description |
---|---|---|
EmailItemRow | row | |
System.Boolean | mime | |
System.Boolean | streams |
Returns
Type | Description |
---|---|
SuperOffice.CRM.Mail.MailItem |
GetMinimalMailEnvelope(Int32, EMailFlags)
Declaration
public static MailEnvelope GetMinimalMailEnvelope(int serverId, EMailFlags flags)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | serverId | |
EMailFlags | flags |
Returns
Type | Description |
---|---|
SuperOffice.CRM.Mail.MailEnvelope |
GetSentFolderName(Int32, Boolean)
Get the full name of the first folder with the Sent attribute in the database.
Declaration
public static string GetSentFolderName(int accountId, bool create = true)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | accountId | |
System.Boolean | create |
Returns
Type | Description |
---|---|
System.String |
GetSentFolderNames(Int32)
Get all folders marked with the Sent folder attribute
Declaration
public static string[] GetSentFolderNames(int emailAccountId)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | emailAccountId |
Returns
Type | Description |
---|---|
System.String[] |
GetSpecialFolderName(Int32, Int32)
Get all folders for a given account with the provided folder attribute
Declaration
public static string GetSpecialFolderName(int accountId, int folderAttribute)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | accountId | |
System.Int32 | folderAttribute | EMailFolderAttributeConstants |
Returns
Type | Description |
---|---|
System.String |
GetSpecialFolderNames(Int32, Int32)
Declaration
public static string[] GetSpecialFolderNames(int accountId, int folderAttribute)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | accountId | |
System.Int32 | folderAttribute |
Returns
Type | Description |
---|---|
System.String[] |
GetTrashFolderName(Int32)
Get the full name of the folder with the Trash attribute in the database.
Declaration
public static string GetTrashFolderName(int accountId)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | accountId |
Returns
Type | Description |
---|---|
System.String |
SetCachedEnvelopesRead(Int32, String, SoMailCredentials, Int32[], Boolean)
Updates the read state for envelopes in the cache
Declaration
public static void SetCachedEnvelopesRead(int associateId, string folder, SoMailCredentials mailCredentials, int[] messageIdList, bool read)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | associateId | Associate id |
System.String | folder | Folder where the messages are stored |
SoMailCredentials | mailCredentials | Mail credentials providing information about the current context |
System.Int32[] | messageIdList | List of message ids to to mark |
System.Boolean | read | Mark as read or unread |
SetCachedFolderInfo(Int32, String, String, SoMailFolderInfo[])
Cache mail folder info to the database
Declaration
public static void SetCachedFolderInfo(int assocId, string server, string username, SoMailFolderInfo[] folderInfo)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | assocId | Associate to cache item for |
System.String | server | Mail server |
System.String | username | Mail server account |
SuperOffice.CRM.Mail.SoMailFolderInfo[] | folderInfo | Folder information to cache |
SetCachedFolderList(Int32, String, String, String[])
Cache mail folder list to the database. This should be the list without any information about number of read/unread items so that the folder list can be retrieved fast.
Declaration
public static void SetCachedFolderList(int assocId, string server, string username, string[] folderList)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | assocId | Associate to cache item for |
System.String | server | Mail server |
System.String | username | Mail server account |
System.String[] | folderList | Folder list to cache |
SetCachingFinished(Int32, SoMailCredentials)
Update the ForeignKey record to Inactive SubKey value
Declaration
public static void SetCachingFinished(int associateId, SoMailCredentials credentials)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | associateId | |
SoMailCredentials | credentials |
SetCachingStarted(Int32, SoMailCredentials)
If needed, create the ForeignKey record; make sure sure it has the Actvie Subkey value, and updated = Now
Declaration
public static void SetCachingStarted(int associateId, SoMailCredentials credentials)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | associateId | |
SoMailCredentials | credentials |
UpdateCacheWithNewEMail(Int32, SoMailCredentials, String)
Updates the cache with new email that has arrived after the last one in the cache.
Declaration
public static bool UpdateCacheWithNewEMail(int associateId, SoMailCredentials credentials, string folder)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | associateId | Id of associate to cache folders for |
SoMailCredentials | credentials | Login credentials for mail server/account |
System.String | folder | If specified, cache only this folder |
Returns
Type | Description |
---|---|
System.Boolean | True if one or more new messages was found on the server. Checked against the message id. |
UpdateMailCacheForAssociate(Int32, SoMailCredentials, String, MailEnvelope[])
Update the associate mail cache with new data
Declaration
public static void UpdateMailCacheForAssociate(int associateId, SoMailCredentials credentials, string folder, MailEnvelope[] envelopes)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | associateId | Id of associate to cache data for |
SoMailCredentials | credentials | Mail credentials |
System.String | folder | Folder the envelopes belong to |
SuperOffice.CRM.Mail.MailEnvelope[] | envelopes | The new data |
UpdateRecipientList(Int32, MailEnvelope)
Declaration
public static void UpdateRecipientList(int assosciateId, MailEnvelope mail)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | assosciateId | |
SuperOffice.CRM.Mail.MailEnvelope |
UpdateStatusAndDeletedEnvelopes(Int32, SoMailCredentials, String)
Checks all messages in the cache and removes deleted and changes status.
Declaration
public static bool UpdateStatusAndDeletedEnvelopes(int associateId, SoMailCredentials credentials, string folder)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | associateId | |
SoMailCredentials | credentials | |
System.String | folder |
Returns
Type | Description |
---|---|
System.Boolean |