Ejemplo n.º 1
0
        /* ----------------------------------------------------------------- */
        ///
        /// AttachFile
        ///
        /// <summary>
        /// 添付ファイルに関する設定を実行します。
        /// </summary>
        ///
        /* ----------------------------------------------------------------- */
        private void AttachFile(Mapi32.MapiMessage mms)
        {
            if (!Attach.HasValue())
            {
                return;
            }

            var size = Marshal.SizeOf(typeof(Mapi32.MapiFileDesc));
            var ptr  = Marshal.AllocHGlobal(size);
            var cvt  = (int)ptr;
            var desc = new Mapi32.MapiFileDesc
            {
                position = -1,
                path     = Attach,
                name     = System.IO.Path.GetFileName(Attach),
            };

            Marshal.StructureToPtr(desc, (IntPtr)cvt, false);
        }
Ejemplo n.º 2
0
        /* ----------------------------------------------------------------- */
        ///
        /// Show
        ///
        /// <summary>
        /// メール画面を表示します。
        /// </summary>
        ///
        /* ----------------------------------------------------------------- */
        public void Show()
        {
            var mms = new Mapi32.MapiMessage
            {
                subject  = Subject,
                noteText = Body,
                flags    = 0x02, // MAPI_RECEIPT_REQUESTED
            };

            AttachFile(mms);

            var result = Mapi32.NativeMethods.MAPISendMail(
                IntPtr.Zero,
                IntPtr.Zero,
                mms,
                0x09, // MAPI_DIALOG | MAPI_LOGON_UI
                0
                );

            if (result != 0)
            {
                throw new Win32Exception(result);
            }
        }