VB Code to Click Yes Outlook Security

B

Bob

I noticed there are messages to deal with the Outlook Security message to
Click Yes when automating sending a mail message. This will occur using the
SendMail command in VBA.

This is a work around only. I do not have access to change or want to even
mess with changing Exchange Server settings. I have several Excel 2000
workbooks that do routing and this security message is a real nusiance. I
just put this code together and have not fully applied it.

I did a bit of code and got something to work. It still needs more work but
it does work. What I have done is compile an exe from VB6 and then launch
it from my VBA Excel project. The app runs for approx. five minutes and
then closes. That may be too long or too short depending on your code and
how many prompts you get.

I would like some reposting of anyone having something better or improving
this code.

As normal use at own risk. I don't think you will have a problem though.

Thanks,
Bob
========================================
----------------------------------------------------------------------------
--
Excel VBA used for testing:
'***********************************
'Excel file and compiled Exe are in same folder.
'***********************************
'For the shell command to work I had to change to the dir. Not sure why.
'This code for Excel VBA.

ChDir ActiveWorkbook.path

'start my vb app giving the name I used when compiling.
RetVal = Shell("RunOutlookPrompt.exe",1)

ActiveWorkBook.SendMail Recipients:="Smith, Bob"

----------------------------------------------------------------------------
--
'Use this Code in VB6 project.
'This code requires a reference to:
'Microsoft WMI Scripting
'Form1
'Timer1 added to the form with 3000 as the interval you can change.

'use for pausing sleep [number]
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Public mCounter As Long 'counter used to close app after 5 or so minutes

Private Sub Form_Load()
Form1.Visible = False

'don't run twice
'Kill Timer and unload
If App.PrevInstance = True Then
Form1.Timer1.Interval = 0
Form1.Timer1.Enabled = False
Unload Me
End If

End Sub

Private Sub Timer1_Timer()
'Below are pauses before sending keys.
'Depending on your PC speed etc. you may need to alter
'the time of the pause.
'The key pause is the first one that detects the Microsoft Outlook
caption.
'There is a progress bar that runs so timing is real important at
this point.

'add to counter declared as a Public varible.
mCounter = mCounter + 1

'Checking for 100 with 3sec loop ends up around 5 minutes.
If mCounter = 100 Then
'Use this line for testing.
'MsgBox "unloading Outlook Checker"
Unload Me 'close the app
End If

DoEvents

Set wshshell = CreateObject("WScript.Shell")

'Wait until the application has loaded - Check every number of seconds
set on Timer1.
'I am using 3000 for my interval.

While wshshell.AppActivate("Microsoft Outlook") = False
Exit Sub 'exit without running code.
Wend

DoEvents

'found the caption now wait for the Yes key to
'appear.
Sleep 5000 'try pause that works for you if 5 isn't long enough.

DoEvents

'Bring the application to the foreground
wshshell.AppActivate "Microsoft Outlook"
Sleep 200

'Send a Left Arrow key to move to Yes Button
wshshell.SendKeys "{Left}"
Sleep 200

'Bring the application to the foreground
wshshell.AppActivate "Microsoft Outlook"
Sleep 200

'Send key to press Enter Key to continue with sending message.
wshshell.SendKeys "{ENTER}"
Sleep 200

End Sub
 
R

Ron de Bruin

Hi Bob

http://www.rondebruin.nl/sendmail.htm#Prevent

You can use CDO if you want
http://www.rondebruin.nl/cdo.htm

Have fun

--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)




Bob said:
I noticed there are messages to deal with the Outlook Security message to
Click Yes when automating sending a mail message. This will occur using the
SendMail command in VBA.

This is a work around only. I do not have access to change or want to even
mess with changing Exchange Server settings. I have several Excel 2000
workbooks that do routing and this security message is a real nusiance. I
just put this code together and have not fully applied it.

