Show / Hide Table of Contents

Class MailCache

Class that handles e-mail caching to the superoffice db

Inheritance
Object
MailCache
Inherited Members
Object.ToString()
Object.Equals(Object)
Object.Equals(Object, Object)
Object.ReferenceEquals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Namespace: SuperOffice.CRM.Mail
Assembly: SoDataBase.dll
Syntax
public static class MailCache

Fields

RecipientConceptualType

Declaration
public const string RecipientConceptualType = "RecipientList"
Field Value
Type Description
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
Int32 associateId

Id of associate to cache folders for

SoMailCredentials credentials

Login credentials for mail server/account

String folder

If specified, cache only this folder

Returns
Type Description
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
Int32 associateId

Id of associate to cache folders for

SoMailCredentials credentials

Login credentials for mail server/account

String folder

If specified, cache only this folder

Int32 folderCount

out parameter, returns number of envelopes in selected folder

Int32 downloadedEnvelopeCount

out parameter, returns number of new elements downloaded

Int32 cachedEnvelopeCount

out parameter, returns number of envelopes in cache

Returns
Type Description
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
Int32 assocId

Associate to cache item for

String server

Mail server

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
Int32 associateId

Associate id

String folder
SoMailCredentials mailCredentials

Mail credentials to provide information about the context

Int32[] messageIdList

list of message ids to delete

findFolderSeparator(Int32)

Declaration
public static string findFolderSeparator(int accountId)
Parameters
Type Name Description
Int32 accountId
Returns
Type Description
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
Int32[] idList
Returns
Type Description
Boolean

findOrCreateEmailFolder(Int32, MailFolder, Boolean)

Declaration
public static int[] findOrCreateEmailFolder(int accountId, MailFolder folder, bool updateAttributes = false)
Parameters
Type Name Description
Int32 accountId
SuperOffice.CRM.Mail.MailFolder folder
Boolean updateAttributes
Returns
Type Description
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
Int32 accountId
String folder
String delimiter
Returns
Type Description
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
Int32 assocId
String server
String username
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
Int32 assocId

Id of associate

String server

Mail server

String username

Mail server account

String folder

Name of folder

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
Int32 assocId

Id of associate

String server

Mail server

String username

Mail server account

String folder

Name of folder

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
Int32 assocId

Id of associate to retrieve item from

String server

Mail server

String username

Mail server account

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
Int32 assocId

Id of associate to retrieve item from

SoMailCredentials credentials

Mail server credentials

Returns
Type Description
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
Int32 assocId

Id of associate to retrieve item from

String server

Mail server

String username

Mail server account

Int32 messageId

Id of message to retrieve

String folder

The item belongs to this folder

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
Int32 associateId
SoMailCredentials credentials
Returns
Type Description
Boolean

GetDraftsFolderName(Int32)

Declaration
public static string GetDraftsFolderName(int accountId)
Parameters
Type Name Description
Int32 accountId
Returns
Type Description
String

GetEmailAccountId(Int32, String, String)

Declaration
public static int GetEmailAccountId(int assocId, string server, string username)
Parameters
Type Name Description
Int32 assocId
String server
String username
Returns
Type Description
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
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
Int32 folderId
Returns
Type Description
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
Boolean mime
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
Int32 serverId
EMailFlags flags
Returns
Type Description
SuperOffice.CRM.Mail.MailEnvelope

GetSentFolderName(Int32)

Get the full name of the first folder with the Sent attribute in the database.

Declaration
public static string GetSentFolderName(int accountId)
Parameters
Type Name Description
Int32 accountId
Returns
Type Description
String

GetSentFolderNames(Int32)

Get all folders marked with the Sent folder attribute

Declaration
public static string[] GetSentFolderNames(int emailAccountId)
Parameters
Type Name Description
Int32 emailAccountId
Returns
Type Description
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
Int32 accountId
Int32 folderAttribute

EMailFolderAttributeConstants

Returns
Type Description
String

GetSpecialFolderNames(Int32, Int32)

Declaration
public static string[] GetSpecialFolderNames(int accountId, int folderAttribute)
Parameters
Type Name Description
Int32 accountId
Int32 folderAttribute
Returns
Type Description
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
Int32 accountId
Returns
Type Description
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
Int32 associateId

Associate id

String folder

Folder where the messages are stored

SoMailCredentials mailCredentials

Mail credentials providing information about the current context

Int32[] messageIdList

List of message ids to to mark

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
Int32 assocId

Associate to cache item for

String server

Mail server

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
Int32 assocId

Associate to cache item for

String server

Mail server

String username

Mail server account

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
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
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
Int32 associateId

Id of associate to cache folders for

SoMailCredentials credentials

Login credentials for mail server/account

String folder

If specified, cache only this folder

Returns
Type Description
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
Int32 associateId

Id of associate to cache data for

SoMailCredentials credentials

Mail credentials

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
Int32 assosciateId
SuperOffice.CRM.Mail.MailEnvelope mail

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
Int32 associateId
SoMailCredentials credentials
String folder
Returns
Type Description
Boolean
© SuperOffice. All rights reserved.
SuperOffice |  Community |  Release Notes |  Privacy |  Site feedback |  Search Docs |  About Docs |  Back to top