Jump to content

need help with changing script


Recommended Posts

Hi im new here and look for some advice with make program wich will open file and look in to the file excel or txt and search for expired time.

Then if expired time is <= 1 month from curent time program will automaticly send mail.

example of file: 

     A       B        C             D             E

text 1 | text 2 | tex3 | expired time | mail

I'm just find this:

Global $oExcel = _Excel_Open(False)

Global $oBook = _Excel_BookOpen($oExcel, $sWorkbook, True)

Global $aData = _Excel_RangeRead($oBook, Default, $oBook.ActiveSheet.Usedrange)

_Excel_Close($oExcel, False)

$oOutlook = _OL_Open()
For $i = 1 To UBound($aData, 1) - 1
    $sDate = StringLeft($aData[$i][13], 4) & "-" & StringMid($aData[$i][13], 5, 2) & "-" & StringMid($aData[$i][13], 7, 2) ; Format date to YYYY-MM-DD
    $sTemp = $sBody & "<p>" & '<html><body><style>table{width:100%;}td{border:1px solid;}</style>' & _
            '<table><tr bgcolor="#ffcc66"><td>' & $aData[0][1] & '</td><td>' & $aData[0][9] & '</td>' & _
            '<td>' & $aData[0][11] & '</td><td>' & $aData[0][13] & '</td><td>' & $aData[0][16] & '</td><td>' & $aData[0][17] & '</td><td>' & $aData[0][18] & '</td>' & _
            '<tr><td>' & $aData[$i][1] & '</td><td>' & $aData[$i][9] & '</td>' & _
            '<td>' & $aData[$i][11] & '</td><td>' & $sDate & '</td><td>' & $aData[$i][16] & '</td><td>' & $aData[$i][17] & '</td><td>' & $aData[$i][18] & '</td>' & _
            '</tr></table></body></html>' ; set the body to the static text from $sBody plus 5 cells from Excel
    _OL_Wrapper_SendMail($oOutlook, $aData[$i][9], $aData[$i][10], "", $aData[$i][1], $sTemp, "", $olFormatHTML)
Next
_OL_Close($oOutlook)
Exit

 

and try to change it to resolve mine problem.

If u have some time maybe help with this ...

Ty

Mariusz

Edited by KuanTi
Link to comment
Share on other sites

I am not able to test this, but you never compare the date to an expired range. I think you need to check that with an If/Then statement, and if it falls outside the lines, then use the wrapper to send the email. Right now it looks like you are sending out the email for every row?

 

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Link to comment
Share on other sites

You will need to do a date check to determine if the date is <= one month...maybe check if the month is different (up from one, up from two would be automatic), then once the month is one value higher, check the date, if it is a match or higher then send, if not then do not send.

 

 

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Link to comment
Share on other sites

Ty Guys for replay but need some advice. How to check DATE recorded  in file ??

i can compare dates using below script  but dont know how to check from file any help will close me to end ;)

#include <Date.au3>
#include <MsgBoxConstants.au3>
Local $time = "2015/05/15 00:00:00"
Local $time2 = "2015/07/28 00:00:00"
$iDateCalc = _DateDiff('M',$time,$time2)
MsgBox (4096,"",$iDateCalc)

Link to comment
Share on other sites

hmm how to compare _datedif in array ?

file a:

a,a,a,a,2015/05/15
a,a,a,a,2015/07/15
a,a,a,a,2015/09/15

file b:

2015/05/14

#include <Date.au3>
#include <MsgBoxConstants.au3>
#include <File.au3>
#include <Array.au3>

Local $time = "2015/05/15"
Local $time2 = "2015/07/28"

Global $aArray_1, $aArray_2
$sFile_1 = "c:\test\a.txt"
$sFile_2 = "c:\test\b.txt"

$iDateCalc = _DateDiff('M',$time,$time2)

_FileReadToArray($sFile_1, $aArray_1)
_FileReadToArray($sFile_2, $aArray_2)

;_ArrayDisplay($aArray_1)
;_ArrayDisplay($aArray_2)

Global $aArray_2D_1[$aArray_1[0] + 1][5], $aArray_2D_2[$aArray_2[0] + 1][1]

For $i = 1 To $aArray_1[0]
    $aSplit_1 = StringSplit($aArray_1[$i], ",", 2)
    $aSplit_2 = StringSplit($aArray_2[$i], ",", 2)
    For $j = 0 To 1
        $aArray_2D_1[$i][$j] = $aSplit_1[$j]
        $aArray_2D_2[$i][$j] = $aSplit_2[$j]
    Next
Next

For $i = 1 To UBound($aArray_2D_1) - 1
    If $aArray_2D_1[$i][4] < $aArray_2D_2[$i][4] Then
        ConsoleWrite($aArray_2D_1[$i][4] & " is less than " & $aArray_2D_2[$i][4] & @CRLF)
    Else
        ConsoleWrite($aArray_2D_1[$i][4] & " is greater than " & $aArray_2D_2[$i][4] & @CRLF)
    EndIf
 Next

MsgBox (4096,"",$iDateCalc)

Edited by KuanTi
Link to comment
Share on other sites

You pull the date from the array, and put in same formt as datediff or however you want to compare. 

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Link to comment
Share on other sites

Try this and check the help file, there are plenty of examples:

#include <Date.au3>
#include <array.au3>

$aTempDate = StringSplit('2015/05/10', '/', 2)

$iYear = $aTempDate[0]
$iMonth = $aTempDate[1]
$iDay = $aTempDate[2]
_ArrayDisplay($aTempDate)

Local $iDateCalc = _DateDiff('D', $iYear & '/' & $iMonth & '/' &$iDay & " 00:00:00", _NowCalc())
MsgBox(4096, "", "Number of Days since Update: " & $iDateCalc)

 

 

Edited by nitekram

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...