public InspectorHook(WsInspector inspector) { _inspector = inspector; _inspector.InspectorClosing += OnInspectorClosing; _inspector.Activated += OnActivated; _inspector.Deactivate += OnDeactivate; _inspectorHandle = GetInspectorHandle(_inspector); _mailItem = inspector.CurrentItem as WsMailItem; if (_mailItem != null) _mailItem.BeforeCheckNames += OnBeforeCheckNames; }
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"); } } } }
public void AddAttachment(WsMailItem mailItem, string sourceFile) { using (var lcfm = new LocalCopyOfFileManager()) { string displayName = Path.GetFileName(sourceFile) + LargeAttachmentHelper.FileExtension; string destinationfile = lcfm.GetLocalCopyOfFileTarget(Path.GetFileName(sourceFile)) + LargeAttachmentHelper.FileExtension; Logger.LogInfo( string.Format( "Add Large Attachment. Source File = {0}, Target DisplayName = {1}, Target File = {2}", sourceFile, displayName, destinationfile)); var attachmentManager = new BigAttachmentsManager(); attachmentManager.AddAttachmentPlaceHolder(sourceFile, destinationfile); attachmentManager.AddAttachmentToMessage(mailItem, displayName, destinationfile); } }
private void OnItemSend(object Item, ref bool Cancel) { var mailItem = new WsMailItem(Item); dynamic activeInspector = Globals.Application.ActiveInspector(); try { if (!Utils.HasBeenProcessedByInteractiveProtect(mailItem) && mailItem.Attachments != null && mailItem.Attachments.Count > 0) { var applyExternally = OptionApi.GetBool("InteractiveProtectApplyOptionsOnExternal"); var applyInternally = OptionApi.GetBool("InteractiveProtectApplyOptionsOnInternal"); if (applyExternally || applyInternally) { var recipientProxy = new OutlookRecipientsProxy(mailItem); var isInternal = recipientProxy.IsInternal(); if (isInternal && applyInternally) { ApplyInteractiveProtectOptionsOnSend(mailItem, activeInspector.UnSafeInspector); } else if (!isInternal && applyExternally) { ApplyInteractiveProtectOptionsOnSend(mailItem, activeInspector.UnSafeInspector); } } } else { Utils.SetMimeHeaderForProtectServer(mailItem); } MapiProperties.Delete(mailItem, Constants.ProcessedByInteractiveProtect); HandleSecureFileTransfer(activeInspector.Id, mailItem, out Cancel); } catch (Exception e) { if (!MailClientWorkerBase.ShouldContinueAfterException(e)) { Cancel = true; } Logger.LogError(e); } }
public void AddSendAndProtectMapiProperty(WsMailItem mailItem) { mailItem.UserProperties.Add("SentAndProtectByWorkshare", OlUserPropertyType.olText); }
public void AddAttachmentToMessage(WsMailItem mailItem, string displayName, string fileName) { mailItem.Attachments.Add(fileName, OlAttachmentType.olByValue, Type.Missing, displayName); Logger.LogInfo(string.Format("Add attachment to mail item. DisplayName = {0}, FileName = {1}", displayName, fileName)); }
public dynamic CreateItemFromTemplate(string TemplatePath, [Optional] object InFolder) { WsMailItem mailItem = null; try { mailItem = new WsMailItem(_application.CreateItemFromTemplate(TemplatePath, InFolder)); return mailItem; } catch (Exception) { return mailItem; } }
public bool ProcessMailMessage(object messageInstance) { try { using (dynamic mailItem = new WsMailItem(messageInstance)) { try { ((Microsoft.Office.Interop.Outlook.ItemEvents_10_Event)messageInstance).Close += OnItemClose; return ProcessMailSynchronously(MapiProperties.IsSet(mailItem, SEND_AND_PROTECT), mailItem); } finally { ((Microsoft.Office.Interop.Outlook.ItemEvents_10_Event)messageInstance).Close -= OnItemClose; } } } finally { GarbageCollect(); } }
public void AddAttachmentToMessage(WsMailItem mailItem, string displayName, string fileName) { _instance.AddAttachmentToMessage(mailItem, displayName, fileName); }
public void TestOutlookSendLinkOOM_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")); OutlookSendLinkOOM oom = new OutlookSendLinkOOM(); 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] = oom.GetRecordKey(wsMailItem, i); } for (int i = 1; i <= count; i++) { oom.ReplaceAttachments(wsMailItem, recordKeyArray[i - 1], sendLink); } int[] posArray2 = new int[wsMailItem.Attachments.Count]; string[] names = new string[count]; for (int i = 1; i <= wsMailItem.Attachments.Count; i++) { posArray2[i - 1] = wsMailItem.Attachments[i].Position; names[i - 1] = wsMailItem.Attachments[i].DisplayName; } for (int i = 0; i < wsMailItem.Attachments.Count; i++) { Assert.AreEqual(posArray[i], posArray2[i]); Assert.AreEqual(names[i], "Attachments.html"); } } }
private void HandleSecureFileTransfer(Guid id, WsMailItem mailItem, out bool Cancel) { Cancel = false; if (_sendLinkCache.ContainsKey(id)) { var osl = new OutlookSendLink(); if (!osl.ShowBccWarning(mailItem)) { Cancel = true; return; } TaskPaneEventArgs args; if (_sendLinkCache.TryRemove(id, out args)) { SendLinkAddMembers.Add(mailItem, args.FolderId, args.PlatformSession); if (!string.IsNullOrEmpty(mailItem.Subject)) { args.PlatformSession.ApiHelper.RenameFolder(args.FolderId, mailItem.Subject); } } } }