Пример #1
0
        public static int SendMail(string strAttachmentFileName, string strSubject)
        {
            IntPtr session   = new IntPtr(0);
            IntPtr winhandle = new IntPtr(0);

            CMapiMessage msg = new CMapiMessage();

            msg.subject = strSubject;

            int    sizeofMapiDesc = Marshal.SizeOf(typeof(CMapiFileDesc));
            IntPtr pMapiDesc      = Marshal.AllocHGlobal(sizeofMapiDesc);

            CMapiFileDesc fileDesc = new CMapiFileDesc();

            fileDesc.position = -1;
            int ptr = (int)pMapiDesc;

            string strPath = strAttachmentFileName;

            fileDesc.name = Path.GetFileName(strPath);
            fileDesc.path = strPath;
            Marshal.StructureToPtr(fileDesc, (IntPtr)ptr, false);

            msg.files     = pMapiDesc;
            msg.fileCount = 1;

            return(MAPISendMail(session, winhandle, msg, MAPI_LOGON_UI | MAPI_DIALOG, 0));
        }
Пример #2
0
        public static int SendMail(string strAttachmentFileName, string strSubject)
        {
            IntPtr session = new IntPtr(0);
            IntPtr winhandle = new IntPtr(0);

            CMapiMessage msg = new CMapiMessage();
            msg.subject = strSubject;

            int sizeofMapiDesc = Marshal.SizeOf(typeof(CMapiFileDesc));
            IntPtr pMapiDesc = Marshal.AllocHGlobal(sizeofMapiDesc);

            CMapiFileDesc fileDesc = new CMapiFileDesc();
            fileDesc.position = -1;
            int ptr = (int)pMapiDesc;

            string strPath = strAttachmentFileName;
            fileDesc.name = Path.GetFileName(strPath);
            fileDesc.path = strPath;
            Marshal.StructureToPtr(fileDesc, (IntPtr)ptr, false);

            msg.files = pMapiDesc;
            msg.fileCount = 1;

            return MAPISendMail(session, winhandle, msg, MAPI_LOGON_UI | MAPI_DIALOG, 0);
        }