Jump to content

Open Outlook Custom Form (OFT) and read


Recommended Posts

WOW!!! you really are something!! It work!!

Now need to figure out how to check whether the address is label or textbox and execute the command depend on the type.

Then skip the "State: " and only capture the value after that which the character can increase depend on the address. (I think I will go with StringStripWS + StringSplit , ":")

Really need to know how to check whether the textbox/label exist in the form. :blink:

i think it something like this

I try with this code but got error since "= Nothing" is wrong syntax for Autoit

$Findlabel = $oNewItem.GetInspector.ModifiedFormPages("Message").Controls("Label5")
            If NOT $Findlabel = Nothing Then
                MsgBox(0, "", "Got Label!")
            Else
                MsgBox(0, "", "No Label!")
            Endif
Edited by myteam
Link to comment
Share on other sites

This code snippet should handle the problem with non existing controls:

Global $oMyError = ObjEvent("AutoIt.Error", "_MyErrorHandler") ; Install a custom error handler
Global $iCOMError = 0

$oOutlook = ObjCreate("Outlook.Application")
$oNewItem = $oOutlook.CreateItemFromTemplate("H:\tools\AutoIt3\SADMG\SADMG AID Project\SADMG.oft")
$sLabelCaption = $oNewItem.GetInspector.ModifiedFormPages("Message" ).Controls("Label28" ).caption
If $iCOMError = 1 Then
    MsgBox(0,"","Element could not be found")
Else
    MsgBox(0,"","Element was found")
EndIf

Func _MyErrorHandler()

    $iCOMError = 0
    Local $bHexNumber = Hex($oMyError.number, 8)
    Local $sError = "COM Error Encountered in " & @ScriptName & @CRLF & _
            "Scriptline = " & $oMyError.scriptline & @CRLF & _
            "NumberHex = " & $bHexNumber & @CRLF & _
            "Number = " & $oMyError.number & @CRLF & _
            "WinDescription = " & StringStripWS($oMyError.WinDescription, 2) & @CRLF & _
            "Description = " & StringStripWS($oMyError.description, 2) & @CRLF & _
            "Source = " & $oMyError.Source & @CRLF & _
            "HelpFile = " & $oMyError.HelpFile & @CRLF & _
            "HelpContext = " & $oMyError.HelpContext & @CRLF & _
            "LastDllError = " & $oMyError.LastDllError
    Switch $bHexNumber
        Case "80020009"
            $iCOMError = 1
        Case Else
            MsgBox(262144, "My COM Error handler", $sError)
    EndSwitch

EndFunc ;==>_MyErrorHandler

If a control does not exist error "80020009" is raised. All COM errors are handled function _MyErrorHandler. For error "80020009" the error handler sets the variable $iCOMError = 1 and returns to the calling script line. You now can check for the absence of a control.

All other COM errors are displayed in a MSGBox.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Or even better:

$oOutlook = ObjCreate("Outlook.Application")
$oNewItem = $oOutlook.CreateItemFromTemplate("H:\tools\AutoIt3\SADMG\SADMG AID Project\SADMG.oft")
$oControl = $oNewItem.GetInspector.ModifiedFormPages("Message").Controls("Label28")
If IsObj($oControl) Then
    MsgBox(0,"","Exists. Caption is " & $oControl.caption) 
Else
    MsgBox(0,"","Does not exist")
EndIf

Based on this Newsgroup.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

$oControl = $oNewItem.GetInspector.ModifiedFormPages("Message").Controls("Label28")

Nope, it not working since the program will crash in this line because it point to non-existence control.

By the way, I seem to have problem with stringsplit.

If the code is like this:

$aMail = StringSplit("water@google.com;myteam@yahoo.com",";")

I can have the result to show = water@google.com

But, sometimes there is only 1 email without the ";". That's when my script crash.

Example:

$aMail = StringSplit("water@google.com",";")
= CRASH ;)

How can I check if the email contain ";"?

Do I need to use Autoit error handling just like checking the label?

p/s: I feel bad using error handling to make my buggy script work :blink:

Edited by myteam
Link to comment
Share on other sites

Nope, it not working since the program will crash in this line because it point to non-existence control.

You are right. You need the Errorhandler stuff to check for the existance of a control.

By the way, I seem to have problem with stringsplit.

Stringsplit, like any other AutoIt function, sets @error in case of a problem.

So please check the helpfile and you'll find a returncode for "no ; in the string". In this case simply use the original string as mail address.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

@error trick work!! Thank you very much Water!!

I'm planning to do next automation project later using excel as the source after

finish fixing up all the bug in my script. Hope you will be there!!

Autoit is awesome!!!

p/s: You maybe not Outlook Guru but you are Master! :blink:

Link to comment
Share on other sites

I'm planning to do next automation project later using excel as the source after

finish fixing up all the bug in my script. Hope you will be there!!

Excel is quite easy. You can use the builtin Excel UDF or - if you need more functions - use the ExcelCOM UDF or code everything yourself.

p/s: You maybe not Outlook Guru but you are Master! :blink:

Thanks! I'm glad it works!

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

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