From: vincent@cubedesigners.com Date: Wed, 30 May 2018 17:12:23 +0000 (+0000) Subject: wip #2074 @3 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=1789917f1b84c6b4008d4cd087a8244b48690ae2;p=cubeextranet.git wip #2074 @3 --- diff --git a/fluidbook/bourbon/compile.bat b/fluidbook/bourbon/compile.bat new file mode 100644 index 000000000..4c71cecf0 --- /dev/null +++ b/fluidbook/bourbon/compile.bat @@ -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 +pause \ No newline at end of file diff --git a/fluidbook/bourbon/sendemail.bat b/fluidbook/bourbon/sendemail.bat new file mode 100644 index 000000000..aeb3924f2 --- /dev/null +++ b/fluidbook/bourbon/sendemail.bat @@ -0,0 +1,2 @@ +@echo off +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 index 000000000..9985d91a7 --- /dev/null +++ b/fluidbook/bourbon/sendemail.cs @@ -0,0 +1,45 @@ +using System; +using Outlook = Microsoft.Office.Interop.Outlook; + +namespace BourbonFluidbook +{ + class Bourbon + { + static void Main() + { + String[] args = Environment.GetCommandLineArgs(); + Bourbon.sendEmail(args[1], args[2], args[3], args[4], args[5]); + } + + public static void sendEmail(string to,string subject,string body,string attachment,string attachmentName) + { + try + { + Outlook.Application oApp = new Outlook.Application(); + + // These 3 lines solved the problem + Outlook.NameSpace ns = oApp.GetNamespace("MAPI"); + Outlook.MAPIFolder f = ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox); + System.Threading.Thread.Sleep(5000); // test + + Outlook.MailItem oMsg = (Outlook.MailItem) oApp.CreateItem(Outlook.OlItemType.olMailItem); + oMsg.HTMLBody = body; + oMsg.Subject = subject; + Outlook.Attachments oAttachments = (Outlook.Attachments)oMsg.Attachments; + Outlook.Attachment oAttachment = (Outlook.Attachment)oAttachments.Add(attachment,1,0,attachmentName); + Outlook.Recipients oRecips = (Outlook.Recipients)oMsg.Recipients; + Outlook.Recipient oRecip = (Outlook.Recipient)oRecips.Add(to); + oRecip.Resolve(); + oMsg.Send(); + oRecip = null; + oRecips = null; + oMsg = null; + oApp = null; + } + catch (Exception ex) + { + + } + } + } +} \ No newline at end of file