//////////////////////////////////////////////////////////////////////////////////////////////////////////// // // This function moves the first message from the Inbox to the Sent Items folder (requested by user) // // NOTE: MAPIEx takes care of the internal folder, but in this case you have an external folder that must // be disposed of. // //////////////////////////////////////////////////////////////////////////////////////////////////////////// public static void MoveMessageTest(NetMAPI mapi) { if (mapi.OpenInbox() && mapi.GetContents()) { mapi.SortContents(false); MAPIMessage message; StringBuilder s = new StringBuilder(NetMAPI.DefaultBufferSize); if (mapi.GetNextMessage(out message)) { Console.Write("Moving message from '"); message.GetSenderName(s); Console.Write(s.ToString() + "' ("); message.GetSenderEmail(s); Console.Write(s.ToString() + "), subject '"); message.GetSubject(s); Console.Write(s.ToString() + "'\n"); MAPIFolder sentItems = mapi.OpenSentItems(false); if (mapi.Folder.MoveMessage(message, sentItems)) { Console.WriteLine("Message moved successfully"); } sentItems.Dispose(); message.Dispose(); } } }