Sign in to follow this  
Followers 0
vrocco

Outlook Mail with third party plugin

34 posts in this topic

#1 ·  Posted (edited)

I am trying to send the contents of a text file to an email recipient using outlook. The only problem I am having is that my company uses a third party plugin that allows you to add a classification to the message before sending. I am trying to click-through that classification window so that it will send without any user interaction. However, it doesn't seem to identify the window that pops up. Can somebody help me with what I am doing wrong here. Included the relevant part of the code below:

$oOApp = ObjCreate("Outlook.Application")
$oOMail = $oOApp.CreateItem($olMailItem)
$oOMail.Save
With $oOMail
    .To = $address
    .Subject = $subject
    .BodyFormat = $olFormatHTML
    .Importance = $olImportanceNormal
    While 1
        $line = FileReadLine($file)
        If @error = -1 Then ExitLoop
        $lineFinal = $lineFinal & "<BR>" &$line
    WEnd
    FileClose($file)
    .HTMLBody = $lineFinal
    .Send
    Do
        Sleep(500)
    Until WinExists("Message Classification", "Select Classification")
    ControlClick("Message Classification", "Select Classification", 1)
EndWith
$oOApp = 0

WinMatchTitleMode is set to 2

Edited by vrocco

Share this post


Link to post
Share on other sites



no one?

Share this post


Link to post
Share on other sites

So everyone else is as stumped as I am?

Share this post


Link to post
Share on other sites

Did you use AutoIts Window Info Tool to check if the Window title, window text and ControlId are correct?

Where does your script hang? In the loop or when it tries to ControlClick? If you don't know insert a ConsoleWrite in the loop, before and after the ControlClick. Check the return value of ControlClick.

I separated the parts of your script: reading the file, creating the mail and waiting for the window to pop up

While 1
    $line = FileReadLine($file)
    If @error = -1 Then ExitLoop
    $lineFinal = $lineFinal & "<BR>" & $line
WEnd
FileClose($file)
$oOApp = ObjCreate("Outlook.Application")
$oOMail = $oOApp.CreateItem($olMailItem)
With $oOMail
    .Save
    .To = $address
    .Subject = $subject
    .BodyFormat = $olFormatHTML
    .Importance = $olImportanceNormal
    .HTMLBody = $lineFinal
    .Send
EndWith
Do
    ConsoleWrite("Sleep" & @CRLF)
    Sleep(500)
Until WinExists("Message Classification", "Select Classification")
ConsoleWrite("Before ControlClick" & @CRLF)
$iResult = ControlClick("Message Classification", "Select Classification", 1)
ConsoleWrite("After ControlClick. Result = " & $iResult & @CRLF)
$oOApp = 0

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

If it is a plug in you can disable it and then send the mail and then enable it.

Most likely you can set classification(what is that?) using the Outlook COM .

Share this post


Link to post
Share on other sites

Did you use AutoIts Window Info Tool to check if the Window title, window text and ControlId are correct?

Where does your script hang? In the loop or when it tries to ControlClick? If you don't know insert a ConsoleWrite in the loop, before and after the ControlClick. Check the return value of ControlClick.

I separated the parts of your script: reading the file, creating the mail and waiting for the window to pop up

I have never used ConsoleWrite before. How do I view the output? Do I need notepad or something open for it to write to? I tried to do something similar by placing a MsgBox after the WinExists function that just said "Got Window". It never gave me the message box, so I assume that is where it is stalling. I did check the AutoIt Info tool to make sure I had the window title and text set correctly and set the WinTitleMatch Mode to 2. Still no love.

If it is a plug in you can disable it and then send the mail and then enable it.

Most likely you can set classification(what is that?) using the Outlook COM .

This isn't an option because they are set by global policy. All machines are part of a domain, so as the local admin, I don't have the power to change this.

Share this post


Link to post
Share on other sites

ConsoleWrite in the SciTE environment does the same as MsgBox for compiled scripts. As you never get to the MsgBox either the title or the text can not be found.

Could you please try

Until WinExists("Message Classification")
so we can check where the problem is?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

ConsoleWrite in the SciTE environment does the same as MsgBox for compiled scripts. As you never get to the MsgBox either the title or the text can not be found.

Could you please try

Until WinExists("Message Classification")
so we can check where the problem is?

Still no MsgBox when doing it this way. I was looking at the Au3Info window and this window seems to have a different class than just the normal explorer windows. Would it be possible to use WinTitleMatchMode 4 with the classname to find it?

I have never done that either. How would I format that?

Share this post


Link to post
Share on other sites

Incidentally, here is the Au3Info. Am I missing something?

Press CTRL-ALT-F to freeze the display.

>>>>>>>>>>>> Window Details <<<<<<<<<<<<<
Title:  Message Classification - PAROCCOVS11 MAC Address
Class:  #32770
Size:   X: 432    Y: 240    W: 417    H: 167

