Show / Hide Table of Contents

Class MessageStoreSession

Class to deal with sessions for incoming/message store (i.e. IMAP) mail servers.
Instantiate this class with BeginRead(SoMailFolder).

Inheritance
Object
MailSession<ISoIncomingMailInterface>
MessageStoreSession
Implements
IDisposable
Inherited Members
MailSession<ISoIncomingMailInterface>.Logout()
MailSession<ISoIncomingMailInterface>.Dispose()
MailSession<ISoIncomingMailInterface>.Server
MailSession<ISoIncomingMailInterface>.UserName
MailSession<ISoIncomingMailInterface>.UseSSL
MailSession<ISoIncomingMailInterface>.Password
MailSession<ISoIncomingMailInterface>.MailInterface
Namespace: SuperOffice.CRM.Mail
Assembly: SoDataBase.dll
Syntax
public sealed class MessageStoreSession : MailSession<ISoIncomingMailInterface>, IDisposable

Properties

CurrentFolder

Get the currently selected folder.

Declaration
public string CurrentFolder { get; }
Property Value
Type Description
String

Methods

CreateFolder(String)

Create a new folder

Declaration
public void CreateFolder(string folderName)
Parameters
Type Name Description
String folderName

Full path and name of folder to create

Delete(String, Int32[])

Deleted/move specified e-mails

Declaration
public void Delete(string moveToFolder, params int[] messageServerIds)
Parameters
Type Name Description
String moveToFolder
Int32[] messageServerIds

Array of ids to target mail items

DeleteFolder(String)

Delete a folder and all e-mails

Declaration
public void DeleteFolder(string folderName)
Parameters
Type Name Description
String folderName

Full path and name of folder to delete

EmptyFolder(String)

Delete all items in current folder

Declaration
public void EmptyFolder(string moveToFolder)
Parameters
Type Name Description
String moveToFolder

If set, move deleted items to this folder

GetAttachment(Int32, String)

Retrieve an attachment from an e-mail

Declaration
public MailAttachment GetAttachment(int messageServerId, string attachmentId)
Parameters
Type Name Description
Int32 messageServerId

Unique id of the mail to get the attachment from

String attachmentId

Unique id of the attachment to get

Returns
Type Description
MailAttachment

GetEMail(Int32)

Fetch a single e-mail from the server

Declaration
public MailItem GetEMail(int messageServerId)
Parameters
Type Name Description
Int32 messageServerId

Unique server id for the item

Returns
Type Description
MailItem

The e-mail

GetEMail(Int32, Boolean)

Fetch a single e-mail from the server

Declaration
public MailItem GetEMail(int messageServerId, bool includeAttachmentStreams)
Parameters
Type Name Description
Int32 messageServerId

Unique server id for the item

Boolean includeAttachmentStreams

Should we include attachment streams(content).

Returns
Type Description
MailItem

The e-mail

GetEMail(Int32, Boolean, Boolean)

Fetch a single e-mail from the server

Declaration
public MailItem GetEMail(int messageServerId, bool includeAttachmentStreams, bool includeMime)
Parameters
Type Name Description
Int32 messageServerId

Unique server id for the item

Boolean includeAttachmentStreams

Should we include attachment streams(content).

Boolean includeMime

Should we include mime text.

Returns
Type Description
MailItem

The e-mail

GetEMailAsString(String)

Fetch a single e-mail optionally stripping attachments and deliver a stream to the raw MIME data(RFC 822)

Declaration
public string GetEMailAsString(string msgId)
Parameters
Type Name Description
String msgId
Returns
Type Description
String

Stream to a RFC 822 MIME representation of the e-mail

GetEMailStream(Int32, Boolean, Boolean)

Fetch a single e-mail optionally stripping attachments and deliver a stream to the raw MIME data(RFC 822)

Declaration
public Stream GetEMailStream(int messageServerId, bool stripAttachments, bool sanitizeAttachments)
Parameters
Type Name Description
Int32 messageServerId

Unique server id for the item

Boolean stripAttachments

If true, get stream without attachments

Boolean sanitizeAttachments

If true, remove bad attachments.

Returns
Type Description
Stream

Stream to a RFC 822 MIME representation of the e-mail

GetEnvelopeIds(String)

Returns envelopes ids in the folder

Declaration
public int[] GetEnvelopeIds(string search)
Parameters
Type Name Description
String search
Returns
Type Description
Int32[]

GetEnvelopes(MailSortCriterion, Boolean)

Fetch all envelopes from current folder

Declaration
public MailEnvelope[] GetEnvelopes(MailSortCriterion sortOrder, bool reverse)
Parameters
Type Name Description
MailSortCriterion sortOrder

