/// <summary> /// Download all attachments using attachmentfactory objecy /// </summary> /// <param name="attachmentFactory">TDAPIOLELib.AttachmentFactory Object</param> /// <param name="attachmentDownloadPath">Path to download attachments</param> /// <returns></returns> public static Boolean DownloadAttachments(TDAPIOLELib.AttachmentFactory attachmentFactory, String attachmentDownloadPath) { try { TDAPIOLELib.ExtendedStorage OExtendedStorage; if (attachmentFactory.NewList("").Count > 0) { if ((System.IO.Directory.Exists(attachmentDownloadPath)) == false) { throw (new Exception("Attachment download path does not exist")); } foreach (TDAPIOLELib.Attachment OAttachment in attachmentFactory.NewList("")) { OExtendedStorage = OAttachment.AttachmentStorage; OExtendedStorage.ClientPath = attachmentDownloadPath; OAttachment.Load(true, OAttachment.Name); } return(true); } else { throw (new Exception("Attachments not Found")); } } catch (Exception ex) { throw ex; } }
/// <summary> /// Delete all attachments using attachmentfactory Object /// </summary> /// <param name="attachmentFactory">TDAPIOLELib.AttachmentFactory Object</param> /// <returns>True if successfull</returns> public static Boolean DeleteAllAttachments(TDAPIOLELib.AttachmentFactory attachmentFactory) { TDAPIOLELib.List AttachmentsList = attachmentFactory.NewList(""); foreach (TDAPIOLELib.Attachment OAttach in AttachmentsList) { attachmentFactory.RemoveItem(OAttach.ID); } return(true); }
/// <summary> /// Delete Attachments by name /// </summary> /// <param name="attachmentFactory">TDAPIOLELib.AttachmentFactory Object</param> /// <param name="attachmentName">name of the attachment to be deleted</param> /// <returns>Return true if successfull</returns> public static Boolean DeleteAttachmentByName(TDAPIOLELib.AttachmentFactory attachmentFactory, String attachmentName) { TDAPIOLELib.List AttachmentsList = attachmentFactory.NewList(""); foreach (TDAPIOLELib.Attachment OAttach in AttachmentsList) { if (OAttach.Name.EndsWith(attachmentName)) { attachmentFactory.RemoveItem(OAttach.ID); break; } } return(true); }