protected override void AdjustAttachments(MailItem mailItem, List<SendLinkInfo> links, string id) { MessageBodyFormat bodyFormat; using (RedemptionMailProxy redemptionMailProxy = new RedemptionMailProxy(mailItem)) { bodyFormat = OutlookBodyFormat.GetMessageBodyFormat(redemptionMailProxy.FormattedBodyText); } // Remove non-Signature attachments and add Link Atachment if required IEnumerable<string> recordKeys = GetListofRecordKeys(mailItem, bodyFormat); if (ShouldAttachSendLinkContentFile()) { Interop.Logging.Logger.LogInfo("Adding Link Content File"); SendLinkInfo filenames = CreateSendLinkContentFile(links, id); if (bodyFormat == MessageBodyFormat.Rtf) { IWSMailAttachmentTransform mat = new OutlookIImplFactory().CreateWSMailAttachmentTransform(); mat.SendLinkReplaceRtfAttachments(mailItem, filenames.FilePath, filenames.DisplayName); } else { // We put a single link attachment in place of all non-Signature attachments in the message RemoveAllAttachments(mailItem, recordKeys); AddAttachment(mailItem, filenames); } } else { RemoveAllAttachments(mailItem, recordKeys); } }
private RWSMail(MSOutlook.MailItem mailItem) { m_oif = new OutlookIImplFactory(); string assemblyLocation = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath); if (string.IsNullOrEmpty(assemblyLocation)) throw new ArgumentNullException("Unable to get assembly location"); assemblyLocation = new Uri(assemblyLocation).LocalPath; RedemptionLoader.DllLocation32Bit = Path.Combine(assemblyLocation, "redemption.dll"); m_safeMailItem = RedemptionLoader.new_SafeMailItem(); _wsMailItem = mailItem; if (mailItem is WsMailItem) { m_safeMailItem.Item = _wsMailItem.UnSafeMailItem; } else { // Needed for the unit tests m_safeMailItem.Item = _wsMailItem; } m_application = mailItem.Application; }
public void TestFixtureSetup() { _outlookapp = new WsApplication(new MSOutlook.Application(), false); _oif = new OutlookIImplFactory(); _wsUtilities = _oif.CreateUtilities(); Disable(); }
public RedemptionRecipientTableProxy(object outlookmail, bool bUseCache) { if (null == outlookmail) throw new ArgumentNullException("OutlookMail"); m_bUseCache = bUseCache; m_outlookmail = outlookmail; m_oif = new OutlookIImplFactory(); }
public AddressEntry(object addressEntry) { m_oif = new OutlookIImplFactory(); IWSAddressEntry rae = addressEntry as IWSAddressEntry; if (rae != null) { m_redemptionAddressEntry = rae; } else { m_outlookAddressEntry = addressEntry as MSOutlook.AddressEntry; } }
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 TestFixtureTearDown() { if (_wsUtilities != null) { _wsUtilities.Cleanup(); _wsUtilities = null; } _oif = null; _outlookapp.Quit(); _outlookapp.Dispose(); _outlookapp = null; GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); }
private void Initialise(object mailItem, bool bUseCache, bool disableAccessToDOMAttachments) { if (null == mailItem) throw new ArgumentNullException("mailItem"); m_outlookMail = mailItem as MSOutlook.MailItem; if (null == m_outlookMail) throw new ArgumentNullException("m_outlookMail"); m_oif = new OutlookIImplFactory(); m_mailItem = m_oif.CreateWSMail(m_outlookMail); m_outlookRecipientTableProxy = new RedemptionRecipientTableProxy(m_outlookMail, bUseCache); m_outlookToRecipientsProxy = new RedemptionRecipientsProxy(m_outlookRecipientTableProxy, OutlookRecipientTypes.ToRecipient); m_outlookCcRecipientsProxy = new RedemptionRecipientsProxy(m_outlookRecipientTableProxy, OutlookRecipientTypes.CcRecipient); m_outlookBccRecipientsProxy = new RedemptionRecipientsProxy(m_outlookRecipientTableProxy, OutlookRecipientTypes.BccRecipient); m_outlookAttachmentsProxy = new RedemptionAttachmentsProxy(m_outlookMail, disableAccessToDOMAttachments); m_bIsValid = true; }
private void Initialise(MSOutlook.MailItem mailItem, bool bUseCache) { if (null == mailItem) throw new ArgumentNullException("mailItem"); m_oif = new OutlookIImplFactory(); m_outlookMail = mailItem; if (null == m_outlookMail) throw new ArgumentNullException("m_outlookMail"); m_RecipientsProxy = new OutlookRecipientsProxy(m_outlookMail, bUseCache); m_outlookAttachmentsProxy = new OutlookAttachmentsProxy(m_outlookMail); m_bIsValid = true; }
private static EmailRecipient GetSessionUser() { if (m_currentUser != null) return m_currentUser; OutlookIImplFactory oif = new OutlookIImplFactory(); using (IWSUtilities utils = oif.CreateUtilities()) { using (IWSCurrentUser currentUser = utils.CurrentUser) { m_currentUser = new EmailRecipient(); m_currentUser.Name = currentUser.Name; m_currentUser.EmailAddress = currentUser.Address; SetSmtpAddress(m_currentUser, currentUser.GetFields(MapiDefines.PR_EMS_AB_PROXY_ADDRESSES)); m_currentUser.Internal = true; } } return m_currentUser; }
public static void SetMimeHeaderForProtectServer(MailItem mailItem) { var oif = new OutlookIImplFactory(); using (var mitem = oif.CreateWSMail(mailItem)) { mitem.SetMIMEHeaderValue(RequestDigestProvider.XHEADER_MESSAGE_PROTECTED, ""); } }
public AttachmentsProxy(MailItem outlookMail) { m_outlookMail = outlookMail; m_oif = new OutlookIImplFactory(); }