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.BusinessLogic.dll
Syntax
public static class MailCache

Fields

RecipientConceptualType

Class that handles e-mail caching to the superoffice db

Declaration
public const string RecipientConceptualType = "RecipientList"
Field Value
Type Description
string

Methods

CacheMailForAssociateAsync(int, SoMailCredentials, string, CancellationToken)

Cache all subscribed mail folders or specified folder for a specified associate

Declaration
public static Task<(bool changes, int folderCount, int downloadedEnvelopeCount, int cachedEnvelopeCount)> CacheMailForAssociateAsync(int associateId, SoMailCredentials credentials, string folder, CancellationToken cancellationToken)
Parameters
Type Name Description
int associateId

Id of associate to cache folders for

SoMailCredentials credentials

Login credentials for mail server/account

string folder

If specified, cache only this folder

CancellationToken cancellationToken
Returns
Type Description
Task<(bool changes, int folderCount, int downloadedEnvelopeCount, int cachedEnvelopeCount)>

True if one or more new messages was found on the server.

ClearCachedFolderInfo(int, string, string)

Cache mail folder info to the database

Declaration
public static void ClearCachedFolderInfo(int assocId, string server, string username)
Parameters
Type Name Description
int assocId

Associate to cache item for

string server

Mail server

string username

Mail server account

FindFolderSeparatorAsync(int, CancellationToken)

Class that handles e-mail caching to the superoffice db

Declaration
public static Task<string> FindFolderSeparatorAsync(int accountId, CancellationToken cancellationToken)
Parameters
Type Name Description
int accountId
CancellationToken cancellationToken
Returns
Type Description
Task<string>

FindMessageInIdList(MailEnvelope, int[])

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
MailEnvelope envelope
int[] idList
Returns
Type Description
bool

FindOrCreateEmailFolderAsync(int, MailFolder, CancellationToken, bool)

Class that handles e-mail caching to the superoffice db

Declaration
public static Task<int[]> FindOrCreateEmailFolderAsync(int accountId, MailFolder folder, CancellationToken cancellationToken, bool updateAttributes = false)
Parameters
Type Name Description
int accountId
MailFolder folder
CancellationToken cancellationToken
bool updateAttributes
Returns
Type Description
Task<int[]>

An array of folder ids, with the element in the first index of the array the topmost parent

FindOrCreateEmailFolderAsync(int, string, string, CancellationToken)

Class that handles e-mail caching to the superoffice db

Declaration
public static Task<int[]> FindOrCreateEmailFolderAsync(int accountId, string folder, string delimiter = "", CancellationToken cancellationToken = default)
Parameters
Type Name Description
int accountId
string folder
string delimiter
CancellationToken cancellationToken
Returns
Type Description
Task<int[]>

An array of folder ids, with the element in the first index of the array the topmost parent

GetCachedEnvelopesAsync(int, string, string, string, CancellationToken)

Class that handles e-mail caching to the superoffice db

Declaration
public static Task<(MailEnvelope[] envelopes, int lastMailUID, DateTime lastMailDate)> GetCachedEnvelopesAsync(int assocId, string server, string username, string folder, CancellationToken cancellationToken)
Parameters
Type Name Description
int assocId
string server
string username
string folder
CancellationToken cancellationToken
Returns
Type Description
Task<(MailEnvelope[] envelopes, int lastMailUID, DateTime lastMailDate)>

GetCachedFolderInfoAsync(int, string, string, string[], CancellationToken)

Returns the number of items in a given list of folders

Declaration
public static Task<SoMailFolderInfo[]> GetCachedFolderInfoAsync(int assocId, string server, string username, string[] folderList, CancellationToken cancellationToken)
Parameters
Type Name Description
int 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

CancellationToken cancellationToken
Returns
Type Description
Task<SoMailFolderInfo[]>

GetCachedFolderListAsync(int, SoMailCredentials, CancellationToken)

Returns a cached list of folders

Declaration
public static Task<string[]> GetCachedFolderListAsync(int assocId, SoMailCredentials credentials, CancellationToken cancellationToken)
Parameters
Type Name Description
int assocId

Id of associate to retrieve item from

SoMailCredentials credentials

Mail server credentials

CancellationToken cancellationToken
Returns
Type Description
Task<string[]>

GetCachedMailItemAsync(int, string, string, int, string, bool, CancellationToken)

Look for and return a MailItem from the database. If item is not found, null is returned.

Declaration
public static Task<MailItem> GetCachedMailItemAsync(int assocId, string server, string username, int messageId, string folder, bool includeAttachments, CancellationToken cancellationToken)
Parameters
Type Name Description
int assocId

Id of associate to retrieve item from

string server

Mail server

string username

Mail server account

int messageId

Id of message to retrieve

string folder

The item belongs to this folder

bool includeAttachments

If true, cached object need to contain all attachments

CancellationToken cancellationToken
Returns
Type Description
Task<MailItem>

MailItem object, or null if no object is found

GetCachingStartedAsync(int, SoMailCredentials, CancellationToken)

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 Task<bool> GetCachingStartedAsync(int associateId, SoMailCredentials credentials, CancellationToken cancellationToken)
Parameters
Type Name Description
int associateId
SoMailCredentials credentials
CancellationToken cancellationToken
Returns
Type Description
Task<bool>

GetDraftsFolderNameAsync(int, CancellationToken)

Class that handles e-mail caching to the superoffice db

Declaration
public static Task<string> GetDraftsFolderNameAsync(int accountId, CancellationToken cancellationToken)
Parameters
Type Name Description
int accountId
CancellationToken cancellationToken
Returns
Type Description
Task<string>

GetEmailAccountIdAsync(int, string, string, CancellationToken)

Class that handles e-mail caching to the superoffice db

