Ce que j'essaie de faire est d'ajouter un bouton "Email To ..." à un client winform qui ouvre une nouvelle fenêtre de courrier Outlook et attache un fichier pour que l'utilisateur puisse le transférer. Je peux obtenir l'intégration de perspectives fonctionnant très bien si les perspectives ne fonctionnent pas déjà. Ceci est une application Winforms C# .NET 4.0, en utilisant la bibliothèque d'interopérabilité Outlook 14.0, par rapport à Outlook 2010 32 bits s'exécutant sur Windows 7 64 bit machine. J'ai l'application déjà compilé en x86 pour d'autres raisons, donc je doute que ce soit un problème 32/64 bits. Voici mon code:Comment se connecter à Outlook 2010 pendant son exécution dans C#?
// Connect to outlook and create a new mail item
var app = new Outlook.Application();
var ns = app.GetNamespace("MAPI");
var mailItem = (Outlook.MailItem)ns.Application.CreateItem(Outlook.OlItemType.olMailItem);
// create the mail item and attach the file
mailItem.To = "";
mailItem.Subject = "Emailing: " + Path.GetFileName(_currentFilePath);
mailItem.Attachments.Add(_currentFilePath, Outlook.OlAttachmentType.olEmbeddeditem);
// show the email dialog window
mailItem.Display(true);
Si Outlook ne fonctionne pas, il fonctionne parfaitement. Une fois son ouverture, je reçois l'erreur suivante sur la première ligne où il tente de créer l'objet Outlook.Application:
Retrieving the COM class factory for component with CLSID {0006F03A-0000-0000-C000-000000000046} failed due to the following error: 80080005 Server execution failed (Exception from HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE)).
Toutes les idées ce qui cause cela? Est-ce une sorte de conflit de version?
Vous devriez accepter la réponse de Jahmics, c'est correct. – flayn