I did a bit of code and got something to work. It still needs more work but
it does work. What I have done is compile an exe from VB6 and then launch
it from my VBA Excel project. The app runs for approx. five minutes and
then closes. That may be too long or too short depending on your code and
how many prompts you get.

I would like some reposting of anyone having something better or improving
this code.

As normal use at own risk. I don't think you will have a problem though.

Thanks,
Bob
========================================
----------------------------------------------------------------------------
--
Excel VBA used for testing:
'***********************************
'Excel file and compiled Exe are in same folder.
'***********************************
'For the shell command to work I had to change to the dir. Not sure why.
'This code for Excel VBA.

ChDir ActiveWorkbook.path

'start my vb app giving the name I used when compiling.
RetVal = Shell("RunOutlookPrompt.exe",1)

ActiveWorkBook.SendMail Recipients:="Smith, Bob"

----------------------------------------------------------------------------
--
'Use this Code in VB6 project.
'This code requires a reference to:
'Microsoft WMI Scripting
'Form1
'Timer1 added to the form with 3000 as the interval you can change.

'use for pausing sleep [number]
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Public mCounter As Long 'counter used to close app after 5 or so minutes

Private Sub Form_Load()
Form1.Visible = False

'don't run twice
'Kill Timer and unload
If App.PrevInstance = True Then
Form1.Timer1.Interval = 0
Form1.Timer1.Enabled = False
Unload Me
End If

End Sub

Private Sub Timer1_Timer()
'Below are pauses before sending keys.
'Depending on your PC speed etc. you may need to alter
'the time of the pause.
'The key pause is the first one that detects the Microsoft Outlook
caption.
'There is a progress bar that runs so timing is real important at
this point.

'add to counter declared as a Public varible.
mCounter = mCounter + 1

'Checking for 100 with 3sec loop ends up around 5 minutes.
If mCounter = 100 Then
'Use this line for testing.
'MsgBox "unloading Outlook Checker"
Unload Me 'close the app
End If

DoEvents

Set wshshell = CreateObject("WScript.Shell")

'Wait until the application has loaded - Check every number of seconds
set on Timer1.
'I am using 3000 for my interval.

While wshshell.AppActivate("Microsoft Outlook") = False
Exit Sub 'exit without running code.
Wend

DoEvents

'found the caption now wait for the Yes key to
'appear.
Sleep 5000 'try pause that works for you if 5 isn't long enough.

DoEvents

'Bring the application to the foreground
wshshell.AppActivate "Microsoft Outlook"
Sleep 200

'Send a Left Arrow key to move to Yes Button
wshshell.SendKeys "{Left}"
Sleep 200

'Bring the application to the foreground
wshshell.AppActivate "Microsoft Outlook"
Sleep 200

'Send key to press Enter Key to continue with sending message.
wshshell.SendKeys "{ENTER}"
Sleep 200

End Sub
 
B

Bob

Ron,

I am using CDO for a automated mailing of a report. In my case we have
three exchange servers on our WAN. The one that is configured for CDO to
work is in Atlanta.

This also requires that you give a full address ex. (e-mail address removed)

With our local exchange server and Outlook I can give in Excel VBA SendMail
Jones, Jim. This also cuts traffic going to our internet exchange server
and messages are within our local network. Maybe not a big deal but may
cause an impact on our Internet gateway messaging.

I am also using the built in feature to route messages to a list of users.
That is all run under Excel. I did mention that I could try to rewrite and
use CDO but that was shot down.

Thanks,
Bob

Ron de Bruin said:
Hi Bob

http://www.rondebruin.nl/sendmail.htm#Prevent

You can use CDO if you want
http://www.rondebruin.nl/cdo.htm

Have fun

--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)




I noticed there are messages to deal with the Outlook Security message to
Click Yes when automating sending a mail message. This will occur using the
SendMail command in VBA.

This is a work around only. I do not have access to change or want to even
mess with changing Exchange Server settings. I have several Excel 2000
workbooks that do routing and this security message is a real nusiance. I
just put this code together and have not fully applied it.

