Esempio n. 1
0
        private bool DeferSendLinkMail(Microsoft.Office.Interop.Outlook.MailItem mailItem)
        {            
            try
            {
				if (mailItem.UserProperties.Find(SendLinkPropertyName) == null)
	            {
	                Logger.LogInfo("Not SendLink mail.");
	                return false;
	            }

	            var prSearchKey = GetPrSearchKey(mailItem);
	            if (string.IsNullOrEmpty(prSearchKey))
	            {
	                Logger.LogError("Failed to retrieve the SearchKey.");
	                return false;
	            }

	            if (!DeferredSendStore.Exist(prSearchKey))
	            {
	                Logger.LogInfo("Search key does not exist in DeferredSendStore. Uploaded completed before the message reached the Outbox.");
	                return false;
	            }

	            CreateSubmitWorkerThread(prSearchKey);

	            var messageUtils = new OutlookAddinLib.MessageUtils();
                var mapiObject = mailItem.MAPIOBJECT;
                using (new ComRelease(mapiObject))
                {
                    messageUtils.AbortSubmit(mapiObject);
                        // Unfortunately aborting the single item will cause all items in the Outbox to be aborted i.e. submitted state is set to false
                }

                Logger.LogInfo("SendLink deterministic send abort sending mail while file upload in progress. PrSearchKey = " + prSearchKey);

	            return true;
            }
            catch (Exception ex)
            {
                Logger.LogError(ex);
                return false;
            }
        }