Exemplo n.º 1
0
        // ----------------------------------------------------------- FINDING ---------

        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);
        }
Exemplo n.º 2
0
		// ----------------------------------------------------------- FINDING ---------

		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);
			var 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;
		}