I did a bit of code and got something to work. It still needs more work but
it does work. What I have done is compile an exe from VB6 and then launch
it from my VBA Excel project. The app runs for approx. five minutes and
then closes. That may be too long or too short depending on your code and
how many prompts you get.

I would like some reposting of anyone having something better or improving
this code.

As normal use at own risk. I don't think you will have a problem though.

Thanks,
Bob
========================================
--------------------------------------------------------------------------
--
--
Excel VBA used for testing:
'***********************************
'Excel file and compiled Exe are in same folder.
'***********************************
'For the shell command to work I had to change to the dir. Not sure why.
'This code for Excel VBA.

ChDir ActiveWorkbook.path

'start my vb app giving the name I used when compiling.
RetVal = Shell("RunOutlookPrompt.exe",1)

ActiveWorkBook.SendMail Recipients:="Smith, Bob"

--------------------------------------------------------------------------
--
--
'Use this Code in VB6 project.
'This code requires a reference to:
'Microsoft WMI Scripting
'Form1
'Timer1 added to the form with 3000 as the interval you can change.

'use for pausing sleep [number]
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Public mCounter As Long 'counter used to close app after 5 or so minutes

Private Sub Form_Load()
Form1.Visible = False

'don't run twice
'Kill Timer and unload
If App.PrevInstance = True Then
Form1.Timer1.Interval = 0
Form1.Timer1.Enabled = False
Unload Me
End If

End Sub

Private Sub Timer1_Timer()
'Below are pauses before sending keys.
'Depending on your PC speed etc. you may need to alter
'the time of the pause.
'The key pause is the first one that detects the Microsoft Outlook
caption.
'There is a progress bar that runs so timing is real important at
this point.

'add to counter declared as a Public varible.
mCounter = mCounter + 1

'Checking for 100 with 3sec loop ends up around 5 minutes.
If mCounter = 100 Then
'Use this line for testing.
'MsgBox "unloading Outlook Checker"
Unload Me 'close the app
End If

DoEvents

Set wshshell = CreateObject("WScript.Shell")

'Wait until the application has loaded - Check every number of seconds
set on Timer1.
'I am using 3000 for my interval.

While wshshell.AppActivate("Microsoft Outlook") = False
Exit Sub 'exit without running code.
Wend

DoEvents

'found the caption now wait for the Yes key to
'appear.
Sleep 5000 'try pause that works for you if 5 isn't long enough.

DoEvents

'Bring the application to the foreground
wshshell.AppActivate "Microsoft Outlook"
Sleep 200

'Send a Left Arrow key to move to Yes Button
wshshell.SendKeys "{Left}"
Sleep 200

'Bring the application to the foreground
wshshell.AppActivate "Microsoft Outlook"
Sleep 200

'Send key to press Enter Key to continue with sending message.
wshshell.SendKeys "{ENTER}"
Sleep 200

End Sub
 
R

Ron de Bruin

Hi Bob

You Run Office 2000 I read

If you use only SR1 you don't have a problem with Security.
Is this not a option for you ?


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)




Bob said:
Ron,

I am using CDO for a automated mailing of a report. In my case we have
three exchange servers on our WAN. The one that is configured for CDO to
work is in Atlanta.

This also requires that you give a full address ex. (e-mail address removed)

With our local exchange server and Outlook I can give in Excel VBA SendMail
Jones, Jim. This also cuts traffic going to our internet exchange server
and messages are within our local network. Maybe not a big deal but may
cause an impact on our Internet gateway messaging.

I am also using the built in feature to route messages to a list of users.
That is all run under Excel. I did mention that I could try to rewrite and
use CDO but that was shot down.

Thanks,
Bob

Ron de Bruin said:
Hi Bob

http://www.rondebruin.nl/sendmail.htm#Prevent

You can use CDO if you want
http://www.rondebruin.nl/cdo.htm

Have fun

--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)




