コード例 #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);
        }
コード例 #2
0
        private void ShowMail(object parameter)
        {
            var manualResetEvent = parameter as ManualResetEvent;

            int error = ShowMail(manualResetEvent);

            // Check for error
            if (error > Mapi.MAPI_USER_ABORT)
            {
                string errorMessage = Mapi.GetError(error);
                Debug.WriteLine(errorMessage);
            }
        }