Example #1
0
        private void Cleanup(ref MapiMessage msg)
        {
            int size = Marshal.SizeOf(typeof(MapiRecipDesc));
            int ptr = 0;

            if (msg.Recips != IntPtr.Zero)
            {
                ptr = (int)msg.Recips;
                for (int i = 0; i < msg.RecipCount; i++)
                {
                    Marshal.DestroyStructure((IntPtr)ptr, typeof(MapiRecipDesc));
                    ptr += size;
                }
                Marshal.FreeHGlobal(msg.Recips);
            }

            if (msg.Files != IntPtr.Zero)
            {
                size = Marshal.SizeOf(typeof(MapiFileDesc));

                ptr = (int)msg.Files;
                for (int i = 0; i < msg.FileCount; i++)
                {
                    Marshal.DestroyStructure((IntPtr)ptr, typeof(MapiFileDesc));
                    ptr += size;
                }
                Marshal.FreeHGlobal(msg.Files);
            }

            _recipients.Clear();
            _attachments.Clear();
        }
Example #2
0
        private int SendMail(String strSubject, String strBody, int how)
        {
            MapiMessage msg = new MapiMessage();

            msg.Subject = strSubject;
            msg.NoteText = strBody;

            msg.Recips = GetRecipients(out msg.RecipCount);
            msg.Files = GetAttachments(out msg.FileCount);

            _lastError = NativeMethods.MapiSendMail(new IntPtr(0), new IntPtr(0), msg, how, 0);

            Cleanup(ref msg);

            return _lastError;
        }
Example #3
0
 internal static extern int MapiSendMail(IntPtr sess, IntPtr hwnd, MapiMessage message, int flg, int rsv);