Beispiel #1
0
        int processMail(object oMsg)
        {
            if (oMsg == null)
            {
                return(-1);
            }
            int foundAttachements = 0;

            if (oMsg == null)
            {
                return(-2);
            }
            Outlook.MailItem mitem = oMsg as Outlook.MailItem;
            if (mitem == null)
            {
                return(-3);
            }
            if (mitem.Subject != null)
            {
                helpers.addLog(string.Format("looking at: {0}\n", mitem.Subject));
            }
            else
            {
                helpers.addLog(string.Format("looking at: {0}\n", mitem.EntryID));
            }

            if (mitem.Attachments.Count == 0)
            {
                return(-4);
            }
            else
            {
                //look for .xml
                foreach (Outlook.Attachment att in mitem.Attachments)
                {
                    if (att.FileName.EndsWith("xml"))
                    {
                        foundAttachements++;
                    }
                }
                if (foundAttachements == 0)
                {
                    return(-5);   //no attachement ending in xml
                }
            }
            if (mitem.Subject.IndexOf(helpers.filterSubject) == -1)
            {
                return(-6);
            }
            if (mitem.Subject.IndexOf(sMailHasAlreadyProcessed) >= 0)  //do not process mail again
            {
                return(-7);
            }

            //process mail
            helpers.addLog(string.Format("### mail found: {0},\n{1}\n\n", mitem.Subject, mitem.Body));
            OnStateChanged(new StatusEventArgs(StatusType.ews_pulse, "getMail: processing eMail " + mitem.Subject));
            MailMsg myMailMsg = new MailMsg(mitem, _userData.sUser);
            int     iRet      = _licenseMail.processMail(myMailMsg);

            //change subject
            if (mitem.Subject.IndexOf(sMailHasAlreadyProcessed) == -1)
            {
                mitem.Subject += sMailHasAlreadyProcessed;
                mitem.Close(Outlook.OlInspectorClose.olSave);
            }

            OnStateChanged(new StatusEventArgs(StatusType.license_mail, "processed " + iRet.ToString()));
            Thread.Sleep(100);
            Thread.Yield();
            return(iRet);
        }
Beispiel #2
0
        int processMail(object oMsg)
        {
            if (oMsg == null)
                return -1;
            int foundAttachements = 0;
            if (oMsg == null)
                return -2;
            Outlook.MailItem mitem = oMsg as Outlook.MailItem;
            if (mitem == null)
                return -3;
            if (mitem.Subject != null)
                helpers.addLog(string.Format("looking at: {0}\n", mitem.Subject));
            else
                helpers.addLog(string.Format("looking at: {0}\n", mitem.EntryID));

            if (mitem.Attachments.Count == 0)
                return -4;
            else
            {
                //look for .xml
                foreach (Outlook.Attachment att in mitem.Attachments)
                {
                    if (att.FileName.EndsWith("xml"))
                        foundAttachements++;
                }
                if (foundAttachements == 0)
                    return -5;   //no attachement ending in xml
            }
            if (mitem.Subject.IndexOf(helpers.filterSubject) == -1)
                return -6;
            if (mitem.Subject.IndexOf(sMailHasAlreadyProcessed) >= 0)  //do not process mail again
                return -7;

            //process mail
            helpers.addLog(string.Format("### mail found: {0},\n{1}\n\n", mitem.Subject, mitem.Body));
            OnStateChanged(new StatusEventArgs(StatusType.ews_pulse, "getMail: processing eMail " + mitem.Subject));
            MailMsg myMailMsg = new MailMsg(mitem, _userData.sUser);
            int iRet = _licenseMail.processMail(myMailMsg);

            //change subject
            if (mitem.Subject.IndexOf(sMailHasAlreadyProcessed) == -1)
            {
                mitem.Subject += sMailHasAlreadyProcessed;
                mitem.Close(Outlook.OlInspectorClose.olSave);
            }

            OnStateChanged(new StatusEventArgs(StatusType.license_mail, "processed " + iRet.ToString()));
            Thread.Sleep(100);
            Thread.Yield();
            return iRet;
        }