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 Dispose() { try { if (m_safeMailItem != null && Marshal.IsComObject(m_safeMailItem)) { Marshal.ReleaseComObject(m_safeMailItem); } m_safeMailItem = null; } catch (System.Exception e) { Logger.LogError(e); } }