Login   /   Register

Clicking Outlook security popup

Rate this article
     2 votes, average: 5 out of 52 votes, average: 5 out of 52 votes, average: 5 out of 52 votes, average: 5 out of 52 votes, average: 5 out of 5
Loading ... Loading ...
March 28th, 2008 by Yaron Assa

If you ever trying sending a with Outlook via "the back door" (e.g. by VBScript), you’ve probably found yourself facing this message :

This can be annoying if you happen to be near the computer, and could turn into a complete disaster if you’re trying to send the email from a QTP script running solo. Because of the COM interface of the outlook objects, your script will hang until this pop-up is resolved. Which could throw a night worth of testing through the window.

So, how can we work around this problem?

One solution is to install a small yet effective program called ClickYes, which, surprisingly enough, clicks yes. Most of the time this turns out to be the perfect solution : simple, effective, and doesn’t require any new code.

However, is some cases, this is not unacceptable. Maybe you’re not allowed to install any custom software, maybe there’re deployment issues, or maybe you just feel like trying the hard way for a change. Well, there is an alternative!

This solution is based on the fact that while the main VBScript in QTP is stuck, VBScript running under another proccess will continue to run uninterrupted. This means that we could run an external VBS file, just before QTP executes the command that initiates the pop-up (this usually happens upon resolving the recipients or sending the message). This VBS will loop in the background, waiting for the Outlook window to appear, send the keystrokes that resolve it, and fade the way all proper scripts do.

This actually looks something like this (remember, this code goes in an external VBS file, NOT the QTP script):

Set fso = CreateObject("WScript.Shell")
 
While fso.AppActivate("Microsoft Outlook") = FALSE
  wscript.sleep 1000
Wend
 
fso.SendKeys "a", True
fso.SendKeys "y", True
 
wscript.sleep 7000
 
While fso.AppActivate ("Microsoft Outlook") = FALSE
  wscript.sleep 1000
Wend
 
fso.SendKeys "y", True

And in the QTP script, we just put this line before executing the popup-initiation command :

SystemUtil.Run "c:\windows\system32\wscript.exe", "c:\ExternalFile.vbs"

And all will be well. By running the VBS via windows script host (wscript.exe), and not the ExecuteFile command, we ensure that the VBScript will run under a different system process, which will not hang when the security pop-up appears.

As usual, this post also was written from an answer I gave at SQAForums.

Posted in MS Office, Outlook

6 Responses to “Clicking Outlook security popup”

  1. shelley Says:

    [-]

    i think this post is very useful

  2. naikaparna Says:

    [+]

    There is one more way around. Instead of using Outlook, CDO object can be used to send a email. Which doesn't popup any security w... ...

  3. Sending mail without a security popup | AdvancedQTP Says:

    [-]

    […] published a QTip regarding handling the Outlook Security Popup that shows whenever you try sending an E-Mail via […]

  4. JasonEly Says:

    [+]

    About 2 years ago I ran into a problem. I needed to check mail that came into a specific email box. I tried doing it via IBM lotus... ...

  5. JasonEly Says:

    [+]

    I forgot to mention... Before getting trigger happy and testing the above code, download the RDO library from the URL I specifi... ...

  6. Mohamed Ali Says:

    [+]

    that's GREAT!! that's Jason! I have used redemption before, but only to access the Address Book, but now i can use it for send/... ...

Leave a Reply

You must be logged in to post a comment.

This article was viewed 1024 times