]> _ Git - cubeextranet.git/commitdiff
wip #2074 @3
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Wed, 30 May 2018 17:12:23 +0000 (17:12 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Wed, 30 May 2018 17:12:23 +0000 (17:12 +0000)
fluidbook/bourbon/compile.bat [new file with mode: 0644]
fluidbook/bourbon/sendemail.bat [new file with mode: 0644]
fluidbook/bourbon/sendemail.cs [new file with mode: 0644]

diff --git a/fluidbook/bourbon/compile.bat b/fluidbook/bourbon/compile.bat
new file mode 100644 (file)
index 0000000..4c71cec
--- /dev/null
@@ -0,0 +1,2 @@
+csc -out:H:\Works\cubeExtranet\fluidbook\bourbon\sendemail.exe -reference:"C:\Program Files (x86)\Microsoft Office\root\Office16\ADDINS\Microsoft Power Query for Excel Integrated\bin\Microsoft.Office.Interop.Outlook.dll" H:\Works\cubeExtranet\fluidbook\bourbon\sendemail.cs\r
+pause
\ No newline at end of file
diff --git a/fluidbook/bourbon/sendemail.bat b/fluidbook/bourbon/sendemail.bat
new file mode 100644 (file)
index 0000000..aeb3924
--- /dev/null
@@ -0,0 +1,2 @@
+@echo off\r
+sendemail.exe "test@cubedesigners.com" "Message de test" "Corps du message de test" "H:\Works\cubeExtranet\fluidbook\bourbon\report.txt" "report.txt"
\ No newline at end of file
diff --git a/fluidbook/bourbon/sendemail.cs b/fluidbook/bourbon/sendemail.cs
new file mode 100644 (file)
index 0000000..9985d91
--- /dev/null
@@ -0,0 +1,45 @@
+using System;\r
+using Outlook = Microsoft.Office.Interop.Outlook;\r
+\r
+namespace BourbonFluidbook\r
+{\r
+    class Bourbon\r
+    {\r
+        static void Main()\r
+        {\r
+            String[] args = Environment.GetCommandLineArgs();\r
+            Bourbon.sendEmail(args[1], args[2], args[3], args[4], args[5]);\r
+        }\r
+\r
+        public static void sendEmail(string to,string subject,string body,string attachment,string attachmentName)\r
+        {\r
+            try\r
+            {\r
+                Outlook.Application oApp = new Outlook.Application();\r
+\r
+                // These 3 lines solved the problem\r
+                Outlook.NameSpace ns = oApp.GetNamespace("MAPI");\r
+                Outlook.MAPIFolder f = ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);\r
+                System.Threading.Thread.Sleep(5000); // test\r
+\r
+                Outlook.MailItem oMsg = (Outlook.MailItem) oApp.CreateItem(Outlook.OlItemType.olMailItem);\r
+                    oMsg.HTMLBody = body;\r
+                    oMsg.Subject = subject;\r
+                    Outlook.Attachments oAttachments = (Outlook.Attachments)oMsg.Attachments;\r
+                    Outlook.Attachment oAttachment = (Outlook.Attachment)oAttachments.Add(attachment,1,0,attachmentName);\r
+                    Outlook.Recipients oRecips = (Outlook.Recipients)oMsg.Recipients;\r
+                    Outlook.Recipient oRecip = (Outlook.Recipient)oRecips.Add(to);\r
+                    oRecip.Resolve();\r
+                    oMsg.Send();\r
+                    oRecip = null;\r
+                    oRecips = null;\r
+                    oMsg = null;\r
+                    oApp = null;\r
+            }\r
+            catch (Exception ex)\r
+            {\r
+\r
+            }\r
+        }\r
+    }\r
+}
\ No newline at end of file