示例#1
0
 private static extern int MAPISendMail(IntPtr sess, IntPtr hwnd,
                                        MapiMessage message,
                                        int flg, int rsv);
示例#2
0
		// ----------------------------------------------------------- SENDING ---------

		public bool Send(string subject, string noteText, bool ShowDialog)
		{
			int flags = 0;

			if (ShowDialog)
			{
				flags = MAPI_DIALOG;
			}

			lastMsg = new MapiMessage {subject = subject, noteText = noteText, originator = AllocOrigin()};

			// set pointers
			lastMsg.recips = AllocRecips(out lastMsg.recipCount);
			lastMsg.files = AllocAttachs(out lastMsg.fileCount);
			error = MAPISendMail(session, winhandle, lastMsg, flags, 0);

			Dealloc();
			Reset();
			return error == 0;
		}
示例#3
0
		public bool SaveAttachm(string id, string name, string savepath)
		{
			IntPtr ptrmsg = IntPtr.Zero;
			error = MAPIReadMail(session, winhandle, id,
			                     MapiPeek, 0, ref ptrmsg);
			if ((error != 0) || (ptrmsg == IntPtr.Zero))
				return false;

			lastMsg = new MapiMessage();
			Marshal.PtrToStructure(ptrmsg, lastMsg);
			bool f = false;
			if ((lastMsg.fileCount > 0) && (lastMsg.fileCount < 100) && (lastMsg.files != IntPtr.Zero))
				f = SaveAttachByName(name, savepath);
			MAPIFreeBuffer(ptrmsg);
			return f;
		}
示例#4
0
		// ----------------------------------------------------------- READING ---------

		public string Read(string id, out MailAttach[] aat)
		{
			aat = null;
			IntPtr ptrmsg = IntPtr.Zero;
			error = MAPIReadMail(session, winhandle, id,
			                     MapiPeek | MapiSuprAttach, 0, ref ptrmsg);
			if ((error != 0) || (ptrmsg == IntPtr.Zero))
				return null;

			lastMsg = new MapiMessage();
			Marshal.PtrToStructure(ptrmsg, lastMsg);

			if ((lastMsg.fileCount > 0) && (lastMsg.fileCount < 100) && (lastMsg.files != IntPtr.Zero))
				GetAttachNames(out aat);

			MAPIFreeBuffer(ptrmsg);
			return lastMsg.noteText;
		}
示例#5
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;
		}
示例#6
0
		private static extern int MAPISendMail(IntPtr sess, IntPtr hwnd,
		                                       MapiMessage message,
		                                       int flg, int rsv);