>>>>>>>>>>> Mouse Details <<<<<<<<<<<
Screen: X: 557  Y: 254
Cursor ID:  2

>>>>>>>>>>> Pixel Color Under Mouse <<<<<<<<<<<
RGB:    Hex: 0x3997DD   Dec: 3774429

>>>>>>>>>>> Control Under Mouse <<<<<<<<<<<
Size:
Control ID:
ClassNameNN:
Text:

>>>>>>>>>>> Status Bar Text <<<<<<<<<<<


>>>>>>>>>>> Visible Window Text <<<<<<<<<<<
Select Classification Level(s)...
Classification
UNCLASSIFIED
Caveats
OK
Cancel

>>>>>>>>>>> Hidden Window Text <<<<<<<<<<<
>>
<<
&Help
Verify Recipients

Share this post


Link to post
Share on other sites

For the Advanced Window Descriptions to work you don't have to set the WinTitleMatchMode (according to the help file).

Just use:

WinWaitActive("[CLASS:#32770]")

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

For the Advanced Window Descriptions to work you don't have to set the WinTitleMatchMode (according to the help file).

Just use:

WinWaitActive("[CLASS:#32770]")

That didn't do anything. However, here is something weird. When I did set the WinTitleMatchMode to 4 and used this:

Do
    Sleep(500)
Until WinExists("classname=#32770")
MsgBox(0, "Got it", "Got window")

It did nothing while the window was visible, but when I manually clicked the cancel button on the window, then the msgbox popped up. So somehow it exited that loop when I cancelled which it wasn't doing before.

Share this post


Link to post
Share on other sites

Another try. Replace the loop

Do
    Sleep(500)
Until WinExists("[CLASS:#32770]")
MsgBox(0, "Got it", "Got window")
with

WinWait("[CLASS:#32770]")
MsgBox(0, "Got it", "Got window")
WinActivate("[CLASS:#32770]")

Make sure to write CLASS in upper case - as the examples in the help file do.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

I searched the forum and found this one.

So this class seems to be very common and therefore the code should describe the window as good as possible:

WinWait("[CLASS:#32770]","Select Classification Level(s)")
MsgBox(0, "Got it", "Got window")
WinActivate("[CLASS:#32770]","Select Classification Level(s)")

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

OK it does the same thing as before. Nothing until I hit the cancel button on the popup window and then I get the msgbox. Man this is frustrating.

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

Could you run this little code snippet when your Classification Window is active and post the results?

#include <array.au3>
$avWinList = WinList("[Class:#32770]") 
_ArrayDisplay($avWinList, "#32770")
Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

I searched the forum and found this one.

So this class seems to be very common and therefore the code should describe the window as good as possible:

WinWait("[CLASS:#32770]","Select Classification Level(s)")
MsgBox(0, "Got it", "Got window")
WinActivate("[CLASS:#32770]","Select Classification Level(s)")

This one doesn't even give me the msgbox when I hit cancel

Share this post


Link to post
Share on other sites

Could you run this little code snippet when your Classification Window is active and post the results?

#include <array.au3>
$avWinList = WinList("[Class:#32770]") 
_ArrayDisplay($avWinList, "#32770")

[0]|8|
[1]|On-Access Scan Messages|0x00010210
[2]|Message Classification - PAROCCOVS11 MAC Address|0x00040814
[3]|2 Reminders|0x0003051A
[4]|Outlook Send/Receive Progress|0x00090336
[5]|McAfee AutoUpdate|0x000102E6
[6]|McAfee Agent Monitor|0x000102C4
[7]|On-Access Scan Statistics|0x0001022E
[8]|Odtray Window|0x000201A8

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

[0]|8|
[1]|On-Access Scan Messages|0x00010210
[2]|Message Classification - PAROCCOVS11 MAC Address|0x00040814
[3]|2 Reminders|0x0003051A
[4]|Outlook Send/Receive Progress|0x00090336
[5]|McAfee AutoUpdate|0x000102E6
[6]|McAfee Agent Monitor|0x000102C4
[7]|On-Access Scan Statistics|0x0001022E
[8]|Odtray Window|0x000201A8

As you can see the entry number [2] is what you need.

What do you get when you just run

#include <array.au3>
Opt("WinTitleMatchMode", 2) 
$avWinList = WinList("Classification")
_ArrayDisplay($avWinList, "Classification")
Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

[0]|1|
[1]|Message Classification - PAROCCOVS11 MAC Address|0x001A0D20

Share this post


Link to post
Share on other sites

#20 ·  Posted (edited)

OK, another try:

#include <array.au3>
Opt("WinTitleMatchMode", 2) 
$avWinList = WinList("Message Classification")
_ArrayDisplay($avWinList, "Message Classification")

If you don't get a result with this try then we know that there is no space betwenn "Message" and "Classification" in the window title.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
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
Sign in to follow this  
Followers 0