Beispiel #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));
        }
Beispiel #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);
        }
Beispiel #3
0
 private static extern int MAPISendMail(IntPtr sess, IntPtr hwnd, CMapiMessage message, int flg, int rsv);
Beispiel #4
0
 private static extern int MAPISendMail(IntPtr sess, IntPtr hwnd,CMapiMessage message, int flg, int rsv);