I noticed there are messages to deal with the Outlook Security message to
Click Yes when automating sending a mail message. This will occur using the
SendMail command in VBA.

This is a work around only. I do not have access to change or want to even
mess with changing Exchange Server settings. I have several Excel 2000
workbooks that do routing and this security message is a real nusiance. I
just put this code together and have not fully applied it.

I did a bit of code and got something to work. It still needs more work but
it does work. What I have done is compile an exe from VB6 and then launch
it from my VBA Excel project. The app runs for approx. five minutes and
then closes. That may be too long or too short depending on your code and
how many prompts you get.

I would like some reposting of anyone having something better or improving
this code.

As normal use at own risk. I don't think you will have a problem though.

Thanks,
Bob
========================================
--------------------------------------------------------------------------
--
--
Excel VBA used for testing:
'***********************************
'Excel file and compiled Exe are in same folder.
'***********************************
'For the shell command to work I had to change to the dir. Not sure why.
'This code for Excel VBA.

ChDir ActiveWorkbook.path

'start my vb app giving the name I used when compiling.
RetVal = Shell("RunOutlookPrompt.exe",1)

ActiveWorkBook.SendMail Recipients:="Smith, Bob"

--------------------------------------------------------------------------
--
--
'Use this Code in VB6 project.
'This code requires a reference to:
'Microsoft WMI Scripting
'Form1
'Timer1 added to the form with 3000 as the interval you can change.

'use for pausing sleep [number]
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Public mCounter As Long 'counter used to close app after 5 or so minutes

Private Sub Form_Load()
Form1.Visible = False

'don't run twice
'Kill Timer and unload
If App.PrevInstance = True Then
Form1.Timer1.Interval = 0
Form1.Timer1.Enabled = False
Unload Me
End If

End Sub

Private Sub Timer1_Timer()
'Below are pauses before sending keys.
'Depending on your PC speed etc. you may need to alter
'the time of the pause.
'The key pause is the first one that detects the Microsoft Outlook
caption.
'There is a progress bar that runs so timing is real important at
this point.

'add to counter declared as a Public varible.
mCounter = mCounter + 1

'Checking for 100 with 3sec loop ends up around 5 minutes.
If mCounter = 100 Then
'Use this line for testing.
'MsgBox "unloading Outlook Checker"
Unload Me 'close the app
End If

DoEvents

Set wshshell = CreateObject("WScript.Shell")

'Wait until the application has loaded - Check every number of seconds
set on Timer1.
'I am using 3000 for my interval.

While wshshell.AppActivate("Microsoft Outlook") = False
Exit Sub 'exit without running code.
Wend

DoEvents

'found the caption now wait for the Yes key to
'appear.
Sleep 5000 'try pause that works for you if 5 isn't long enough.

DoEvents

'Bring the application to the foreground
wshshell.AppActivate "Microsoft Outlook"
Sleep 200

'Send a Left Arrow key to move to Yes Button
wshshell.SendKeys "{Left}"
Sleep 200

'Bring the application to the foreground
wshshell.AppActivate "Microsoft Outlook"
Sleep 200

'Send key to press Enter Key to continue with sending message.
wshshell.SendKeys "{ENTER}"
Sleep 200

End Sub
 
B

Bob

Ron,

We have a mix of Office 2000 with and without SR2. We where instructed to
run the security patch a while back so a lot of the new installs have SR2.

I am running Office XP with Windows XP Pro on my PC. Yesterday I did a test
with a routing slip stepping through the code when routing is started.

Gives a prompt for every person in the .Reciepients List and then the prompt
with a progress bar at the .Route line. There are five e-mail accounts
given for the routing slip so that is a total of at least (6) prompts.
Really annoying.

Thanks,
Bob

Ron de Bruin said:
Hi Bob

You Run Office 2000 I read

If you use only SR1 you don't have a problem with Security.
Is this not a option for you ?


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)




Ron,

I am using CDO for a automated mailing of a report. In my case we have
three exchange servers on our WAN. The one that is configured for CDO to
work is in Atlanta.

