Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 235960f450 | |||
| 9298c3c287 |
+1
-1
@@ -2,7 +2,7 @@
|
||||
; Erfordert Inno Setup 6.x (https://jrsoftware.org/isinfo.php)
|
||||
|
||||
#define MyAppName "Starface Outlook Sync"
|
||||
#define MyAppVersion "0.0.0.4"
|
||||
#define MyAppVersion "0.0.0.5"
|
||||
#define MyAppPublisher "HackerSoft - Hacker-Net Telekommunikation"
|
||||
#define MyAppURL "https://www.hacker-net.de"
|
||||
#define MyAppExeName "StarfaceOutlookSync.exe"
|
||||
|
||||
@@ -50,20 +50,29 @@ namespace StarfaceOutlookSync.Services
|
||||
var app = GetOutlookApp();
|
||||
var ns = app.GetNamespace("MAPI");
|
||||
|
||||
// Standard-Kontaktordner
|
||||
var defaultFolder = ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts);
|
||||
folders.Add(defaultFolder.FolderPath);
|
||||
|
||||
// Unterordner
|
||||
AddSubFolders(defaultFolder, folders);
|
||||
|
||||
// Weitere Kontaktordner in anderen Stores
|
||||
// Alle Stores durchgehen (jedes Konto, jede PST-Datei etc.)
|
||||
foreach (Outlook.Store store in ns.Stores)
|
||||
{
|
||||
try
|
||||
{
|
||||
var rootFolder = store.GetRootFolder();
|
||||
FindContactFolders(rootFolder, folders);
|
||||
FindContactFoldersRecursive(rootFolder, folders);
|
||||
Marshal.ReleaseComObject(rootFolder);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine($"Error scanning store '{store.DisplayName}': {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
// Falls nichts gefunden, Standard-Kontaktordner als Fallback
|
||||
if (folders.Count == 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
var defaultFolder = ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts);
|
||||
folders.Add(defaultFolder.FolderPath);
|
||||
Marshal.ReleaseComObject(defaultFolder);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
@@ -78,30 +87,34 @@ namespace StarfaceOutlookSync.Services
|
||||
return folders;
|
||||
}
|
||||
|
||||
private void AddSubFolders(Outlook.MAPIFolder folder, List<string> paths)
|
||||
private void FindContactFoldersRecursive(Outlook.MAPIFolder folder, List<string> paths)
|
||||
{
|
||||
foreach (Outlook.MAPIFolder sub in folder.Folders)
|
||||
try
|
||||
{
|
||||
if (sub.DefaultItemType == Outlook.OlItemType.olContactItem)
|
||||
// Kontaktordner erkennen: DefaultItemType ODER Ordnername enthaelt "Kontakt"/"Contact"
|
||||
if (folder.DefaultItemType == Outlook.OlItemType.olContactItem)
|
||||
{
|
||||
if (!paths.Contains(sub.FolderPath))
|
||||
paths.Add(sub.FolderPath);
|
||||
AddSubFolders(sub, paths);
|
||||
if (!paths.Contains(folder.FolderPath))
|
||||
paths.Add(folder.FolderPath);
|
||||
}
|
||||
|
||||
// Alle Unterordner durchsuchen
|
||||
foreach (Outlook.MAPIFolder sub in folder.Folders)
|
||||
{
|
||||
try
|
||||
{
|
||||
FindContactFoldersRecursive(sub, paths);
|
||||
}
|
||||
catch { }
|
||||
finally
|
||||
{
|
||||
Marshal.ReleaseComObject(sub);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void FindContactFolders(Outlook.MAPIFolder folder, List<string> paths)
|
||||
{
|
||||
if (folder.DefaultItemType == Outlook.OlItemType.olContactItem)
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (!paths.Contains(folder.FolderPath))
|
||||
paths.Add(folder.FolderPath);
|
||||
}
|
||||
|
||||
foreach (Outlook.MAPIFolder sub in folder.Folders)
|
||||
{
|
||||
FindContactFolders(sub, paths);
|
||||
System.Diagnostics.Debug.WriteLine($"Error scanning folder '{folder.Name}': {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
<AssemblyTitle>Starface Outlook Sync</AssemblyTitle>
|
||||
<Company>HackerSoft - Hacker-Net Telekommunikation</Company>
|
||||
<Product>Starface Outlook Sync</Product>
|
||||
<Version>0.0.0.4</Version>
|
||||
<AssemblyVersion>0.0.0.4</AssemblyVersion>
|
||||
<FileVersion>0.0.0.4</FileVersion>
|
||||
<Version>0.0.0.5</Version>
|
||||
<AssemblyVersion>0.0.0.5</AssemblyVersion>
|
||||
<FileVersion>0.0.0.5</FileVersion>
|
||||
<Description>Synchronisiert Outlook-Kontakte mit Starface Telefonanlage</Description>
|
||||
<Copyright>Stefan Hacker - HackerSoft</Copyright>
|
||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace StarfaceOutlookSync.UI
|
||||
|
||||
var lblVersion = new Label
|
||||
{
|
||||
Text = "Version 0.0.0.4",
|
||||
Text = "Version 0.0.0.5",
|
||||
Left = 0, Top = 56, Width = 340, Height = 20,
|
||||
TextAlign = ContentAlignment.MiddleCenter,
|
||||
ForeColor = Color.Gray
|
||||
|
||||
@@ -142,9 +142,12 @@ namespace StarfaceOutlookSync.UI
|
||||
_outlookFolderPaths = outlook.GetContactFolderPaths();
|
||||
}
|
||||
}
|
||||
catch
|
||||
catch (Exception ex)
|
||||
{
|
||||
_outlookFolderPaths = new List<string> { "\\\\Kontakte" };
|
||||
MessageBox.Show(
|
||||
$"Outlook-Kontaktordner konnten nicht geladen werden:\n{ex.Message}\n\nIst Outlook gestartet?",
|
||||
"Outlook-Verbindung", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
_outlookFolderPaths = new List<string>();
|
||||
}
|
||||
|
||||
// Bestehende Werte laden
|
||||
|
||||
Reference in New Issue
Block a user