How return mails should be sorted

Boolean reverse

Reverse the sort order

Returns
Type Description
MailEnvelope[]

All envelopes for the current folder

GetEnvelopes(MailSortCriterion, Boolean, Int32[])

Fetch specific envelopes from the server.

Declaration
public MailEnvelope[] GetEnvelopes(MailSortCriterion sortOrder, bool reverse, params int[] items)
Parameters
Type Name Description
MailSortCriterion sortOrder

What order to retrieve e-mails

Boolean reverse

Reverse sort order

Int32[] items

List of unique ids for e-mails to fetch

Returns
Type Description
MailEnvelope[]

Envelopes for the specified e-mails

GetEnvelopes(Int32, Int32, MailSortCriterion)

Fetch envelopes from the server based on message server ids.

Declaration
public MailEnvelope[] GetEnvelopes(int from, int to, MailSortCriterion sortOrder)
Parameters
Type Name Description
Int32 from

from serverid

Int32 to

To serverid

MailSortCriterion sortOrder

How e-mails should be sorted

Returns
Type Description
MailEnvelope[]

Envelopes for the specified e-mails

GetEnvelopes(Int32, Int32, MailSortCriterion, Boolean)

Fetch envelopes from the server

Declaration
public MailEnvelope[] GetEnvelopes(int from, int to, MailSortCriterion sortOrder, bool reverse)
Parameters
Type Name Description
Int32 from

Based on the sortOrder retrieve e-mails from this index

Int32 to

Based on the sortOrder retrieve e-mails till this index

MailSortCriterion sortOrder

How e-mails should be sorted

Boolean reverse

Reverse the sort order

Returns
Type Description
MailEnvelope[]

Envelopes for the specified e-mails

GetEnvelopes(Int32[], MailSortCriterion, Boolean)

Fetch envelopes from the server based on message server ids.

Declaration
public MailEnvelope[] GetEnvelopes(int[] messageIds, MailSortCriterion sortOrder, bool reverse)
Parameters
Type Name Description
Int32[] messageIds

array of ids of messages to get

MailSortCriterion sortOrder

How e-mails should be sorted

Boolean reverse

Reverse the sort order

Returns
Type Description
MailEnvelope[]

Envelopes for the specified e-mails

GetFolderExist(String)

Check if a specified folder exist on the server

Declaration
public bool GetFolderExist(string folderName)
Parameters
Type Name Description
String folderName

Full path and name of folder to verify existence of

Returns
Type Description
Boolean

True if folder exists on the server. False is also returned if the connection to the mail server has been closed.

GetFolderInfo(String[])

returns folder information for the current list of folders

Declaration
public SoMailFolderInfo[] GetFolderInfo(string[] folders)
Parameters
Type Name Description
String[] folders
Returns
Type Description
SoMailFolderInfo[]

GetFolderList()

Retrieve all subscribed folders for the account

Declaration
public string[] GetFolderList()
Returns
Type Description
String[]

Ex: { "Inbox", "Inbox/SubFolder", "Sent Items" }

GetFolderMailCount(Boolean)

Retrieve the number of e-mails in current folder

Declaration
public int GetFolderMailCount(bool onlyUnread)
Parameters
Type Name Description
Boolean onlyUnread

If true, only count unread e-mails

Returns
Type Description
Int32

Number of e-mails

GetPartialEnvelopes(Int32, Int32, MailSortCriterion, Boolean, String)

Fetch envelopes but only populate values specified by the fields parameter Valid values are "Date From To Subject FLAGS RFC822.SIZE" The specified sortOrder will always include the field it is sorting on

Declaration
public MailEnvelope[] GetPartialEnvelopes(int from, int to, MailSortCriterion sortOrder, bool revers, string fields)
Parameters
Type Name Description
Int32 from
Int32 to
MailSortCriterion sortOrder
Boolean revers
String fields
Returns
Type Description
MailEnvelope[]

GetPartialEnvelopes(Int32[], String)

Fetch envelopes but only populate values specified by the fields parameter Valid values are "Date From To Subject FLAGS RFC822.SIZE" The specified sortOrder will always include the field it is sorting on

Declaration
public MailEnvelope[] GetPartialEnvelopes(int[] mailServerIds, string fields)
Parameters
Type Name Description
Int32[] mailServerIds

array of serverids

String fields
Returns
Type Description
MailEnvelope[]

GetRawFolderList(Boolean)

Retrieve all subscribed folders for the account

Declaration
public string[] GetRawFolderList(bool includeItemCount)
Parameters
Type Name Description
Boolean includeItemCount

