示例#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;
            }
        }
示例#2
0
 // If the item is not a MailItem then we need to resolve the type and submit the item
 private void SubmitOther(dynamic item)
 {            
     try
     {
         var mapiObject = item.MAPIOBJECT;
         using (new ComRelease(mapiObject))
         {
             var messageUtils = new OutlookAddinLib.MessageUtils();
             messageUtils.SubmitMessage(mapiObject);
         }
     }
     catch (Exception ex)
     {
         Logger.LogError(ex);
         Logger.LogError("Failed to submit mail item. Item will remail in the Outbox.");
     }
 }
示例#3
0
 // The caller is responsable to release the MailItem COM object
 private void SubmitMail(Microsoft.Office.Interop.Outlook.MailItem mailItem)
 {
     var messageUtils = new OutlookAddinLib.MessageUtils();
     var mapiObject = mailItem.MAPIOBJECT;
     using (new ComRelease(mapiObject))
     {
         messageUtils.SubmitMessage(mapiObject);
     }
 }