This also requires that you give a full address ex. (e-mail address removed)

With our local exchange server and Outlook I can give in Excel VBA SendMail
Jones, Jim. This also cuts traffic going to our internet exchange server
and messages are within our local network. Maybe not a big deal but may
cause an impact on our Internet gateway messaging.

I am also using the built in feature to route messages to a list of users.
That is all run under Excel. I did mention that I could try to rewrite and
use CDO but that was shot down.

Thanks,
Bob

Ron de Bruin said:
Hi Bob

http://www.rondebruin.nl/sendmail.htm#Prevent

You can use CDO if you want
http://www.rondebruin.nl/cdo.htm

Have fun

--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)




I noticed there are messages to deal with the Outlook Security
message
to
Click Yes when automating sending a mail message. This will occur
using
the
SendMail command in VBA.

This is a work around only. I do not have access to change or want
to
even
mess with changing Exchange Server settings. I have several Excel 2000
workbooks that do routing and this security message is a real
nusiance.
I
just put this code together and have not fully applied it.

I did a bit of code and got something to work. It still needs more
work
but
it does work. What I have done is compile an exe from VB6 and then launch
it from my VBA Excel project. The app runs for approx. five minutes and
then closes. That may be too long or too short depending on your
code
and
how many prompts you get.

I would like some reposting of anyone having something better or improving
this code.

As normal use at own risk. I don't think you will have a problem though.
--------------------------------------------------------------------------
--
--
Excel VBA used for testing:
'***********************************
'Excel file and compiled Exe are in same folder.
'***********************************
'For the shell command to work I had to change to the dir. Not sure why.
'This code for Excel VBA.

ChDir ActiveWorkbook.path

'start my vb app giving the name I used when compiling.
RetVal = Shell("RunOutlookPrompt.exe",1)

ActiveWorkBook.SendMail Recipients:="Smith, Bob"
--------------------------------------------------------------------------
--
--
'Use this Code in VB6 project.
'This code requires a reference to:
'Microsoft WMI Scripting
'Form1
'Timer1 added to the form with 3000 as the interval you can change.

'use for pausing sleep [number]
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Public mCounter As Long 'counter used to close app after 5 or so minutes

Private Sub Form_Load()
Form1.Visible = False

'don't run twice
'Kill Timer and unload
If App.PrevInstance = True Then
Form1.Timer1.Interval = 0
Form1.Timer1.Enabled = False
Unload Me
End If

End Sub

Private Sub Timer1_Timer()
'Below are pauses before sending keys.
'Depending on your PC speed etc. you may need to alter
'the time of the pause.
'The key pause is the first one that detects the Microsoft Outlook
caption.
'There is a progress bar that runs so timing is real
important
at
this point.

'add to counter declared as a Public varible.
mCounter = mCounter + 1

'Checking for 100 with 3sec loop ends up around 5 minutes.
If mCounter = 100 Then
'Use this line for testing.
'MsgBox "unloading Outlook Checker"
Unload Me 'close the app
End If

DoEvents

Set wshshell = CreateObject("WScript.Shell")

'Wait until the application has loaded - Check every number of seconds
set on Timer1.
'I am using 3000 for my interval.

While wshshell.AppActivate("Microsoft Outlook") = False
Exit Sub 'exit without running code.
Wend

DoEvents

'found the caption now wait for the Yes key to
'appear.
Sleep 5000 'try pause that works for you if 5 isn't long enough.

DoEvents

'Bring the application to the foreground
wshshell.AppActivate "Microsoft Outlook"
Sleep 200

'Send a Left Arrow key to move to Yes Button
wshshell.SendKeys "{Left}"
Sleep 200

'Bring the application to the foreground
wshshell.AppActivate "Microsoft Outlook"
Sleep 200

'Send key to press Enter Key to continue with sending message.
wshshell.SendKeys "{ENTER}"
Sleep 200

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top