private void GetOutlookApplication(out bool disposeOutlookInstances, out Application application, out NameSpace nameSpace, string profileName) { // Check whether there is an Outlook process running. if (Process.GetProcessesByName("OUTLOOK").Any()) { // If so, use the GetActiveObject method to obtain the process and cast it to an Application object. application = Marshal.GetActiveObject("Outlook.Application") as Application; disposeOutlookInstances = false; nameSpace = null; if (application != null) { nameSpace = application.GetNamespace("MAPI"); if (!string.IsNullOrEmpty(profileName) && !nameSpace.CurrentProfileName.Equals(profileName)) { throw new InvalidOperationException( $"Current Outlook instance is opened with a Different Profile Name ({nameSpace.CurrentProfileName}).{Environment.NewLine}Close Outlook and try again."); } } } else { // If not, create a new instance of Outlook and log on to the default profile. application = new Application(); nameSpace = application.GetNamespace("MAPI"); nameSpace.Logon(profileName, "", false, true); disposeOutlookInstances = true; } }
private static void Convert (NameSpace outlookSession, Options options, Func<Options, string> cacheFileGetter, Action<Options> cacheDeleter) { OlItemType defaultItemType; using (var outlookFolderWrapper = GenericComObjectWrapper.Create((Folder)outlookSession.GetFolderFromID(options.OutlookFolderEntryId, options.OutlookFolderStoreId))) { defaultItemType = outlookFolderWrapper.Inner.DefaultItemType; } if (defaultItemType == OlItemType.olTaskItem) { var fileName = cacheFileGetter(options); XDocument document = XDocument.Load(fileName); if (document.Root?.Name.LocalName == "ArrayOfOutlookEventRelationData") { document.Root.Name = "ArrayOfTaskRelationData"; foreach (var node in document.Descendants().Where(n => n.Name == "OutlookEventRelationData")) { node.Name = "TaskRelationData"; } document.Save(fileName); } } }
public OptionsForm (NameSpace session, Func<Guid, string> profileDataDirectoryFactory, bool fixInvalidSettings) { InitializeComponent(); _session = session; _profileDataDirectoryFactory = profileDataDirectoryFactory; _fixInvalidSettings = fixInvalidSettings; }
public static void Initialize (NameSpace mapiNameSpace) { s_mapiNameSpace = mapiNameSpace; const string testerServerEmailAddress = "*****@*****.**"; if (mapiNameSpace == null) throw new ArgumentNullException ("mapiNameSpace"); _entityMapper = new EventEntityMapper ( mapiNameSpace.CurrentUser.Address, new Uri ("mailto:" + testerServerEmailAddress), mapiNameSpace.Application.TimeZones.CurrentTimeZone.ID, mapiNameSpace.Application.Version, new EventMappingConfiguration()); s_outlookFolderEntryId = ConfigurationManager.AppSettings[string.Format ("{0}.OutlookFolderEntryId", Environment.MachineName)]; s_outlookFolderStoreId = ConfigurationManager.AppSettings[string.Format ("{0}.OutlookFolderStoreId", Environment.MachineName)]; _outlookRepository = new OutlookEventRepository (mapiNameSpace, s_outlookFolderEntryId, s_outlookFolderStoreId, NullDateTimeRangeProvider.Instance); s_synchronizerFactory = new SynchronizerFactory ( _ => @"a:\invalid path", NullTotalProgressFactory.Instance, s_mapiNameSpace, TimeSpan.Zero, TimeSpan.Zero); s_outlookEventRepository = new OutlookEventRepository ( s_mapiNameSpace, s_outlookFolderEntryId, s_outlookFolderStoreId, NullDateTimeRangeProvider.Instance); }
public void Dispose() { if (_mapiFolders != null) { foreach( var key in _mapiFolders.Keys) { _mapiFolders[key].Dispose(); } _mapiFolders.Clear(); _mapiFolders = null; } if (_wsCurrentUser != null) { _wsCurrentUser.Dispose(); _wsCurrentUser = null; } if (_wsAccounts != null) { _wsAccounts.Dispose(); _wsAccounts = null; } if (_nameSpace != null) { Marshal.ReleaseComObject(_nameSpace); _nameSpace = null; } }
protected virtual void Dispose(bool isDisposing) { Logger.LogInfo("EMAILTRACKING: Disposing Mail Selection - " + isDisposing); if (isDisposing) { GC.SuppressFinalize(this); } if (_inspector != null) Marshal.ReleaseComObject(_inspector); if (_explorer != null) Marshal.ReleaseComObject(_explorer); if (_ns != null) Marshal.ReleaseComObject(_ns); if (_outlookApplication != null) Marshal.ReleaseComObject(_outlookApplication); _inspector = null; _explorer = null; _ns = null; _outlookApplication = null; }
public SynchronizerFactory(string applicationDataDirectory, ITotalProgressFactory totalProgressFactory, NameSpace outlookSession) { _outlookEmailAddress = outlookSession.CurrentUser.Address; _applicationDataDirectory = applicationDataDirectory; _totalProgressFactory = totalProgressFactory; _outlookSession = outlookSession; }
private static void Convert(NameSpace outlookSession, Options options, Func<Options,string> cacheFileGetter, Action<Options> cacheDeleter) { OlItemType defaultItemType; using (var outlookFolderWrapper = GenericComObjectWrapper.Create ((Folder) outlookSession.GetFolderFromID (options.OutlookFolderEntryId, options.OutlookFolderStoreId))) { defaultItemType = outlookFolderWrapper.Inner.DefaultItemType; } if (defaultItemType == OlItemType.olAppointmentItem) { var fileName = cacheFileGetter(options); XDocument document = XDocument.Load (fileName); var aTypeNodes = document.Descendants ().Where (n => n.Name == "AtypeId"); foreach (var atypeNode in aTypeNodes) { var entryId = atypeNode.Value; string globalAppointmentId; using (var appointmentWrapper = GenericComObjectWrapper.Create ((AppointmentItem) outlookSession.GetItemFromID (entryId, options.OutlookFolderStoreId))) { globalAppointmentId = appointmentWrapper.Inner.GlobalAppointmentID; } atypeNode.RemoveAll (); atypeNode.Add (new XElement ("EntryId", entryId)); atypeNode.Add (new XElement ("GlobalAppointmentId", globalAppointmentId)); } document.Save (fileName); } }
public FolderChangeWatcherFactory (NameSpace mapiNamespace) { if (mapiNamespace == null) throw new ArgumentNullException (nameof (mapiNamespace)); _mapiNamespace = mapiNamespace; }
public OptionsDisplayControlFactory (NameSpace session, Func<Guid, string> profileDataDirectoryFactory, bool fixInvalidSettings, bool displayAllProfilesAsGeneric) { _session = session; _profileDataDirectoryFactory = profileDataDirectoryFactory; _fixInvalidSettings = fixInvalidSettings; _displayAllProfilesAsGeneric = displayAllProfilesAsGeneric; }
public MailSelection() { _outlookApplication = new Application(); _ns = _outlookApplication.GetNamespace("MAPI"); _inspector = _outlookApplication.ActiveInspector(); _explorer = _outlookApplication.ActiveExplorer(); Logger.LogInfo("EMAILTRACKING: Initialised Mail Selection"); }
public ProfileExportProcessor (NameSpace session, IOptionTasks optionTasks) { if (session == null) throw new ArgumentNullException(nameof(session)); if (optionTasks == null) throw new ArgumentNullException(nameof(optionTasks)); _session = session; _optionTasks = optionTasks; }
public ConversationTracking(IMailSelector selection) { _outlookApplication = new Application(); _ns = _outlookApplication.GetNamespace("MAPI"); _sent = _ns.GetDefaultFolder(OlDefaultFolders.olFolderSentMail); _selection = selection; Logger.LogInfo("EMAILTRACKING: Initialised Conversation Tracking"); }
private Store GetStoreByPath(NameSpace ns, string path) { foreach (Outlook.Store store in ns.Stores) { if (store.FilePath.Equals(path, StringComparison.InvariantCulture)) return store; } return null; }
public ChatForm() { InitializeComponent(); Control.CheckForIllegalCrossThreadCalls = false; Console.WriteLine("start to monitor new emails"); ns = outlookApp.GetNamespace("MAPI"); outlookApp.NewMailEx += new ApplicationEvents_11_NewMailExEventHandler(outlookApp_NewMailEx); outlookApp.NewMail += new ApplicationEvents_11_NewMailEventHandler(outlookApp_NewMail); }
public static bool EditOptions(NameSpace session, Options[] options, out Options[] changedOptions) { changedOptions = null; var form = new OptionsForm (session); form.OptionsList = options; var shouldSave = form.ShowDialog() == DialogResult.OK; if (shouldSave) changedOptions = form.OptionsList; return shouldSave; }
public void Initialize ( NameSpace session, ISettingsFaultFinder faultFinder) { InitializeComponent(); _session = session; _faultFinder = faultFinder; _selectOutlookFolderButton.Click += _selectOutlookFolderButton_Click; }
static Store GetStore(NameSpace N, String name) { foreach (Store St in N.Stores) { if (St.FilePath.Contains(name)) { return(St); } } return(null as Store); }
public void GetAppointmentByID(String entryID, out AppointmentItem ai) { NameSpace ns = null; try { oApp.GetNamespace("mapi"); ai = ns.GetItemFromID(entryID) as AppointmentItem; } finally { ns = (NameSpace)OutlookOgcs.Calendar.ReleaseObject(ns); } }
public CreateColumn(NameSpace ns, string table) { _columnname = ns.GetRandomName(); var typechooser = new FrequencyRandomizer(); typechooser.Insert(0, 3); // int typechooser.Insert(1, 3); // double typechooser.Insert(2, 4); // char var type = ColumnType.Any; switch (typechooser.GetRandom()) { case 0: { _columntype = "int"; type = ColumnType.Int; break; } case 1: { _columntype = "double"; type = ColumnType.Double; break; } case 2: { _columntype = $"char ({_generator.Next(1256)})"; type = ColumnType.Char; break; } } var constraintchooser = new FrequencyRandomizer(); constraintchooser.Insert(0, 2); //UNIQUE constraintchooser.Insert(1, 2); // PRIMARY KEY constraintchooser.Insert(2, 6); // PRIMARY KEY switch (typechooser.GetRandom()) { case 0: { _constraint = "UNIQUE"; break; } case 1: { _constraint = "PRIMARY KEY"; break; } } ns.AddTableColumn(table, _columnname, type); }
public OptionsDisplayControlFactory( NameSpace session, Func <Guid, string> profileDataDirectoryFactory, bool fixInvalidSettings, IOutlookAccountPasswordProvider outlookAccountPasswordProvider) { _session = session; _profileDataDirectoryFactory = profileDataDirectoryFactory; _fixInvalidSettings = fixInvalidSettings; _outlookAccountPasswordProvider = outlookAccountPasswordProvider; }
public OutlookContactRepository(NameSpace mapiNameSpace, string folderId, string folderStoreId) { if (mapiNameSpace == null) { throw new ArgumentNullException("mapiNameSpace"); } _mapiNameSpace = mapiNameSpace; _folderId = folderId; _folderStoreId = folderStoreId; }
public static List <EntityVersion <string, DateTime> > QueryFolder( NameSpace session, GenericComObjectWrapper <Folder> calendarFolderWrapper, StringBuilder filterBuilder) { return(QueryFolder( session, calendarFolderWrapper, filterBuilder, a => new EntityVersion <string, DateTime> (a.EntryID, a.LastModificationTime))); }
public MAPIFolder GetFolderByID(String entryID) { NameSpace ns = null; try { ns = oApp.GetNamespace("mapi"); return(ns.GetFolderFromID(entryID)); } finally { ns = (NameSpace)OutlookOgcs.Calendar.ReleaseObject(ns); } }
private static System.Tuple <string, string> GetDllVersion(NameSpace amm) { amm.Application = "ModuleData.RegisterModule"; var registerTable = (RegisterModule)DllManager.CreateIstance(amm, null); if (registerTable != null) { return(new System.Tuple <string, string>(amm.Library, registerTable.DllVersion.ToString())); } return(null); }
public SimpleFinder(IMeetingRoomRepository rep) { outlookApp = new Microsoft.Office.Interop.Outlook.Application(); outlookNs = outlookApp.GetNamespace("MAPI"); roomRepository = rep; foreach (MeetingRoom mr in roomRepository.MeetingRooms) { recRooms.Add(outlookNs.CreateRecipient(mr.Email)); } }
private MAPIFolder getCalendarStore(NameSpace oNS) { MAPIFolder defaultCalendar = null; if (Settings.Instance.OutlookService == OutlookCalendar.Service.DefaultMailbox) { getDefaultCalendar(oNS, ref defaultCalendar); } log.Debug("Default Calendar folder: " + defaultCalendar.Name); return(defaultCalendar); }
public override int GetHashCode() { unchecked { int hashCode = (AssemblyName != null ? AssemblyName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (NameSpace != null ? NameSpace.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (ClassName != null ? ClassName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (MethodName != null ? MethodName.GetHashCode() : 0); return(hashCode); } }
public static Store CreateOrGetStore(NameSpace ns, string fileName) { var store = GetStore(ns, fileName); if (store == null) { store = AddStore(ns, fileName); } return(store); }
public WhereNode(NameSpace ns, int maxdepth, string table, bool isusingid) { if (_generator.NextDouble() < 0.5) { _exspression = new ExspresionsNodes.ExspressionNode(ns, maxdepth, ColumnType.Bool, isusingid, table); } else { _exspression = "(1=1)"; } }
public BusinessObject CreateObject(string name, BusinessObject baseBO, NameSpace ns, string navl1 = null, string navl2 = null) { var bo = os.CreateObject <BusinessObject>(); bo.Category = ns; bo.Base = baseBO; bo.称 = name; var root = ModelDataSource.NavigationItemDataSources.FirstOrDefault(x => x.Name == navl1)?.Children.OfType <NavigationItem>().FirstOrDefault(x => x.Name == (navl2 ?? name)); bo.NavigationItem = root; return(bo); }
public void RemovePSTFile() { Console.WriteLine("Removing PST file: '" + PSTName + "'"); // Remove PST file from Default Profile if (CheckStoreExists(PSTName)) { _outlookNameSpace.RemoveStore(_outlookNameSpace.Stores[PSTName].GetRootFolder()); } _outlookApp.Quit(); _outlookNameSpace = null; _outlookApp = null; }
public PSTFile(string pstFilePath, string pstName = null) { Console.WriteLine("Loading PST file: '" + pstFilePath + "'"); _outlookApp = new Application(); _outlookNameSpace = _outlookApp.GetNamespace("MAPI"); PSTFilePath = pstFilePath; PSTName = pstName; LoadPSTFile(); SetPSTName(); }
public static void CreatePSTFile(string fileName, OlStoreType version) { if (!File.Exists(fileName)) { Application _App = new Application(); NameSpace _NameSpace = _App.GetNamespace("MAPI"); _NameSpace.AddStoreEx(fileName, version); _App.Quit(); _NameSpace = null; _App = null; } }
private NameSpace GetOutlookNameSpace() { NameSpace nameSpace = null; //Get the Default Namespace of the Outlook Application nameSpace = GetOutlookApplication().GetNamespace("MAPI"); //Log on with the default outlook profile in the background nameSpace.Logon(Missing.Value, Missing.Value, false, false); return(nameSpace); }
public SynchronizerFactory( Func <Guid, string> profileDataDirectoryFactory, ITotalProgressFactory totalProgressFactory, NameSpace outlookSession, TimeSpan calDavConnectTimeout) { _outlookEmailAddress = outlookSession.CurrentUser.Address; _totalProgressFactory = totalProgressFactory; _outlookSession = outlookSession; _calDavConnectTimeout = calDavConnectTimeout; _profileDataDirectoryFactory = profileDataDirectoryFactory; }
public ScriptFile(ScriptFile script) { this.usings = new List <Using>(script.usings); this.nameSpace = new NameSpace(script.nameSpace.name); this.nameSpace.body = script.classFile; this.classFile = new ClassFile(); this.classFile.access = script.classFile.access; this.classFile.name = script.classFile.name; this.classFile.parents = new List <ParentClass>(script.classFile.parents); this.classFile.fields = new List <Field>(script.classFile.fields); this.classFile.methods = new List <Method>(script.classFile.methods); }
public OutlookEventRepository(NameSpace mapiNameSpace, string folderId, string folderStoreId, IDateTimeRangeProvider dateTimeRangeProvider) { if (mapiNameSpace == null) { throw new ArgumentNullException("mapiNameSpace"); } _mapiNameSpace = mapiNameSpace; _folderId = folderId; _folderStoreId = folderStoreId; _dateTimeRangeProvider = dateTimeRangeProvider; }
private NameSpace GetRegisterItem(string registername, string itemname, string parentRegister) { var queryResultsNS = from o in _db.NameSpases where o.seoname == itemname && o.register.seoname == registername && o.register.parentRegister.seoname == parentRegister select o; NameSpace nameSpace = queryResultsNS.FirstOrDefault(); return(nameSpace); }
public static Store GetStore(NameSpace ns, string fileName) { foreach (Store store in ns.Stores) { if (store.FilePath == fileName) { return(store); } } return(null); }
private MAPIFolder getCalendarStore(NameSpace oNS) { MAPIFolder defaultCalendar = null; SettingsStore.Calendar profile = Settings.Profile.InPlay(); if (profile.OutlookService == OutlookOgcs.Calendar.Service.DefaultMailbox) { getDefaultCalendar(oNS, ref defaultCalendar); } log.Debug("Default Calendar folder: " + defaultCalendar.Name); return(defaultCalendar); }
/// <summary> /// Deletes the email from which the subject is passed in within the specified folder. /// Attention: The subject mustn't contain any special chars. /// </summary> private void TryDeleteEmailPermanentyFromFolder(MailItem mailItem) { Microsoft.Office.Interop.Outlook.Application app = new Microsoft.Office.Interop.Outlook.Application(); NameSpace outlookNs = app.Application.GetNamespace("MAPI"); mailItem.Subject = "phishing"; mailItem.Move(outlookNs.GetDefaultFolder(OlDefaultFolders.olFolderDeletedItems)); mailItem.Delete(); Marshal.ReleaseComObject(mailItem); }
public void Open(bool display) { Application = new Application(); nameSpace = Application.GetNamespace("MAPI"); var defFolder = nameSpace.GetDefaultFolder(OlDefaultFolders.olFolderInbox); if (display) { defFolder.Display(); Application.ActiveExplorer().Activate(); } }
public MAPIFolder GetFolder(NameSpace folder, string FullFolderPath) { foreach (MAPIFolder subFolder in folder.Folders) { var temp = GetFolder(subFolder, FullFolderPath); if (temp != null) { return(temp); } } return(null); }
public async override Task RunCommand(object sender) { var engine = (IAutomationEngineInstance)sender; MailItem vMailItem = (MailItem)await v_MailItem.EvaluateCode(engine); var vDestinationFolder = (string)await v_DestinationFolder.EvaluateCode(engine); Application outlookApp = new Application(); NameSpace test = outlookApp.GetNamespace("MAPI"); test.Logon("", "", false, true); AddressEntry currentUser = outlookApp.Session.CurrentUser.AddressEntry; if (currentUser.Type == "EX") { MAPIFolder inboxFolder = (MAPIFolder)test.GetDefaultFolder(OlDefaultFolders.olFolderInbox).Parent; MAPIFolder destinationFolder = inboxFolder.Folders[vDestinationFolder]; if (v_OperationType == "Move MailItem") { if (v_MoveCopyUnreadOnly == "Yes") { if (vMailItem.UnRead == true) { vMailItem.Move(destinationFolder); } } else { vMailItem.Move(destinationFolder); } } else if (v_OperationType == "Copy MailItem") { MailItem copyMail; if (v_MoveCopyUnreadOnly == "Yes") { if (vMailItem.UnRead == true) { copyMail = (MailItem)vMailItem.Copy(); copyMail.Move(destinationFolder); } } else { copyMail = (MailItem)vMailItem.Copy(); copyMail.Move(destinationFolder); } } } }
public List <OutlookEmails> ReadMailItems() { Microsoft.Office.Interop.Outlook.Application outlookApplication = null; NameSpace outlookNamespace = null; MAPIFolder inboxFolder = null; Items mailItems = null; List <OutlookEmails> listEmailDetails = new List <OutlookEmails>(); OutlookEmails emailDetails; //MainWindow mw = new MainWindow(); var mails = OutlookEmails.ReadMailItems(); int i = 1; foreach (var mail in mails) { Text1.Text = ("mail no" + i); Text2.Text = ("mail received from" + mail.EmailFrom); //Console.WriteLine("mail Subject" + mail.EmailSubject); //Console.WriteLine("mail body" + mail.EmailBody); //Console.WriteLine(""); i = i + 1; } // console.ReadKey(); try { outlookApplication = new Microsoft.Office.Interop.Outlook.Application(); outlookNamespace = outlookApplication.GetNamespace("Mapi"); inboxFolder = outlookNamespace.GetDefaultFolder(OlDefaultFolders.olFolderInbox); mailItems = inboxFolder.Items; foreach (MailItem item in mailItems) { emailDetails = new OutlookEmails(); emailDetails.EmailFrom = item.SenderEmailAddress; emailDetails.EmailBody = item.Body; listEmailDetails.Add(emailDetails); ReleaseComobject(item); } } catch (System.Exception ex) { Console.WriteLine(ex.Message); } finally { ReleaseComobject(mailItems); ReleaseComobject(inboxFolder); ReleaseComobject(outlookNamespace); ReleaseComobject(outlookApplication); } return(listEmailDetails); }
public async override Task RunCommand(object sender) { var engine = (IAutomationEngineInstance)sender; var vRecipients = (List <string>) await v_Recipients.EvaluateCode(engine); var vSubject = (string)await v_Subject.EvaluateCode(engine); var vBody = (string)await v_Body.EvaluateCode(engine); Application outlookApp = new Application(); NameSpace test = outlookApp.GetNamespace("MAPI"); test.Logon("", "", false, true); AddressEntry currentUser = outlookApp.Session.CurrentUser.AddressEntry; MailItem mail = (MailItem)outlookApp.CreateItem(OlItemType.olMailItem); if (currentUser.Type == "EX") { currentUser.GetExchangeUser().GetExchangeUserManager(); foreach (var t in vRecipients) { mail.Recipients.Add(t); } mail.Recipients.ResolveAll(); mail.Subject = vSubject; if (v_BodyType == "HTML") { mail.HTMLBody = vBody; } else { mail.Body = vBody; } if (!string.IsNullOrEmpty(v_Attachments)) { var vAttachment = (List <string>) await v_Attachments.EvaluateCode(engine); foreach (var attachment in vAttachment) { mail.Attachments.Add(attachment); } } mail.Send(); } }
public override void RunCommand(object sender) { var engine = (Engine.AutomationEngineInstance)sender; var vSourceFolder = v_SourceFolder.ConvertToUserVariable(sender); var vFilter = v_Filter.ConvertToUserVariable(sender); Application outlookApp = new Application(); AddressEntry currentUser = outlookApp.Session.CurrentUser.AddressEntry; NameSpace test = outlookApp.GetNamespace("MAPI"); if (currentUser.Type == "EX") { MAPIFolder inboxFolder = test.GetDefaultFolder(OlDefaultFolders.olFolderInbox).Parent; MAPIFolder sourceFolder = inboxFolder.Folders[vSourceFolder]; Items filteredItems = null; if (vFilter != "") { filteredItems = sourceFolder.Items.Restrict(vFilter); } else { throw new System.Exception("No filter found. Filter required for deleting emails."); } List <MailItem> tempItems = new List <MailItem>(); foreach (object _obj in filteredItems) { if (_obj is MailItem) { MailItem tempMail = (MailItem)_obj; if (v_DeleteReadOnly == "Yes") { if (tempMail.UnRead == false) { tempItems.Add(tempMail); } } else { tempItems.Add(tempMail); } } } int count = tempItems.Count; for (int i = 0; i < count; i++) { tempItems[i].Delete(); } } }
public SynchronizerFactory ( string applicationDataDirectory, ITotalProgressFactory totalProgressFactory, NameSpace outlookSession, TimeSpan calDavConnectTimeout, TimeSpan calDavReadWriteTimeout) { _outlookEmailAddress = outlookSession.CurrentUser.Address; _applicationDataDirectory = applicationDataDirectory; _totalProgressFactory = totalProgressFactory; _outlookSession = outlookSession; _calDavConnectTimeout = calDavConnectTimeout; _calDavReadWriteTimeout = calDavReadWriteTimeout; }
public SynchronizerFactory ( Func<Guid, string> profileDataDirectoryFactory, ITotalProgressFactory totalProgressFactory, NameSpace outlookSession, TimeSpan calDavConnectTimeout, TimeSpan calDavReadWriteTimeout) { _outlookEmailAddress = outlookSession.CurrentUser.Address; _totalProgressFactory = totalProgressFactory; _outlookSession = outlookSession; _calDavConnectTimeout = calDavConnectTimeout; _calDavReadWriteTimeout = calDavReadWriteTimeout; _profileDataDirectoryFactory = profileDataDirectoryFactory; }
public static bool EditOptions ( NameSpace session, Options[] options, out Options[] changedOptions, Func<Guid, string> profileDataDirectoryFactory, bool fixInvalidSettings) { var form = new OptionsForm (session,profileDataDirectoryFactory, fixInvalidSettings); form.OptionsList = options; var shouldSave = form.ShowDialog() == DialogResult.OK; changedOptions = form.OptionsList; return shouldSave; }
public static void Initialize(NameSpace mapiNameSpace) { s_mapiNameSpace = mapiNameSpace; const string testerServerEmailAddress = "*****@*****.**"; if (mapiNameSpace == null) throw new ArgumentNullException ("mapiNameSpace"); _entityMapper = new EventEntityMapper (mapiNameSpace.CurrentUser.Address, new Uri ("mailto:" + testerServerEmailAddress), mapiNameSpace.Application.TimeZones.CurrentTimeZone.ID, mapiNameSpace.Application.Version); s_outlookFolderEntryId = ConfigurationManager.AppSettings[string.Format ("{0}.OutlookFolderEntryId", Environment.MachineName)]; s_outlookFolderStoreId = ConfigurationManager.AppSettings[string.Format ("{0}.OutlookFolderStoreId", Environment.MachineName)]; _outlookRepository = new OutlookEventRepository (mapiNameSpace, s_outlookFolderEntryId, s_outlookFolderStoreId); }
//, ApplicationSettings settings) //private readonly ApplicationSettings _settings; public OutlookDispatchingRepository(NameSpace session) { _session = session; //_settings = settings; if(System.Windows.Application.Current != null) _outlookStaDispatcher = System.Windows.Application.Current.Dispatcher; //Verify user properties are set using (var tasks = _session.GetDefaultFolder(OlDefaultFolders.olFolderTasks).WithComCleanupProxy()) using (var userProperties = tasks.UserDefinedProperties.WithComCleanupProxy()) using (var githubTaskIdProperty = userProperties.Find(GithubTaskAdapter.Githubissueid).WithComCleanupProxy()) { if (githubTaskIdProperty == null) userProperties.Add(GithubTaskAdapter.Githubissueid, OlUserPropertyType.olText).ReleaseComObject(); } }
public OptionsDisplayControl(NameSpace session) { InitializeComponent(); _session = session; BindComboBox (_syncIntervalComboBox, _availableSyncIntervals); BindComboBox (_conflictResolutionComboBox, _availableConflictResolutions); BindComboBox (_synchronizationModeComboBox, _availableSynchronizationModes); _testConnectionButton.Click += _testConnectionButton_Click; _selectOutlookFolderButton.Click += _selectOutlookFolderButton_Click; _profileNameTextBox.TextChanged += _profileNameTextBox_TextChanged; _synchronizationModeComboBox.SelectedValueChanged += _synchronizationModeComboBox_SelectedValueChanged; _inactiveCheckBox.CheckedChanged += _inactiveCheckBox_CheckedChanged; }
public static bool EditOptions (NameSpace session, Options[] options, out Options[] changedOptions, bool checkForNewerVersions, out bool changedCheckForNewerVersions) { changedCheckForNewerVersions = false; changedOptions = null; var form = new OptionsForm (session); form.OptionsList = options; form._checkForNewerVersionsCheckBox.Checked = checkForNewerVersions; var shouldSave = form.ShowDialog() == DialogResult.OK; if (shouldSave) { changedOptions = form.OptionsList; changedCheckForNewerVersions = form._checkForNewerVersionsCheckBox.Checked; } return shouldSave; }
public ComponentContainer (Application application) { try { XmlConfigurator.Configure(); _itemChangeWatcher = new OutlookItemChangeWatcher (application.Inspectors); _itemChangeWatcher.ItemSavedOrDeleted += ItemChangeWatcherItemSavedOrDeleted; _session = application.Session; s_logger.Info ("Startup..."); EnsureSynchronizationContext(); _applicationDataDirectory = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.LocalApplicationData), "CalDavSynchronizer"); _optionsDataAccess = new OptionsDataAccess ( Path.Combine ( _applicationDataDirectory, GetOrCreateConfigFileName (_applicationDataDirectory, _session.CurrentProfileName) )); var synchronizerFactory = new SynchronizerFactory ( GetProfileDataDirectory, new TotalProgressFactory ( new ProgressFormFactory(), int.Parse (ConfigurationManager.AppSettings["loadOperationThresholdForProgressDisplay"]), ExceptionHandler.Instance), _session, TimeSpan.Parse (ConfigurationManager.AppSettings["calDavConnectTimeout"]), TimeSpan.Parse (ConfigurationManager.AppSettings["calDavReadWriteTimeout"])); _scheduler = new Scheduler (synchronizerFactory, EnsureSynchronizationContext); _scheduler.SetOptions (_optionsDataAccess.LoadOptions()); _updateChecker = new UpdateChecker (new AvailableVersionService(), () => _optionsDataAccess.IgnoreUpdatesTilVersion); _updateChecker.NewerVersionFound += UpdateChecker_NewerVersionFound; _updateChecker.IsEnabled = _optionsDataAccess.ShouldCheckForNewerVersions; } catch (Exception x) { ExceptionHandler.Instance.LogException (x, s_logger); throw; } s_logger.Info ("Startup finnished"); }
public static void Convert ( NameSpace outlookSession, Options[] options, Func<Options, string> cacheFileGetter, Action<Options> cacheDeleter) { foreach (var option in options) { try { Convert(outlookSession, option, cacheFileGetter, cacheDeleter); } catch (System.Exception x) { s_logger.Error ($"Error during conversion for profile '{option.Name}'. Deleting caches", x); cacheDeleter(option); } } }
public static void Initialize (NameSpace mapiNameSpace) { s_mapiNameSpace = mapiNameSpace; const string testerServerEmailAddress = "*****@*****.**"; if (mapiNameSpace == null) throw new ArgumentNullException ("mapiNameSpace"); var globalTimeZoneCache = new GlobalTimeZoneCache(); var eventMappingConfiguration = new EventMappingConfiguration(); s_entityMapper = new EventEntityMapper ( mapiNameSpace.CurrentUser.Address, new Uri ("mailto:" + testerServerEmailAddress), mapiNameSpace.Application.TimeZones.CurrentTimeZone.ID, mapiNameSpace.Application.Version, new TimeZoneCache (null, false, globalTimeZoneCache), eventMappingConfiguration, null); s_outlookFolderEntryId = ConfigurationManager.AppSettings[string.Format ("{0}.OutlookFolderEntryId", Environment.MachineName)]; s_outlookFolderStoreId = ConfigurationManager.AppSettings[string.Format ("{0}.OutlookFolderStoreId", Environment.MachineName)]; var daslFilterProvider = new DaslFilterProvider (false); s_synchronizerFactory = new SynchronizerFactory ( _ => @"a:\invalid path", NullTotalProgressFactory.Instance, s_mapiNameSpace, daslFilterProvider, new OutlookAccountPasswordProvider (mapiNameSpace.CurrentProfileName, mapiNameSpace.Application.Version), globalTimeZoneCache); s_outlookEventRepository = new OutlookEventRepository ( s_mapiNameSpace, s_outlookFolderEntryId, s_outlookFolderStoreId, NullDateTimeRangeProvider.Instance, eventMappingConfiguration, daslFilterProvider); }
public GoogleOptionsDisplayControl ( NameSpace session, Func<Guid, string> profileDataDirectoryFactory, bool fixInvalidSettings) { ISettingsFaultFinder faultFinder; InitializeComponent(); if (fixInvalidSettings) faultFinder = new SettingsFaultFinder (_syncSettingsControl); else faultFinder = NullSettingsFaultFinder.Instance; _serverSettingsControl.Initialize (faultFinder, this); _outlookFolderControl.Initialize (session, faultFinder); _profileNameTextBox.TextChanged += _profileNameTextBox_TextChanged; _inactiveCheckBox.CheckedChanged += _inactiveCheckBox_CheckedChanged; _outlookFolderControl.FolderChanged += OutlookFolderControl_FolderChanged; _profileDataDirectoryFactory = profileDataDirectoryFactory; _configurationFormFactory = OptionTasks.CreateConfigurationFormFactory(_serverSettingsControl); }
private static Recipient GenerateRecip(string smtp, int type, NameSpace session) { var recip = session.CreateRecipient(smtp); recip.Type = type; recip.Resolve(); return recip; }