Here are two bits of code. First the code to use the class, and then the
class code itself.
ClickYes has to be running. This code doesn't start it up, it just enables
it.
I set ClickYes to autostart, but to start Suspended (meaning disabled).
*** Code to use the class when you send mail
Dim oClickYes As OutlookClickYes
oClickYes.ClickYesStart
'Send your email
oClickYes.ClickYesStop
*** Copy this code into a new class module. I named mine OutlookClickYes.
Option Compare Database
Option Explicit
'Module variables
Private mlngWnd As Long 'Window handle for
ExpressClickYes
Private mlngMsgClickYesSuspendResume As Long 'Message Identifier to
send ExpressClickYes for resume/suspend
' Declare Windows' API functions
Private Declare Function RegisterWindowMessage _
Lib "user32" Alias "RegisterWindowMessageA" _
(ByVal lpString As String) As Long
Private Declare Function FindWindow Lib "user32" _
Alias "FindWindowA" (ByVal lpClassName As Any, _
ByVal lpWindowName As Any) As Long
Private Declare Function SendMessage Lib "user32" _
Alias "SendMessageA" (ByVal hWnd As Long, _
ByVal wMsg As Long, ByVal wParam As Long, _
lParam As Any) As Long
Private Sub Class_Initialize()
' Register a message to send
mlngMsgClickYesSuspendResume =
RegisterWindowMessage("CLICKYES_SUSPEND_RESUME")
' Find ClickYes Window by classname
mlngWnd = FindWindow("EXCLICKYES_WND", 0&)
End Sub
Public Function ClickYesStart() As Boolean
Dim Res As Long
'Send the message to Resume ClickYes
Res = SendMessage(mlngWnd, mlngMsgClickYesSuspendResume, 1, 0)
'Succeeded if we get here? Successful result code JUST comes from
testing. _
NOT VERY RELIABLE.
ClickYesStart = (Res = 0 Or Res = 1308434)
'Debug.Print "MsgID=" & mlngMsgClickYesSuspendResume & "; WindowHandle="
& mlngWnd & "; Result=" & Res
End Function
Public Function ClickYesStop() As Boolean
Dim Res As Long
'Send the message to Suspend ClickYes
Res = SendMessage(mlngWnd, mlngMsgClickYesSuspendResume, 0, 0)
'Succeeded if we get here? Successful result code JUST comes from
testing. _
NOT VERY RELIABLE.
ClickYesStop = (Res = 0 Or Res = 1308434)
End Function
ContextMagic makes a free utility to automate Outlook warning approval.
It's
worked great for my own use and at all my clients.
http://www.contextmagic.com/express-clickyes/
You set it to start automatically with Windows. I always set it up to
start
Disabled, meaning it's NOT helping. That keeps the Outlook "safety" system
in place. My code uses a single routine to send email. That routine
includes
code to automatically enable Express Click-Yes before creating the email,
and to disable it again after sending the email.
If you only send email once in a while, you might not want to bother with
this. When you get that warning message from Outlook, I think there's a
dropdown to tell it how long to allow programmatic access. If you set it
to
the max value and click OK, you should be able to easily send the 10
emails.
If you're considering upgrading to Office 2007 sometime soon, that also
solves the problem since the warning is automatically suppressed if you
have
up-to-date antivirus protection. I prefer that approach.
Thank you all for your responses. I was using Outlook in the beginning
but kept getting those pesky messages about "sending email on behalf".
Since I did not want a user to have to intervene with the sending of
these emails (to about 10 people), I decided to switch to CDO. I am
more than willing to switch back to Outlook if I can get rid of the
"send on your behalf" messages.
Any ideas?- Hide quoted text -
- Show quoted text -
I have been looking at the ClickYes and think it may work for me.
Are you able to send me the statements you use to enable clickyes and
disable clickyes?
Thank you so much!!!