/// <summary> /// Default constructor. /// </summary> /// <param name="session">Reference to current IMAP session.</param> /// <param name="messageInfo">Message info what message items to get.</param> /// <param name="messageItems">Specifies message items what must be filled.</param> public IMAP_eArgs_MessageItems(IMAP_Session session, IMAP_Message messageInfo, IMAP_MessageItems_enum messageItems) { m_pSession = session; m_pMessageInfo = messageInfo; m_MessageItems = messageItems; }
/// <summary> /// Raises event GetMessageItems. /// </summary> /// <param name="session">Reference to IMAP session.</param> /// <param name="messageInfo">Message info what message items to get.</param> /// <param name="messageItems">Specifies message items what must be filled.</param> /// <returns></returns> protected internal IMAP_eArgs_MessageItems OnGetMessageItems(IMAP_Session session, IMAP_Message messageInfo, IMAP_MessageItems_enum messageItems) { IMAP_eArgs_MessageItems eArgs = new IMAP_eArgs_MessageItems(session, messageInfo, messageItems); if (GetMessageItems != null) { GetMessageItems(session, eArgs); } return(eArgs); }
/// <summary> /// Raises event 'DeleteMessage'. /// </summary> /// <param name="session">Reference to IMAP session.</param> /// <param name="message">Message which to delete.</param> /// <returns></returns> internal string OnDeleteMessage(IMAP_Session session, IMAP_Message message) { Message_EventArgs eArgs = new Message_EventArgs(Core.Decode_IMAP_UTF7_String(session.SelectedMailbox), message); if (DeleteMessage != null) { DeleteMessage(session, eArgs); } return(eArgs.ErrorText); }
/* * /// <summary> * /// Raises event 'Search'. * /// </summary> * /// <param name="session">IMAP session what calls this search.</param> * /// <param name="folder">Folder what messages to search.</param> * /// <param name="matcher">Matcher what must be used to check if message matches searching criterial.</param> * /// <returns></returns> * internal IMAP_eArgs_Search OnSearch(IMAP_Session session,string folder,IMAP_SearchMatcher matcher) * { * IMAP_eArgs_Search eArgs = new IMAP_eArgs_Search(session,folder,matcher); * if(this.Search != null){ * this.Search(session,eArgs); * } * * return eArgs; * }*/ /// <summary> /// Raises event 'StoreMessageFlags'. /// </summary> /// <param name="session">Reference to IMAP session.</param> /// <param name="msg">Message which flags to store.</param> /// <returns></returns> internal string OnStoreMessageFlags(IMAP_Session session, IMAP_Message msg) { Message_EventArgs eArgs = new Message_EventArgs(Core.Decode_IMAP_UTF7_String(session.SelectedMailbox), msg); if (StoreMessageFlags != null) { StoreMessageFlags(session, eArgs); } return(eArgs.ErrorText); }
/// <summary> /// Raises event 'CopyMessage'. /// </summary> /// <param name="session">Reference to IMAP session.</param> /// <param name="msg">Message which to copy.</param> /// <param name="location">New message location.</param> /// <returns></returns> internal string OnCopyMessage(IMAP_Session session, IMAP_Message msg, string location) { Message_EventArgs eArgs = new Message_EventArgs(Core.Decode_IMAP_UTF7_String(session.SelectedMailbox), msg, location); if (CopyMessage != null) { CopyMessage(session, eArgs); } return(eArgs.ErrorText); }
/// <summary> /// Adds new message info to the collection. /// </summary> /// <param name="id">Message ID.</param> /// <param name="uid">Message IMAP UID value.</param> /// <param name="internalDate">Message store date.</param> /// <param name="size">Message size in bytes.</param> /// <param name="flags">Message flags.</param> /// <returns>Returns added IMAp message info.</returns> public IMAP_Message Add(string id, long uid, DateTime internalDate, long size, IMAP_MessageFlags flags) { if (uid < 1) { throw new ArgumentException("Message UID value must be > 0 !"); } IMAP_Message message = new IMAP_Message(this, id, uid, internalDate, size, flags); m_pMessages.Add(uid, message); return message; }
/// <summary> /// Adds new message info to the collection. /// </summary> /// <param name="id">Message ID.</param> /// <param name="uid">Message IMAP UID value.</param> /// <param name="internalDate">Message store date.</param> /// <param name="size">Message size in bytes.</param> /// <param name="flags">Message flags.</param> /// <returns>Returns added IMAp message info.</returns> public IMAP_Message Add(string id, long uid, DateTime internalDate, long size, IMAP_MessageFlags flags) { if (uid < 1) { throw new ArgumentException("Message UID value must be > 0 !"); } IMAP_Message message = new IMAP_Message(this, id, uid, internalDate, size, flags); m_pMessages.Add(uid, message); return(message); }
/// <summary> /// Raises event 'StoreMessage'. /// </summary> /// <param name="session">Reference to IMAP session.</param> /// <param name="folder">Folder where to store.</param> /// <param name="msg">Message which to store.</param> /// <param name="messageData">Message data which to store.</param> /// <returns></returns> internal string OnStoreMessage(IMAP_Session session, string folder, IMAP_Message msg, byte[] messageData) { Message_EventArgs eArgs = new Message_EventArgs(folder, msg); eArgs.MessageData = messageData; if (StoreMessage != null) { StoreMessage(session, eArgs); } return(eArgs.ErrorText); }
/// <summary> /// Updates current folder messages info with new messages info. /// </summary> /// <param name="folder"></param> /// <returns></returns> internal string Update(IMAP_SelectedFolder folder) { StringBuilder retVal = new StringBuilder(); long maxUID = MessageUidNext - 1; long countExists = Messages.Count; long countRecent = RecentCount; // Add new messages for (int i = folder.Messages.Count - 1; i >= 0; i--)//FIX { IMAP_Message message = folder.Messages[i]; // New message if (message.UID > maxUID) { m_pMessages.Add(message.ID, message.UID, message.InternalDate, message.Size, message.Flags); } // New messages ended else { break; } } // Remove deleted messages for (int i = 0; i < m_pMessages.Count; i++) { IMAP_Message message = m_pMessages[i]; if (!folder.m_pMessages.ContainsUID(message.UID)) { retVal.Append("* " + message.SequenceNo + " EXPUNGE\r\n"); m_pMessages.Remove(message); i--; } } if (countExists != Messages.Count) { retVal.Append("* " + Messages.Count + " EXISTS\r\n"); } if (countRecent != RecentCount) { retVal.Append("* " + RecentCount + " RECENT\r\n"); } return(retVal.ToString()); }
/// <summary> /// Gets index of specified message in the collection. /// </summary> /// <param name="message">Message indesx to get.</param> /// <returns>Returns index of specified message in the collection or -1 if message doesn't belong to this collection.</returns> public int IndexOf(IMAP_Message message) { return(m_pMessages.IndexOfKey(message.UID)); }
/// <summary> /// Removes specified IMAP message from the collection. /// </summary> /// <param name="message">IMAP message to remove.</param> public void Remove(IMAP_Message message) { m_pMessages.Remove(message.UID); }
/// <summary> /// Is called when DATA command is finnished. /// </summary> /// <param name="result"></param> /// <param name="count"></param> /// <param name="exception"></param> /// <param name="tag"></param> private void EndAppendCmd(IAsyncResult ar) { try { TcpStream.EndReadFixedCount(ar); if (ar.IsCompleted) { Hashtable param = (Hashtable)ar.AsyncState; string cmdTag = (string)param["cmdTag"]; string mailbox = (string)param["mailbox"]; IMAP_MessageFlags mFlags = (IMAP_MessageFlags)param["mFlags"]; DateTime date = (DateTime)param["date"]; MemoryStream strm = (MemoryStream)param["strm"]; IMAP_Message msg = new IMAP_Message(null, "", 0, date, 0, mFlags); string errotText = ImapServer.OnStoreMessage(this, mailbox, msg, strm.ToArray()); if (errotText == null) { WriteLine(string.Format("{0} OK APPEND completed, recieved {1} bytes", cmdTag, strm.Length)); } else { WriteLine(string.Format("{0} NO {1}", cmdTag, errotText)); } } // Command completed ok, get next command BeginRecieveCmd(); } catch (Exception x) { OnError(x); } }
/// <summary> /// Gets index of specified message in the collection. /// </summary> /// <param name="message">Message indesx to get.</param> /// <returns>Returns index of specified message in the collection or -1 if message doesn't belong to this collection.</returns> public int IndexOf(IMAP_Message message) { return m_pMessages.IndexOfKey(message.UID); }