Do not let any software impress you!

Only let it convince your intellect.
Slider img 1
Do not look for a business paradise!

It is a waste of time.
Slider img 2
Only yourself can push you uphill.

There is no easy road to prizes.
Slider img 3
Productivity is the name of the game.

And you have to conquer it.
Slider img 4
As long as you understand it,

you will start to build your know-how.
Slider img 5
We can help with that.

We have the tools and the method.
Slider img 6
Procedure : AU_MAIL_PLANNER

AutoScript

start_agent_info
   AgentName = "AU_MAIL_PLANNER"
   AgentDescr = "Mail Planner"
   PR_FNAME = ""
   PR_TNAME = ""   
   __timer_interval = 1000
end_agent_info

start_bpm_activity "Mail Attachements Characterization"
start_bpm_subactivity "Mail Attachment"
    
    
    
end_bpm_subactivity
end_bpm_activity

start_bpm_activity "Mail Attachments Characterization"
start_bpm_subactivity "Mail Attachments"
    
      mail = __params[1]
      date = __params[2]
      call OpenFormTop("ptBrowse","AU_DOCREL2_B.FM","QRY.DATA","ACTIVITY_MODE",mail,date)
      
end_bpm_subactivity
end_bpm_activity

start_bpm_activity "Bounced Mail Manipulation"
start_bpm_subactivity "Bounced Mail"
        
    mail = __params[1]        
    date = __params[2]
    call OpenFormTop("ptBrowse","AU_MAIL_BOUNCED_B.FM","QRY.DATA","ACTIVITY_MODE",mail,date)
    
end_bpm_subactivity
end_bpm_activity

