Пример #1
0
		public void TestOutlookSendLinkMapi_ReplaceAttachments()
		{
			SendLinkInfo sendLink = new SendLinkInfo();
            sendLink.DisplayName = "Attachments.html";
			sendLink.Link = "A Link";
            sendLink.FilePath = Path.Combine(TestRoot, "Attachments.html");
			OutlookEmailWrapper email = new OutlookEmailWrapper(_outlookSession, Path.Combine(TestRoot, "Test RTF 2010.msg"));
			OutlookSendLinkMAPI mapi = new OutlookSendLinkMAPI();

            int count = email.MailItem.Attachments.Count;
            int[] posArray = new int[count];
            string[] recordKeyArray = new string[count];

            using (var wsMailItem = new WsMailItem(email.MailItem))
            {
                for (int i = 1; i <= count; i++)
                {
                    posArray[i - 1] = wsMailItem.Attachments[i].Position;
                    recordKeyArray[i - 1] = mapi.GetRecordKey(wsMailItem, i);
                }

                for (int i = 1; i <= count; i++)
                {
                    IWSMailAttachmentTransform mat = new OutlookIImplFactory().CreateWSMailAttachmentTransform();
                    mat.SendLinkReplaceRtfAttachments(wsMailItem, sendLink.FilePath, sendLink.DisplayName);
                }

                Redemption.SafeMailItem safeMailItem = RedemptionLoader.new_SafeMailItem();
                using (new ComRelease(safeMailItem))
                {
                    safeMailItem.Item = wsMailItem.UnSafeMailItem;// email.MailItem;

                    int[] posArray2 = new int[safeMailItem.Attachments.Count];
                    string[] names = new string[count];
                    for (int i = 1; i <= safeMailItem.Attachments.Count; i++)
                    {
                        posArray2[i - 1] = safeMailItem.Attachments[i].Position;
                        names[i - 1] = safeMailItem.Attachments[i].DisplayName;
                    }

                    for (int i = 0; i < safeMailItem.Attachments.Count; i++)
                    {
                        Assert.AreEqual(posArray[i], posArray2[i]);
                        Assert.AreEqual(names[i], "Attachments.html");
                    }
                }
            }
		}
Пример #2
0
		private bool ExecuteSendLinkAction(MailItem mailItem, Attachment[] builtup, RequestManager requestManager)
		{
			try
			{               
			    Cursor.Current = Cursors.WaitCursor;

				OutlookSendLink sendLink;
				// For Office version prior to 2010 we need access properties and attachments via MAPI
                if (!UseOutlookDOMForProcessing || OutlookVersion.Convert(m_application.Version) <= OutlookVersion.Version.Outlook2007)
				{
					sendLink = new OutlookSendLinkMAPI();
				}
				else
				{
					sendLink = new OutlookSendLinkOOM();
				}

                if (IsDeterministicSendEnabled)
                {
                    var prSearchBytes = mailItem.PropertyAccessor.GetProperty(MAPIStringDefines.PR_SEARCH_KEY);
                    var prSearchKey = Convert.ToBase64String(prSearchBytes);
                    DeferredSendStore.Add(prSearchKey);
                }

				bool result = sendLink.ExecuteSendLinkAction(mailItem, builtup, requestManager);
				
				if (result && IsDeterministicSendEnabled)
				{
					sendLink.SetDeterministicSendDeferedTime(mailItem);
				}
				return result;
			}
			finally
			{
				Cursor.Current = Cursors.Default;
			}
		}
Пример #3
0
		private Int64 GetTotalAttachmentSize(MailItem mailItem)
		{
			MessageBodyFormat bodyFormat;

            if (UseOutlookDOMForProcessing)
            {
                using (OutlookMailProxy outlookMailProxy = new OutlookMailProxy(mailItem))
                {
                    bodyFormat = OutlookBodyFormat.GetMessageBodyFormat(outlookMailProxy.FormattedBodyText);
                }
            }
            else
            {
                using (RedemptionMailProxy redemptionMailProxy = new RedemptionMailProxy(mailItem, true, DisableAccessToDOMAttachments))
                {
                    bodyFormat = OutlookBodyFormat.GetMessageBodyFormat(redemptionMailProxy.FormattedBodyText);
                }
            }

            if (!UseOutlookDOMForProcessing || OutlookVersion.Convert(m_application.Version) < OutlookVersion.Version.Outlook2007)
			{
                var mapi = new OutlookSendLinkMAPI() { UseOutlookDOMForProcessing = UseOutlookDOMForProcessing, DisableAccessToDOMAttachments = DisableAccessToDOMAttachments };
				return mapi.GetTotalAttachmentSize(mailItem, bodyFormat);
			}
            else
            {
                var oom = new OutlookSendLinkOOM() { UseOutlookDOMForProcessing = UseOutlookDOMForProcessing, DisableAccessToDOMAttachments = DisableAccessToDOMAttachments };
			    return oom.GetTotalAttachmentSize(mailItem, bodyFormat);
            }
		}