Chat now with support
Chat with Support

Archive Manager 5.4 - SDK Guide

SDK collections

SDKCollection Objects contain methods to Add, AddByRef, RemoveByRef, and New. The Add method allows you to create a new Object within the collection. In this case, the Add method only cares about the model data so it would require a model interface.

ISDKFolderCollection folders = testMailbox.Folders;
IFolder newFolder = new Folder();
newFolder.Name = "FolderName";

Using the AddByRef and RemoveByRef allows you to link and unlink by object ID. Each type will have an associated ID property that can be used to link into a given type collection. For example, you could add a folder to the Subfolders collection of another folder to build hierarchy.

ISDKFolderCollection folders = testMailbox.Folders;
ISDKFolder testFolder = folders.Items.FirstOrDefault(f => f.Name == "TestFolder");
ISDKFolder testFolder2 = folders.Items.FirstOrDefault(f => f.Name == "TestFolder2");

The New method returns an empty Model for convenience. Once you “Add” the Model to a collection, the Add method will return an SDK version ready for navigation. The ID field and other relevant links are populated.

ISDKFolderCollection folders = testMailbox.Folders;
IFolder newFolder = new Folder();
newFolder.Name = "FolderName";
ISDKFolder newSDKFolder = folders.Add(newFolder);
int newFolderId = newSDKFolder.Id;
int ownerMailboxId = newSDKFolder.MailBoxId;
int parentFolderId = newSDKFolder.ParentFolderId;

Message creation

Messages are constructed using the Message and Attachment Models. These Models implement interfaces found in the Quest.AM.Public.Interfaces and require some types from Quest.AM.Public. Messages and attachments have many properties. Most are metadata that is not required. The following is an example of populating the general Message fields.

IMessage message = new Message();

message.Attachments = new List<IAttachment2>();
message.From = new EmailAddress("DisplayName", "");
message.To = new List<IEmailAddress2>();
message.To.Add(new EmailAddress("DisplayName", ""));
message.CC = new List<IEmailAddress2>();
message.BCC = new List<IEmailAddress2>();
message.BodyFormat = BodyFormat.Text;
message.DateSent = DateTime.MinValue;
message.DateReceived = DateTime.MaxValue;
message.Header = "";
message.OrigionalMessageID = "InternetMessageID";
message.PartType = EmailPartType.Email;
message.Subject = "Message Subject";
message.ThreadIndex = "AQHNjQWAdEBzhLInT0yR5EYT63xljA==";
message.ThreadTopic = "Message Subject";

Body elements are provided as a Stream type using the StreamAsIDataStream2 wrapper class. The Constructor contains a few fields that are for internal use only at the moment. The important fields will be the stream with the content, the DataStreamPartType, and the stream length.

MemoryStream bodyStream = new MemoryStream();
message.Body = new StreamAsIDataStream2(DataStreamPartType.Body, null, Guid.Empty, false, bodyStream, false, 0, bodyStream.Length);

Attachment creation

Attachments are added to the message’s Attachments collection. An Attachment contains many meta-properties used to describe the attachment, but not all are required.

Attachment attachment = new Attachment();
attachment.Name = "Attachment";
attachment.FileName = "Attachment.docx";
attachment.ContentDescription = "Attachment Description";
attachment.PartType = EmailPartType.Attachment;

The attachment stream is also uses the StreamAsIDataStream2 wrapper class. The property StreamType needs to be set based on the type of attachment it is. In this case, ByValue for an actual attachment file.

MemoryStream attachmentData = new MemoryStream();
attachment.Data = new StreamAsIDataStream2(DataStreamPartType.AttachData, null, Guid.Empty, false, attachmentData, false, 0, attachmentData.Length);

Embedded messages

Attaching messages as embedded messages can be done by assigning the message object to the Data property of the attachment. Setting the StreamType to 6 for EmbeddedMsg will allow the parser to properly handle the embedded message.

IMessage message = new Message();
Related Documents

The document was helpful.

Select Rating

I easily found the information I needed.

Select Rating