Example #1
0
 def __init__(self, filename="LOG1.txt", host_port=""):
     # mailbox="Archive Rafael Briones", folderindex=1):
     self.f = FileWriter(filename)
     self.outlook = win32com.client.gencache.EnsureDispatch(
         "Outlook.Application").GetNamespace("MAPI")
     inbox = self.outlook.GetDefaultFolder(
         win32com.client.constants.olFolderInbox)
     self.inbox = inbox
     self.host_port = host_port
 def __init__(self, filename="LOG1.txt", host_port=""):
     # mailbox="Archive Rafael Briones", folderindex=1):
     self.f = FileWriter(filename)
     self.outlook = win32com.client.gencache.EnsureDispatch("Outlook.Application").GetNamespace("MAPI")
     inbox = self.outlook.GetDefaultFolder(win32com.client.constants.olFolderInbox)
     self.inbox = inbox
     self.host_port = host_port
class DriverEmailTracker:
    def __init__(self, filename="LOG1.txt", host_port=""):
        # mailbox="Archive Rafael Briones", folderindex=1):
        self.f = FileWriter(filename)
        self.outlook = win32com.client.gencache.EnsureDispatch("Outlook.Application").GetNamespace("MAPI")
        inbox = self.outlook.GetDefaultFolder(win32com.client.constants.olFolderInbox)
        self.inbox = inbox
        self.host_port = host_port

    def check(self):
        subject_defect = "QC_MAAB.Sistemas_TVI - Defect"
        search_subject_defect = "'%s%%'" % subject_defect
        subject_update_env = unicode(u'ActualizaciĆ³n Ambientes Testing')
        subject_update_env2 = unicode(u'Actualizacion Ambientes Testing')
        search_subject_update_env = "'%Ambientes Testing'"
        restrict_criteria = "@SQL=\"urn:schemas:httpmail:read\" = 0 And (\"urn:schemas:mailheader:subject\"  like %s Or \"urn:schemas:mailheader:subject\" like %s)" % (
            search_subject_defect, search_subject_update_env)
        print restrict_criteria
        # And [Subject] like '%QC_MAAB.Sistemas_TVI -
        self.f.pl(time.strftime("%H:%M:%S"))
        tot = 0
        all_messages = self.inbox.Items
        messages = all_messages.Restrict(restrict_criteria)
        message = messages.GetFirst()
        while message:
            print message.Subject
            self.f.pl(message.Subject)
            self.f.pl(message.HTMLBody)
            if subject_defect in message.Subject:
                process_defect_email(message.HTMLBody, self.host_port)

            unicode_subject = unicode(message.Subject)
            if subject_update_env == unicode_subject or subject_update_env2 == unicode_subject:
                print 'message.SenderEmailAddress = %s' % message.SenderName
                process_updating_environment(message.HTMLBody, self.host_port, message.SenderName)
            message.UnRead = False
            message = messages.GetNext()
            tot += 1
        self.f.pl("Total Messages found: %i" % tot)
        self.f.pl("-" * 80)
        self.f.flush()
Example #4
0
class DriverEmailTracker:
    def __init__(self, filename="LOG1.txt", host_port=""):
        # mailbox="Archive Rafael Briones", folderindex=1):
        self.f = FileWriter(filename)
        self.outlook = win32com.client.gencache.EnsureDispatch(
            "Outlook.Application").GetNamespace("MAPI")
        inbox = self.outlook.GetDefaultFolder(
            win32com.client.constants.olFolderInbox)
        self.inbox = inbox
        self.host_port = host_port

    def check(self):
        subject_defect = "QC_MAAB.Sistemas_TVI - Defect"
        search_subject_defect = "'%s%%'" % subject_defect
        subject_update_env = unicode(u'ActualizaciĆ³n Ambientes Testing')
        subject_update_env2 = unicode(u'Actualizacion Ambientes Testing')
        search_subject_update_env = "'%Ambientes Testing'"
        restrict_criteria = "@SQL=\"urn:schemas:httpmail:read\" = 0 And (\"urn:schemas:mailheader:subject\"  like %s Or \"urn:schemas:mailheader:subject\" like %s)" % (
            search_subject_defect, search_subject_update_env)
        print restrict_criteria
        # And [Subject] like '%QC_MAAB.Sistemas_TVI -
        self.f.pl(time.strftime("%H:%M:%S"))
        tot = 0
        all_messages = self.inbox.Items
        messages = all_messages.Restrict(restrict_criteria)
        message = messages.GetFirst()
        while message:
            print message.Subject
            self.f.pl(message.Subject)
            self.f.pl(message.HTMLBody)
            if subject_defect in message.Subject:
                process_defect_email(message.HTMLBody, self.host_port)

            unicode_subject = unicode(message.Subject)
            if subject_update_env == unicode_subject or subject_update_env2 == unicode_subject:
                print 'message.SenderEmailAddress = %s' % message.SenderName
                process_updating_environment(message.HTMLBody, self.host_port,
                                             message.SenderName)
            message.UnRead = False
            message = messages.GetNext()
            tot += 1
        self.f.pl("Total Messages found: %i" % tot)
        self.f.pl("-" * 80)
        self.f.flush()