Bonjour
J'essaie d'envoyer un mail en utilisant la librairie de office avec c#
mais cela ne marche pas.
Après la création de l'objet outlook, le process se bloque, et il ne se passe rien.
Voici mon code
Merci de m'aider à résoudre ce problème.
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 // Create an Outlook application. oOutlook = new Microsoft.Office.Interop.Outlook.Application(); // Get the namespace and the logon. oNS = oOutlook.GetNamespace("MAPI"); oNS.Logon(missing, missing, true, true); oMail = (Microsoft.Office.Interop.Outlook.MailItem)oOutlook.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem); // Set the properties of the email. oMail.Subject = "Feedback of All-In-One Code Framework"; oMail.To = "mon@mail.com"; oMail.HTMLBody = "<b>Feedback:</b><br />"; oMail.Importance = Microsoft.Office.Interop.Outlook.OlImportance.olImportanceHigh; oMail.Display(false); // Modal=true makes the Inspector window modal // Automatically send the mail without a new Inspector window. ((Microsoft.Office.Interop.Outlook._MailItem)oMail).Send(); oNS.Logoff(); ((Microsoft.Office.Interop.Outlook._Application)oOutlook).Quit(); // Clean up the unmanaged COM resources. releaseObject(oMail); releaseObject(oNS); releaseObject(oOutlook); GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); GC.WaitForPendingFinalizers();
Partager