Declaration
public static Task<int> GetEmailAccountIdAsync(int assocId, string server, string username, CancellationToken cancellationToken)
Parameters
Type Name Description
int assocId
string server
string username
CancellationToken cancellationToken
Returns
Type Description
Task<int>

GetFolderNameAsync(EmailFolderRow, CancellationToken)

Constructs the full directory path from the given folder row to the root folder.

Declaration
public static Task<string> GetFolderNameAsync(EmailFolderRow folderRow, CancellationToken cancellationToken)
Parameters
Type Name Description
EmailFolderRow folderRow
CancellationToken cancellationToken
Returns
Type Description
Task<string>

GetFolderNameAsync(int, CancellationToken)

Constructs the full directory path from the given folder to the root folder.

Declaration
public static Task<string> GetFolderNameAsync(int folderId, CancellationToken cancellationToken)
Parameters
Type Name Description
int folderId
CancellationToken cancellationToken
Returns
Type Description
Task<string>

GetInboxFolderNameAsync(int, CancellationToken, bool)

Class that handles e-mail caching to the superoffice db

Declaration
public static Task<string> GetInboxFolderNameAsync(int accountId, CancellationToken cancellationToken, bool create = true)
Parameters
Type Name Description
int accountId
CancellationToken cancellationToken
bool create
Returns
Type Description
Task<string>

GetMailItemFromDbRowAsync(EmailItemRow, CancellationToken, bool, bool)

Class that handles e-mail caching to the superoffice db

Declaration
public static Task<MailItem> GetMailItemFromDbRowAsync(EmailItemRow row, CancellationToken cancellationToken, bool mime = false, bool streams = false)
Parameters
Type Name Description
EmailItemRow row
CancellationToken cancellationToken
bool mime
bool streams
Returns
Type Description
Task<MailItem>

GetMinimalMailEnvelope(int, EMailFlags)

Class that handles e-mail caching to the superoffice db

Declaration
public static MailEnvelope GetMinimalMailEnvelope(int serverId, EMailFlags flags)
Parameters
Type Name Description
int serverId
EMailFlags flags
Returns
Type Description
MailEnvelope

GetSentFolderNameAsync(int, CancellationToken, bool)

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

Declaration
public static Task<string> GetSentFolderNameAsync(int accountId, CancellationToken cancellationToken, bool create = true)
Parameters
Type Name Description
int accountId
CancellationToken cancellationToken
bool create
Returns
Type Description
Task<string>

GetSentFolderNamesAsync(int, CancellationToken)

Get all folders marked with the Sent folder attribute

Declaration
public static Task<string[]> GetSentFolderNamesAsync(int emailAccountId, CancellationToken cancellationToken)
Parameters
Type Name Description
int emailAccountId
CancellationToken cancellationToken
Returns
Type Description
Task<string[]>

GetSpecialFolderNameAsync(int, int, CancellationToken)

Get all folders for a given account with the provided folder attribute

Declaration
public static Task<string> GetSpecialFolderNameAsync(int accountId, int folderAttribute, CancellationToken cancellationToken)
Parameters
Type Name Description
int accountId
int folderAttribute

EMailFolderAttributeConstants

CancellationToken cancellationToken
Returns
Type Description
Task<string>

GetSpecialFolderNamesAsync(int, int, CancellationToken)

Class that handles e-mail caching to the superoffice db

Declaration
public static Task<string[]> GetSpecialFolderNamesAsync(int accountId, int folderAttribute, CancellationToken cancellationToken)
Parameters
Type Name Description
int accountId
int folderAttribute
CancellationToken cancellationToken
Returns
Type Description
Task<string[]>

GetTrashFolderNameAsync(int, CancellationToken)

Get the full name of the folder with the Trash attribute in the database.

Declaration
public static Task<string> GetTrashFolderNameAsync(int accountId, CancellationToken cancellationToken)
Parameters
Type Name Description
int accountId
CancellationToken cancellationToken
Returns
Type Description
Task<string>

SetCachedFolderInfoAsync(int, string, string, SoMailFolderInfo[], CancellationToken)

Cache mail folder info to the database

Declaration
public static Task SetCachedFolderInfoAsync(int assocId, string server, string username, SoMailFolderInfo[] folderInfo, CancellationToken cancellationToken)
Parameters
Type Name Description
int assocId

Associate to cache item for

string server

Mail server

string username

Mail server account

SoMailFolderInfo[] folderInfo

Folder information to cache

CancellationToken cancellationToken
Returns
Type Description
Task

SetCachingFinishedAsync(int, SoMailCredentials, CancellationToken)

Update the ForeignKey record to Inactive SubKey value

Declaration
public static Task SetCachingFinishedAsync(int associateId, SoMailCredentials credentials, CancellationToken cancellationToken)
Parameters
Type Name Description
int associateId
SoMailCredentials credentials
CancellationToken cancellationToken
Returns
Type Description
Task

SetCachingStartedAsync(int, SoMailCredentials, CancellationToken)

If needed, create the ForeignKey record; make sure sure it has the Actvie Subkey value, and updated = Now

Declaration
public static Task SetCachingStartedAsync(int associateId, SoMailCredentials credentials, CancellationToken cancellationToken)
Parameters
Type Name Description
int associateId
SoMailCredentials credentials
CancellationToken cancellationToken
Returns
Type Description
Task

UpdateRecipientList(int, MailEnvelope)

Class that handles e-mail caching to the superoffice db

Declaration
public static void UpdateRecipientList(int assosciateId, MailEnvelope mail)
Parameters
Type Name Description
int assosciateId
MailEnvelope mail
© SuperOffice. All rights reserved.
SuperOffice |  Community |  Release Notes |  Privacy |  Site feedback |  Search Docs |  About Docs |  Contribute |  Back to top