Beispiel #1
0
 public void Reset()
 {
     findseed = null;
     origin   = new Win32.MapiRecipDesc();
     recpts.Clear();
     attachs.Clear();
     lastMsg = null;
 }
Beispiel #2
0
 public void AddRecip( string name, string addr, bool cc )
 {
     Win32.MapiRecipDesc dest = new Win32.MapiRecipDesc();
     if( cc )
         dest.recipClass = Win32.MAPI32.MapiCC;
     else
         dest.recipClass = Win32.MAPI32.MapiTO;
     dest.name = name;
     dest.address = addr;
     recpts.Add( dest );
 }
Beispiel #3
0
 public void AddRecip(string name, string addr, bool cc)
 {
     Win32.MapiRecipDesc dest = new Win32.MapiRecipDesc();
     if (cc)
     {
         dest.recipClass = Win32.MAPI32.MapiCC;
     }
     else
     {
         dest.recipClass = Win32.MAPI32.MapiTO;
     }
     dest.name    = name;
     dest.address = addr;
     recpts.Add(dest);
 }
Beispiel #4
0
        public bool SingleAddress(string label, out string name, out string addr)
        {
            name = null;
            addr = null;
            int    newrec = 0;
            IntPtr ptrnew = IntPtr.Zero;

            error = MAPIAddress(session, winhandle, null, 1, label, 0, IntPtr.Zero,
                                0, 0, ref newrec, ref ptrnew);
            if ((error != 0) || (newrec < 1) || (ptrnew == IntPtr.Zero))
            {
                return(false);
            }

            Win32.MapiRecipDesc recip = new Win32.MapiRecipDesc();
            Marshal.PtrToStructure(ptrnew, recip);
            name = recip.name;
            addr = recip.address;

            Win32.MAPI32.MAPIFreeBuffer(ptrnew);
            return(true);
        }
Beispiel #5
0
        // ----------------------------------------------------------- FINDING ---------

        public bool Next(ref MailEnvelop env)
        {
            error = Win32.MAPI32.MAPIFindNext(session, winhandle, null, findseed,
                                              Win32.MAPI32.MapiLongMsgID, 0, lastMsgID);
            if (error != 0)
            {
                return(false);
            }
            findseed = lastMsgID.ToString();

            IntPtr ptrmsg = IntPtr.Zero;

            error = Win32.MAPI32.MAPIReadMail(session, winhandle, findseed,
                                              Win32.MAPI32.MapiEnvOnly | Win32.MAPI32.MapiPeek | Win32.MAPI32.MapiSuprAttach, 0, ref ptrmsg);
            if ((error != 0) || (ptrmsg == IntPtr.Zero))
            {
                return(false);
            }

            lastMsg = new Win32.MapiMessage();
            Marshal.PtrToStructure(ptrmsg, lastMsg);
            Win32.MapiRecipDesc orig = new Win32.MapiRecipDesc();
            if (lastMsg.originator != IntPtr.Zero)
            {
                Marshal.PtrToStructure(lastMsg.originator, orig);
            }

            env.id      = findseed;
            env.date    = DateTime.ParseExact(lastMsg.dateReceived, "yyyy/MM/dd HH:mm", DateTimeFormatInfo.InvariantInfo);
            env.subject = lastMsg.subject;
            env.from    = orig.name;
            env.unread  = (lastMsg.flags & Win32.MAPI32.MapiUnread) != 0;
            env.atts    = lastMsg.fileCount;

            error = Win32.MAPI32.MAPIFreeBuffer(ptrmsg);
            return(error == 0);
        }
Beispiel #6
0
        public bool SingleAddress( string label, out string name, out string addr )
        {
            name = null;
            addr = null;
            int newrec = 0;
            IntPtr ptrnew = IntPtr.Zero;
            error = MAPIAddress(	session, winhandle, null, 1, label, 0, IntPtr.Zero,
                0, 0, ref newrec, ref ptrnew );
            if( (error != 0) || (newrec < 1) || (ptrnew == IntPtr.Zero) )
                return false;

            Win32.MapiRecipDesc recip = new Win32.MapiRecipDesc();
            Marshal.PtrToStructure( ptrnew, recip );
            name = recip.name;
            addr = recip.address;

            Win32.MAPI32.MAPIFreeBuffer( ptrnew );
            return true;
        }
Beispiel #7
0
 public void Reset()
 {
     findseed = null;
     origin = new Win32.MapiRecipDesc();
     recpts.Clear();
     attachs.Clear();
     lastMsg = null;
 }
Beispiel #8
0
        // ----------------------------------------------------------- FINDING ---------
        public bool Next( ref MailEnvelop env )
        {
            error = Win32.MAPI32.MAPIFindNext(	session, winhandle, null, findseed,
                Win32.MAPI32.MapiLongMsgID, 0, lastMsgID );
            if( error != 0 )
                return false;
            findseed = lastMsgID.ToString();

            IntPtr ptrmsg = IntPtr.Zero;
            error = Win32.MAPI32.MAPIReadMail( session, winhandle, findseed,
                Win32.MAPI32.MapiEnvOnly | Win32.MAPI32.MapiPeek | Win32.MAPI32.MapiSuprAttach, 0, ref ptrmsg );
            if( (error != 0) || (ptrmsg == IntPtr.Zero) )
                return false;

            lastMsg = new Win32.MapiMessage();
            Marshal.PtrToStructure( ptrmsg, lastMsg );
            Win32.MapiRecipDesc orig = new Win32.MapiRecipDesc();
            if( lastMsg.originator != IntPtr.Zero )
                Marshal.PtrToStructure( lastMsg.originator, orig );

            env.id		= findseed;
            env.date	= DateTime.ParseExact( lastMsg.dateReceived, "yyyy/MM/dd HH:mm", DateTimeFormatInfo.InvariantInfo );
            env.subject	= lastMsg.subject;
            env.from	= orig.name;
            env.unread	= (lastMsg.flags & Win32.MAPI32.MapiUnread) != 0;
            env.atts	= lastMsg.fileCount;

            error = Win32.MAPI32.MAPIFreeBuffer( ptrmsg );
            return error == 0;
        }