IntPtr GetAttachments(out int fileCount) { fileCount = 0; if (_attachments == null) { return(IntPtr.Zero); } if ((_attachments.Count <= 0) || (_attachments.Count > maxAttachments)) { return(IntPtr.Zero); } int size = Marshal.SizeOf(typeof(MapiFileDesc)); IntPtr intPtr = Marshal.AllocHGlobal(_attachments.Count * size); MapiFileDesc mapiFileDesc = new MapiFileDesc(); mapiFileDesc.position = -1; int ptr = (int)intPtr; foreach (string strAttachment in _attachments) { mapiFileDesc.name = Path.GetFileName(strAttachment); mapiFileDesc.path = strAttachment; Marshal.StructureToPtr(mapiFileDesc, (IntPtr)ptr, false); ptr += size; } fileCount = _attachments.Count; return(intPtr); }
IntPtr GetAttachments(out int fileCount) { fileCount = 0; if (_attachments == null) return IntPtr.Zero; if ((_attachments.Count <= 0) || (_attachments.Count > maxAttachments)) return IntPtr.Zero; int size = Marshal.SizeOf(typeof(MapiFileDesc)); IntPtr intPtr = Marshal.AllocHGlobal(_attachments.Count * size); MapiFileDesc mapiFileDesc = new MapiFileDesc(); mapiFileDesc.position = -1; int ptr = (int)intPtr; foreach (string strAttachment in _attachments) { mapiFileDesc.name = Path.GetFileName(strAttachment); mapiFileDesc.path = strAttachment; Marshal.StructureToPtr(mapiFileDesc, (IntPtr)ptr, false); ptr += size; } fileCount = _attachments.Count; return intPtr; }