Bonjour,
J'ai testé un code écrit en c# sur Visual Studio sensé donner l'arborescence d'Outlook (dossiers, sous dossiers,...)
Mais quand j'essaye d'ajouter une référence COM en plus au projet et que je valide, elle se décoche toute seule après....
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63 using System; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.InteropServices; using Microsoft.Office.Interop.Outlook; namespace OutlookAddIn1 { class Sample { Outlook.Application GetApplicationObject() { Outlook.Application application = null; // Check whether there is an Outlook process running. if (Process.GetProcessesByName("OUTLOOK").Count() > 0) { // If so, use the GetActiveObject method to obtain the process and cast it to an Application object. application = Marshal.GetActiveObject("Outlook.Application") as Outlook.Application; } else { // If not, create a new instance of Outlook and sign in to the default profile. application = new Outlook.Application(); Outlook.NameSpace nameSpace = application.GetNamespace("MAPI"); nameSpace.Logon("", "", Missing.Value, Missing.Value); nameSpace = null; } // Return the Outlook Application object. return application; } private void EnumerateFoldersInDefaultStore() { Outlook.Folder root = Application.Session. DefaultStore.GetRootFolder() as Outlook.Folder; EnumerateFolders(root); } // Uses recursion to enumerate Outlook subfolders. private void EnumerateFolders(Outlook.Folder folder) { Outlook.Folders childFolders = folder.Folders; if (childFolders.Count > 0) { foreach (Outlook.Folder childFolder in childFolders) { // Write the folder path. Debug.WriteLine(childFolder.FolderPath); // Call EnumerateFolders using childFolder. EnumerateFolders(childFolder); } } } } }
Partager