示例#1
0
 public void Reset()
 {
     findseed = null;
     origin   = new MapiRecipDesc();
     recpts.Clear();
     attachs.Clear();
     lastMsg = null;
 }
示例#2
0
        public void AddRecip(string name, string addr, bool cc)
        {
            MapiRecipDesc dest = new MapiRecipDesc();

            if (cc)
            {
                dest.recipClass = MapiCC;
            }
            else
            {
                dest.recipClass = MapiTO;
            }
            dest.name    = name;
            dest.address = addr;
            recpts.Add(dest);
        }
示例#3
0
        public bool Next(ref MailEnvelop env)
        {
            error = MAPIFindNext(session, winhandle, null, findseed,
                                 MapiLongMsgID, 0, lastMsgID);
            if (error != 0)
            {
                return(false);
            }
            findseed = lastMsgID.ToString();

            IntPtr ptrmsg = IntPtr.Zero;

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

            lastMsg = new MapiMessage();
            Marshal.PtrToStructure(ptrmsg, lastMsg);
            MapiRecipDesc orig = new 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 & MapiUnread) != 0;
            env.atts    = lastMsg.fileCount;

            error = MAPIFreeBuffer(ptrmsg);
            return(error == 0);
        }
示例#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);
            }

            MapiRecipDesc recip = new MapiRecipDesc();

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

            MAPIFreeBuffer(ptrnew);
            return(true);
        }