Jump to content

outlook script help


 Share

Recommended Posts

Hi,

I'm in the process of writing a script that searches for an email via an identifier (Request ID), once the email is found, the email needs to be activated.

The request ID is also used to indicate the line on which it was found within the email. I need this line to give me some more information (a date delimited by "/"). I have some sample code that works with notepad with text inserted, however, when I try using this on outlook, i get an error stating:

Dim $line[$linecount]

Dim $line[^

Error: Array variable subscript badly formatted

So my assumption is I am not selecting the correct control or could use some improvement on the code itself. (I have adapted this code from someone else's). All I require is for it to be able to read the body of an email.

Thanks in advance

The following works with text in notepad:

#include <GUIConstants.au3>
#include <GUIedit.au3>
Opt("WinTitleMatchMode", 4); Allow ClassName lookup

Dim $LineCount
Dim $LineNum
Dim $Ret
Dim $LineLen
Dim $FirstCharPos
Dim $Buffer
dim $reqid
dim $test

$reqid = 600319372

Const $Applhandle = WinGetHandle("classname=Notepad")
Const $Ctrlhandle = ControlGetHandle("","",15)

WinWaitActive($Applhandle)
    sleep(500)
    WinHandle()
    CtrlRead($Ctrlhandle)

Func CtrlRead($Ctrlhandle); tested = OK
    $LineCount = _GUICtrlEditGetLineCount($Ctrlhandle)
    MsgBox(0, "Test", "Line #" & " " & $LineCount)
    Dim $line[$LineCount]
    For $LineNum = 0 To $LineCount - 1
        $Ret = DllCall("user32.dll", "int", "SendMessage", "hwnd", $Ctrlhandle, "int", $EM_GETLINE, "int", $LineNum, "str", "")
        MsgBox(0, "Test", "Text is =" & " " & $Ret[4])
        $line[$LineNum] = $ret[4]
        if stringinstr($line[$LineNum], $reqid) Then
            MsgBox(0, "Test", "YOU FOUND THE REQUEST ID")
            $test = StringSplit($line[$LineNum], "/", 1)
        EndIf
    Next
    $timeslot = StringSplit($test[3], " ", 1)
    $date = StringRight($test[1], 2) & "/" & $test[2] & "/" & StringLeft($test[3], 4) & " " & $timeslot[2]
    MsgBox(0, "asdasd", $Date)
    
EndFunc;==>CtrlRead
Link to comment
Share on other sites

I assume you've found $LineCount to be -1 correct? This is the source of your array subscript error.

_GUICtrlEditGetLineCount returns -1 when the control being passed to it is not an "Edit" control.

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

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...