Add unread and total number of items to the foldernames

Returns
Type Description
String[]

List of folders. Each folder contains a delimeter character and the foldername, separated by the '§' character. Foldercounts are optionally added to each folder name. Ex: { "/§Inbox", "/§Inbox/SubFolder", "/§Sent Items" } { "/§Inbox,100,250", "/§Inbox/SubFolder,100,250", "/§Sent Items,100,100" }

MarkAsRead(Boolean, Int32[])

Mark item as (un)read

Declaration
public void MarkAsRead(bool read, params int[] messageServerIds)
Parameters
Type Name Description
Boolean read

If true, items are marked as read. If false, item is marked as unread

Int32[] messageServerIds

Array of ids to target mail items

MoveToFolder(String, Int32[])

Move item(s) from the current folder to targetFolder

Declaration
public void MoveToFolder(string targetFolder, params int[] mesasgeServerIds)
Parameters
Type Name Description
String targetFolder

Name of folder to move items to

Int32[] mesasgeServerIds

Array of ids to mail items

RenameFolder(String, String)

Rename an existing folder

Declaration
public void RenameFolder(string oldName, string newName)
Parameters
Type Name Description
String oldName

Old name of the folder

String newName

New name of the folder

SaveEMail(MailItem)

Save an e-mail back to the server

Declaration
public MailItem SaveEMail(MailItem item)
Parameters
Type Name Description
MailItem item

The e-mail item to save

Returns
Type Description
MailItem

The saved e-mail

SaveEMails(MailItem[])

Save a set of e-mails to the server

Declaration
public void SaveEMails(MailItem[] items)
Parameters
Type Name Description
MailItem[] items

The e-mails to save

SelectFolder(SoMailFolder, Boolean)

Set an active folder

Declaration
public bool SelectFolder(SoMailFolder folder, bool readOnly)
Parameters
Type Name Description
SoMailFolder folder

Folder to set active

Boolean readOnly

If true, the mailbox folder is selected for "read-only" access. No changes to the permanent state of the folder are permitted

Returns
Type Description
Boolean

True if the folder was successfully set active

SelectFolder(String, Boolean)

Set an active folder

Declaration
public bool SelectFolder(string folderName, bool readOnly)
Parameters
Type Name Description
String folderName

Full path and name of folder to set active

Boolean readOnly

If true, the mailbox folder is selected for "read-only" access. No changes to the permanent state of the folder are permitted

Returns
Type Description
Boolean

True if the folder was successfully set active

ServerLogin(String, String, String)

Log on to the mail server

Declaration
protected override ISoIncomingMailInterface ServerLogin(string server, string userName, string password)
Parameters
Type Name Description
String server

Name of mail server with optional port.

String userName

User name used to authenticate to the mail server

String password

Password used to authenticate to the mail server

Returns
Type Description
ISoIncomingMailInterface

Instance of interface to the mail plugin.

Overrides
SuperOffice.CRM.Mail.MailSession<SuperOffice.CRM.Mail.ISoIncomingMailInterface>.ServerLogin(System.String, System.String, System.String)

ServerLogin(String, String, String, Boolean)

Log on to the mail server

Declaration
protected override ISoIncomingMailInterface ServerLogin(string server, string userName, string password, bool useSSL)
Parameters
Type Name Description
String server

Name of mail server with optional port.

String userName

User name used to authenticate to the mail server

String password

Password used to authenticate to the mail server

Boolean useSSL

Use SSL

Returns
Type Description
ISoIncomingMailInterface

Instance of interface to the mail plugin.

Overrides
SuperOffice.CRM.Mail.MailSession<SuperOffice.CRM.Mail.ISoIncomingMailInterface>.ServerLogin(System.String, System.String, System.String, System.Boolean)

ServerLogout()

Log out from the mail server.

Declaration
protected override void ServerLogout()
Overrides
SuperOffice.CRM.Mail.MailSession<SuperOffice.CRM.Mail.ISoIncomingMailInterface>.ServerLogout()

SetFlags(EMailFlags, Int32[])

Set specified flags on e-mail(s)

Declaration
public void SetFlags(EMailFlags flags, params int[] messageServerIds)
Parameters
Type Name Description
EMailFlags flags

Flags to set on e-mail item

Int32[] messageServerIds

E-mails to set flags on

Implements

System.IDisposable

Extension Methods

EnumUtil.MapEnums<From, To>(From)
Converters.MapEnums<From, To>(From)
© SuperOffice. All rights reserved.
SuperOffice |  Community |  Release Notes |  Privacy |  Site feedback |  Search Docs |  About Docs |  Contribute |  Back to top