IntPtr GetAttachments(string fileName, out int fileCount) { int size = Marshal.SizeOf(typeof(MapiFileDesc)); IntPtr intPtr = Marshal.AllocHGlobal(size); MapiFileDesc mapiFileDesc = new MapiFileDesc(); //An integer used to indicate where in the message text to render the attachment. mapiFileDesc.position = -1; int ptr = (int)intPtr; mapiFileDesc.name = fileName; mapiFileDesc.path = System.IO.Directory.GetCurrentDirectory() + @"\" + fileName; Marshal.StructureToPtr(mapiFileDesc, (IntPtr)ptr, false); ptr += size; fileCount = 1; return intPtr; }
IntPtr GetAttachments(string fileName, out int fileCount) { int size = Marshal.SizeOf(typeof(MapiFileDesc)); IntPtr intPtr = Marshal.AllocHGlobal(size); MapiFileDesc mapiFileDesc = new MapiFileDesc(); //An integer used to indicate where in the message text to render the attachment. mapiFileDesc.position = -1; int ptr = (int)intPtr; mapiFileDesc.name = fileName; mapiFileDesc.path = System.IO.Directory.GetCurrentDirectory() + @"\" + fileName; Marshal.StructureToPtr(mapiFileDesc, (IntPtr)ptr, false); ptr += size; fileCount = 1; return(intPtr); }