Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
(def assembly-path "C:\\Users\\cplmam\\Downloads\\\\lib\\net20\\Microsoft.Office.Interop.Outlook.dll")
(assembly-load-from assembly-path)
(import Microsoft.CSharp.CSharpCodeProvider)
(import System.CodeDom.Compiler.CompilerParameters)
(def provider (CSharpCodeProvider.))
(def assemblies (into-array [assembly-path]))
(def compilerparams (CompilerParameters. assemblies))
(.set_GenerateExecutable compilerparams false)
(.set_GenerateInMemory compilerparams true)
(defn cc [code]
(-> provider (.CompileAssemblyFromSource compilerparams code) .CompiledAssembly))
(defn cm [code]
(-> code cc (.GetType "Hello1") (.GetMethod "Main")))
(def m
(cm "
using System.Runtime.InteropServices;
using OutLook = Microsoft.Office.Interop.Outlook;
public class Hello1
public static object Main(OutLook.Application oApp)
OutLook._NameSpace oNS = (OutLook._NameSpace)oApp.GetNamespace(\"MAPI\");
OutLook.MAPIFolder oFolder = oNS.GetDefaultFolder(OutLook.OlDefaultFolders.olFolderInbox);
OutLook.Items items = oFolder.Items;
foreach (OutLook.MailItem mail in items)
return mail;
return null;
(import System.Runtime.InteropServices.Marshal)
(defonce outlook (Marshal/GetActiveObject "Outlook.Application"))
(.Invoke m nil (to-array [outlook])) ;nil is an object for instance methods
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.