Example #1
0
        private int ShowMail(EventWaitHandle waitHandle)
        {
            var message = new Mapi.MapiMessage();
            int errorCode;

            using (var recipientCollectionHandle = Recipients.GetHandle())
                using (var attachmentCollectionHandle = Attachments.GetHandle())
                {
                    message.Subject  = Subject;
                    message.NoteText = Body;

                    message.Recipients     = recipientCollectionHandle;
                    message.RecipientCount = Recipients.Count;

                    message.Files     = attachmentCollectionHandle;
                    message.FileCount = Attachments.Count;

                    // Signal the creating thread (make the remaining code async)
                    if (waitHandle != null)
                    {
                        waitHandle.Set();
                    }

                    //blocking call, waits till the mail message dialog closes
                    errorCode = Mapi.MAPISendMail(IntPtr.Zero, IntPtr.Zero, message, Mapi.MAPI_DIALOG, 0);
                }

            OnSendMailComplete(errorCode);
            return(errorCode);
        }
        private int ShowMail(EventWaitHandle waitHandle)
        {
            var message = new Mapi.MapiMessage();
            int errorCode;

            using (var recipientCollectionHandle = Recipients.GetHandle())
            using (var attachmentCollectionHandle = Attachments.GetHandle())
            {
                message.Subject = Subject;
                message.NoteText = Body;

                message.Recipients = recipientCollectionHandle;
                message.RecipientCount = Recipients.Count;

                message.Files = attachmentCollectionHandle;
                message.FileCount = Attachments.Count;

                // Signal the creating thread (make the remaining code async)
                if (waitHandle != null)
                    waitHandle.Set();

                //blocking call, waits till the mail message dialog closes
                errorCode = Mapi.MAPISendMail(IntPtr.Zero, IntPtr.Zero, message, Mapi.MAPI_DIALOG, 0);
            }

            OnSendMailComplete(errorCode);
            return errorCode;
        }