--- /dev/null
+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