SourceForge.net Logo

Mail Monitor++

- Home
- Project home
- Downloads
   - Version 1.0

- Forums



Introduction

MailMonitor++ is a Pop3 Monitor application.

Features

The mailmonitor++ has the following features:

  • Fast email check.
  • Animation and sound to notify incoming messages.
  • Start you favorite email client.

Sample screenshot

Email account configuration.

Main protocol:

void CPop3Check::ParseMsg()
{
  CString s;
  strstream str;
  string check;
  str <<(LPCSTR)lastMsg;
  str >> check;

  if (check == "-ERR")
  {
    error = "Error -ERR from server :"+lastMsg;
    Close();
    return;
  }
  switch (state)
  {
    case FIRST:
      fromUltMensaje = "";
      newmsgs =0;
      numnewmsg = 0;
      ((DLG)m_pWnd)->Dispatch(S_RECEIVE); 
      s.Format("user %s%c%c", user, 13, 10);
      Send((LPCSTR)s, s.GetLength()); 
      state = USER;
      break;
    
    case USER:
      ((DLG)m_pWnd)->Dispatch(S_RECEIVE);
      s.Format("pass %s%c%c", pass, 13, 10); 
      Send((LPCSTR)s, s.GetLength()); 
      state = PASS;
      break;
    
    case PASS:
      ((DLG)m_pWnd)->Dispatch(S_RECEIVE);
      s.Format("stat%c%c", 13, 10);
      Send((LPCSTR)s, s.GetLength()); 
      state = STAT; 
      break;
    
    case STAT:
      {
        ud->initRegMsgs();
        string s1;
        str.seekg(0);
        str >> s1 >> numMsg >> sizeMsg; 
        flush(str);
        ((DLG)m_pWnd)->Dispatch(S_GETNUMMSGS);
        ((DLG)m_pWnd)->Dispatch(S_GETSIZEMSGS);
        if (numMsg>0)
        {
          state = UIDL;
          s.Format("uidl 1%c%c", 13, 10);
          bufmail = "";
          retrMsg = 1;
          Send((LPCSTR)s, s.GetLength()); 
        }
        else 
        {
          error = "No new messages.";
          Close();
        }
      }
      break;
    case UIDL:
      {
        string s1, s2;
        int p1;
        CString uidl;
        str.seekg(0);
        str >> s1 >> p1 >> s2;
        uidl = s2.data();
        if (ud->IsNewMail(uidl))
        {
          newmsgs += 1;
          numnewmsg = retrMsg;
        }

        if (retrMsg < numMsg) 
        {
          retrMsg++;
          state = UIDL;
          s.Format("uidl %d%c%c", retrMsg, 13, 10);
          Send((LPCSTR)s, s.GetLength());
        }
        else
        {
          if (newmsgs == 1)
          {
            state = RETR;
            s.Format("top %d %d%c%c", numnewmsg, MAX_TOPLINES_EMAIL, 13, 10); 
            bufmail = "";
            Send((LPCSTR)s, s.GetLength()); 
          }
          else
          {
            state = ENDRETR;
            ((DLG)m_pWnd)->Dispatch(S_ENDRETR);
            error = "Session closed";
            s.Format("quit%c%c", 13, 10);
            Send((LPCSTR)s, s.GetLength());
            Close();
          }
        }
      }
      break;

    case RETR:
      {
        bufmail += lastMsg;

        int where = bufmail.Find("From:");
        if (where >= 0 && where + 80 < bufmail.GetLength())
        {
          fromUltMensaje = "";
          ReadLn(where + 5, bufmail, fromUltMensaje);

          char *sfrom = (char*)calloc(fromUltMensaje.GetLength()+1, sizeof(char));
          strcpy(sfrom, fromUltMensaje);
          fromUltMensaje = MimeDecodeMailHeaderField(sfrom);
          free(sfrom);

          state = ENDRETR;
          ((DLG)m_pWnd)->Dispatch(S_ENDRETR);
          error = "Session closed";
          s.Format("quit%c%c", 13, 10);
          Send((LPCSTR)s, s.GetLength());
          Close();
        }
      }
      break;
    case GOON: // default
    default:
      ((DLG)m_pWnd)->Dispatch(S_RECEIVE);
      break;
  }
}

Credits

History

  • 05/04/2004 - Initial version.