start_action

   call trace("AU_MAIL_PLANNER planner agent - out - _TraversingHour=",_TraversingHour)
   call trace("_CurrentDate_Num=",_CurrentDate_Num," fired_date=",fired_date)

   {.............................................................MAIL ATTACHMENTS CHARACTERIZATION}

   when ( _TraversingHour = 6) and ((_CurrentDate_Num > fired_date) or (fired_date = 0)) do

        date = crDate
        date = DateToNum(date)
        date = date-1         {..........characterize yesterdays attachments}
        date = NumToDate(date)                                                        
   call trace("AU_MAIL_PLANNER, date=",date)                                             

        start_sql "*" "KOSMOS"
         SELECT POP3_USER, AU_USER, AU_POS FROM AU_MAIL_POP3
        end_sql                                        
        q = QueryByName()
        call TExecute(q)
        count = TRecordCount(q)
   call trace("count=",count)
        call TFirst(q)
        for i = 1 to count

         mail = TGetFld(q,"POP3_USER")
         uname = TGetFld(q,"AU_USER")
         uname = LookUpId("AU_USER",uname,"UNAME")
         rname = TGetFld(q,"AU_POS")
         rname = LookUpId("AU_POS",rname,"POS_D")

         start_sql "*" "KOSMOS"
         SELECT AU_MAIL_POP3.POP3_USER
         FROM ((AU_MAILADDRESS RIGHT JOIN (((((AU_MAIL RIGHT JOIN (AU_DOC RIGHT JOIN (AU_DOC_REL
         LEFT JOIN AU_DOC_RELTYPE2 ON AU_DOC_REL.AU_DOC_RELTYPE2 = AU_DOC_RELTYPE2.AU_DOC_RELTYPE2)
         ON AU_DOC.AU_DOC = AU_DOC_REL.AU_DOC) ON AU_MAIL.AU_DOC = AU_DOC.AU_DOC)
         LEFT JOIN AU_CONTACT ON AU_DOC_REL.REL_REC_ID = AU_CONTACT.AU_CONTACT)
         LEFT JOIN AU_CONTACT_MAILADDR ON AU_CONTACT.AU_CONTACT = AU_CONTACT_MAILADDR.AU_CONTACT)
         LEFT JOIN AU_MAIL_ADDR ON AU_MAIL.AU_MAIL = AU_MAIL_ADDR.AU_MAIL)
         LEFT JOIN AU_DATACOLLECTTYPE ON AU_DOC_RELTYPE2.AU_DATACOLLECTTYPE = AU_DATACOLLECTTYPE.AU_DATACOLLECTTYPE)
         ON AU_MAILADDRESS.AU_MAILADDRESS = AU_MAIL_ADDR.AU_MAILADDRESS) LEFT JOIN AU_MAIL_POP3_MBOX
         ON AU_MAIL.AU_MAIL_POP3_MBOX = AU_MAIL_POP3_MBOX.AU_MAIL_POP3_MBOX) LEFT JOIN AU_MAIL_POP3
         ON AU_MAIL_POP3_MBOX.AU_MAIL_POP3 = AU_MAIL_POP3.AU_MAIL_POP3
         WHERE (((AU_MAIL_ADDR.MTYPE = 'TO')
                        OR (AU_MAIL_ADDR.MTYPE = 'FROM'))
         AND (AU_CONTACT_MAILADDR.AU_MAILADDRESS = AU_MAIL_ADDR.AU_MAILADDRESS)
         AND (AU_MAIL_POP3.POP3_USER = :M)
         AND (AU_DOC_REL.RELDATE=:D)
         AND ((AU_DOC_REL.REL_TABLE_NAME='AU_CONTACT')
                 OR (AU_DOC_REL.REL_TABLE_NAME='AU_BUSINESS')))
         end_sql
         q1 = QueryByName()
         call TSetParam(q1,"D",date)
         call TSetParam(q1,"M",mail)
         call TExecute(q1)
         count1 = TRecordCount(q1)
         call FreeEmbSQL(q1)
   call trace("count1=",count1, "mail=",mail)

         if (count1 > 0) then

         call bpm_setstepcomment(mail)
         call bpm_assign_job ( "Mail Attachments Characterization", uname, rname, 0, mail, date )

         endif

         call TNext(q)
        next
        call FreeEmbSQL(q)

   endwhen

   {.............................................................BOUNCED MAIL MANIPULATION}

   when ( _TraversingHour = 6 ) and ((_CurrentDate_Num > fired_date) or (fired_date = 0)) do

        date = crDate
        date = DateToNum(date)
        date = date-1         {..........characterize yesterdays attachments}
        date = NumToDate(date)
                                
        start_sql "*" "KOSMOS"
         SELECT POP3_USER, AU_USER, AU_POS FROM AU_MAIL_POP3
        end_sql
        q = QueryByName()
        call TExecute(q)
        count = TRecordCount(q)
        call TFirst(q)
        for i = 1 to count

         mail = TGetFld(q,"POP3_USER")
         uname = TGetFld(q,"AU_USER")
         uname = LookUpId("AU_USER",uname,"UNAME")
         rname = TGetFld(q,"AU_POS")
         rname = LookUpId("AU_POS",rname,"POS_D")

         start_sql "*" "KOSMOS"
                SELECT AU_MAILADDRESS_1.MADDRESS, AU_MAIL.MDATE, AU_MAIL_ADDR.MTYPE, AU_MAIL.AU_USER, AU_MAIL.READ_FLAG,
                AU_MAIL.IN_FLAG, AU_MAIL.OUT_FLAG, AU_MAIL.SUBJECT, AU_MAIL.MAIL_FROM, AU_BUSINESS.TITLE, AU_MAIL.AU_DOC,
                AU_MAIL.AU_MAIL_POP3_MBOX, AU_MAIL.MTIME, AU_MAIL.ATT_FLAG, AU_MAIL.SENDER_FLAG, AU_CONTACT.DISP_NAME,
                AU_MAIL.MSGID, AU_MAIL.AU_MAIL, AU_CONTACT_MAILADDR.ACTIVE_FLAG, AU_CONTACT_MAILADDR.AU_CONTACT_MAILADDR,
                AU_MAILBOUNCETYPE.AU_MAILBOUNCETYPE_D, AU_MAILADDRESS.MADDRESS
                FROM ((((AU_MAIL LEFT JOIN ((AU_CONTACT_MAILADDR LEFT JOIN AU_CONTACT
                ON AU_CONTACT_MAILADDR.AU_CONTACT = AU_CONTACT.AU_CONTACT)
                LEFT JOIN AU_BUSINESS ON AU_CONTACT_MAILADDR.AU_BUSINESS = AU_BUSINESS.AU_BUSINESS)
                ON AU_MAIL.BOUNCED_ADDR = AU_CONTACT_MAILADDR.AU_MAILADDRESS) LEFT JOIN AU_MAILBOUNCETYPE
                ON AU_MAIL.AU_MAILBOUNCETYPE = AU_MAILBOUNCETYPE.AU_MAILBOUNCETYPE) LEFT JOIN AU_MAILADDRESS
                ON AU_CONTACT_MAILADDR.AU_MAILADDRESS = AU_MAILADDRESS.AU_MAILADDRESS) LEFT JOIN AU_MAIL_ADDR
                ON AU_MAIL.AU_MAIL = AU_MAIL_ADDR.AU_MAIL)
                LEFT JOIN AU_MAILADDRESS AS AU_MAILADDRESS_1        
                ON AU_MAIL_ADDR.AU_MAILADDRESS = AU_MAILADDRESS_1.AU_MAILADDRESS
                WHERE ((AU_MAILADDRESS_1.MADDRESS=:M)
                AND (AU_MAIL.MDATE=:D) AND (AU_MAIL_ADDR.MTYPE='TO')
                AND (AU_MAIL.BOUNCED_FLAG='1'))
         end_sql
         q1 = QueryByName()
         call TSetParam(q1,"D",date)
         call TSetParam(q1,"M",mail)
         call TExecute(q1)
         count1 = TRecordCount(q1)
         call FreeEmbSQL(q1)
   call trace("count2=",count1, "mail=",mail)

         if (count1 > 0) then

         call bpm_setstepcomment(mail)
         call bpm_assign_job ( "Bounced Mail Manipulation", uname, rname, 0, mail, date )

         endif

         call TNext(q)
        next
        call FreeEmbSQL(q)

   endwhen

end_action