K
Kristy
Thanks Dmitry, once I used the correct button id I could access those
properties as expected (I'm looking appropriately embarrassed!), and
loving Outlook Spy more by the minute!
I am still unsure of how to achieve what I want to though, can you
help?
I need to get the xy coordinates at my current location first, do I
need to use GetCursorPos API instead of GetCursor to do this?
GetCursor only returns one number between 0-65535 but I think I need 2
(both x and y)? What exaclty is GetCursor giving me?
Then I need to find the Send button and get it's coordinates, using
the below I am getting very small numbers (SendButtonTop = 33,
SendBtnLeft = 89 when it should be around about 1500, 7000) is this
something to do with reading pixels instead of characters?)
Set Btn = Application.ActiveInspector.CommandBars.FindControl(1, 2617)
SendBtnWidth = Btn.Width
SendBtnHeight = Btn.Height
SendBtnTop = Btn.Top + (SendBtnHeight / 2)
SendBtnLeft = Btn.Left + (SendBtnWidth / 2)
mouse_event MOUSEEVENTF_ABSOLUTE + MOUSEEVENTF_MOVE, SendButtonLeft,
SendButtonTop, 0, 0
mouse_event MOUSEEVENTF_ABSOLUTE + MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
mouse_event MOUSEEVENTF_ABSOLUTE + MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
mouse_event MOUSEEVENTF_ABSOLUTE + MOUSEEVENTF_MOVE, MouseCurrPos, 0,
0, 0
Thanks for your time
K
properties as expected (I'm looking appropriately embarrassed!), and
loving Outlook Spy more by the minute!
I am still unsure of how to achieve what I want to though, can you
help?
I need to get the xy coordinates at my current location first, do I
need to use GetCursorPos API instead of GetCursor to do this?
GetCursor only returns one number between 0-65535 but I think I need 2
(both x and y)? What exaclty is GetCursor giving me?
Then I need to find the Send button and get it's coordinates, using
the below I am getting very small numbers (SendButtonTop = 33,
SendBtnLeft = 89 when it should be around about 1500, 7000) is this
something to do with reading pixels instead of characters?)
Set Btn = Application.ActiveInspector.CommandBars.FindControl(1, 2617)
SendBtnWidth = Btn.Width
SendBtnHeight = Btn.Height
SendBtnTop = Btn.Top + (SendBtnHeight / 2)
SendBtnLeft = Btn.Left + (SendBtnWidth / 2)
mouse_event MOUSEEVENTF_ABSOLUTE + MOUSEEVENTF_MOVE, SendButtonLeft,
SendButtonTop, 0, 0
mouse_event MOUSEEVENTF_ABSOLUTE + MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
mouse_event MOUSEEVENTF_ABSOLUTE + MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
mouse_event MOUSEEVENTF_ABSOLUTE + MOUSEEVENTF_MOVE, MouseCurrPos, 0,
0, 0
Thanks for your time
K
Dmitry Streblechenko \(MVP\) said:What do you mean by "'cant seem to use the following in the inspector so not
sure how to
get position of the Send Button so that I can use it???"
Do you access these properties when the Inspector is still open?
BTW, the "Send" button id is 2617 - you can look it up using OutlookSpy:
click the Inspector button on the OutlookSpy toolbar in an Inspector, then
go to the CommandBars tab.
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
Kristy said:Hi Dmitry
Thanks for that, it was the reason for the ghost item in the Sent
folder however it doesn't seem to solve my send from Citrix session
issue.
I would like to try using the mouse_event option instead of closing
the item, getting it from ID etc etc if I can however I have already
tripped myself up... sigh :-(
This is what I would like to do...
Private Declare Function GetCursor Lib "user32" () As Long
Private Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long,
ByVal dx&, ByVal dy&, ByVal cbuttons&, ByVal dwExtraInfo&)
Private Const MOUSEEVENTF_ABSOLUTE = &H8000 'absolute move
Private Const MOUSEEVENTF_LEFTDOWN = &H2 'left button down
Private Const MOUSEEVENTF_LEFTUP = &H4 'left button up
Private Const MOUSEEVENTF_MOVE = &H1 'mouse move
Dim MouseCurrPos
Dim SendBtnTop
Dim SendBtnLeft
Dim SendBtnWidth
Dim SendBtnHeight
Then with the current sItem already open this is what I want to do,
but it fails for many reasons (see below)...
'Get current Mouse postion - should I be using GetCursorPos function
instead so that I can get x, y coordinates?
MouseCurrPos = GetCursor
'Find Out location of Send Button in inspector
Set Btn = Application.ActiveInspector.CommandBars.FindControl(1,
3037)
'cant seem to use the following in the inspector so not sure how to
get position of the Send Button so that I can use it???
SendBtnTop = Btn.Top
SendBtnLeft = Btn.Left
SendBtnWidth = Btn.Width
SendBtnHeight = Btn.Height
'Then move to centre of Send button using xy coordinates
mouse_event MOUSEEVENTF_ABSOLUTE Or MOUSEEVENTF_MOVE, SendBtnTop +
(SendBtnHeight / 2), SendBtnLeft + (SendBtnWidth / 2), 0, 0
'emulate a click
mouse_event MOUSEEVENTF_ABSOLUTE Or MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
mouse_event MOUSEEVENTF_ABSOLUTE Or MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
'move back to original position
mouse_event MOUSEEVENTF_ABSOLUTE Or MOUSEEVENTF_MOVE, MouseCurrPos, 0,
0, 0
OK, so it's a mess... I need help... please
Kristy
"Dmitry Streblechenko \(MVP\)" <[email protected]> wrote in messageWell, you are submitting a message that is referenced by an open inspector,
and that can lead to a disaster - MAPI will not be able to send and then
move the message since it is still referenced. Can you try to close the
inspector first?
Also since the inspector is still open, you can use mouse_event() Win API
function to simulate mouse cursor moving to the center of the Send button,
left button down, then up, then move back to the old position. Note that you
cannot use CommandBarButton.Execute - you will get a prompt.
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
Hi
OK, these are the bits you need I think, I've left out irrelevant bits
of code otherwise it would be too long! This Click event is called
from a button on my toolbar in an open inspector, therefore the HTML
email has already been created and recipients should have been typed
in by the user, any attachments etc added and now the user wants to
send the email and print off the sent item including an attachment
list... the item is tagged (code not included) and printing occurs
when the item reaches the SentItems folder.
This code works on my exchange server, it only appears not to work on
a citrix session when logged in as a user (not the user that loaded
the programme ie administrator, it will work for them). Everything
else works, I also have an option to print received items with
attachments and this works fine, it is the 'send' part that doesn't
work...
Private Sub cbbSendAndPrint_Click(ByVal Ctrl As
Office.CommandBarButton, CancelDefault As Boolean)
On Error GoTo ErrorHandler
Set objItem = golApp.ActiveInspector.CurrentItem
objItem.Subject = objItem.Subject
objItem.Save
Set sItem = CreateObject("Redemption.SafeMailItem")
sItem.item = objItem
With sItem
.Save
.Recipients.ResolveAll
.Send
End With
'next line not required with Exchange but left in as fail safe
utils.DeliverNow
'If delivernow won't work then as a last resort try simulting
send/receive click
'If Version < "11.0" Then 'Outlook XP or lower
' Set Btn = Application.ActiveExplorer.CommandBars.FindControl(1,
5488)
' Btn.Execute
'Else 'Outlook 2003
' 'Note that in Outlook 2003 that button is now a dropdown, the real
Send/Receive is a subitem of the button:
' Set Btn = Application.ActiveExplorer.CommandBars.FindControl(1,
7095)
' Btn.Execute
'End If
sItem.Close (olDiscard)
MacroExit:
On Error Resume Next
Set objItem = Nothing
Set golApp = Nothing
Set sItem = Nothing
Exit Sub
ErrorHandler:
'Display the description and number of the error.
MsgBox "Error: " & Err.Description & vbCrLf & "Error # " _
& Err.Number
Err.Clear
'Exit the macro.
GoTo MacroExit
End Sub
"Dmitry Streblechenko \(MVP\)" <[email protected]> wrote in messageallHmmm... I am pretty much out of ideas. Would it work if you leave
thepostRedemption code intact but comment out SafeMailItem.Send? Can you
themessagecode that creates SafeMailItem, adds recipients and calls Send?
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
Thanks Sue
I have taken the 'simulated click' code out of the application since
the original message didn't get sent anyway, but will put the old
version back on when I get a chance to see what it says... the ghost
message was just a blank email, the actual email was still in drafts,
I'll check that one too to see if it sheds any light on the situation.
Any other ideas Dmitry??? Or am I too accept that I cannot
programmatically send (and flush) mailitems using Exchange and
Redemption when using a Citrix Server session?
Cheers
Kristy
"Sue Mosher [MVP-Outlook]" <[email protected]> wrote in
toRegarding the "ghost" item: Open it and check its Options dialog
seeloadedwhat's listed for the "Save sent messages to" folder.
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
Hi
No, there is no error, the item just ends up sitting in the drafts
folder, unless you are logged in as the administrator (who
theableapplication onto the Citrix server) in which case it works... seems
strange that it should work for the administrator but not for the
users who use the same files, every other part of the applications
works as expected so it doesn't seem to be a permisions thing just
something about that particular command????
If I use the utils.delivernow line of code, it makes no difference...
and if I use the simulated send/receive click event it is actually
even worse because not only does the item still remain in the drafts
but I get a "ghost item" in the Outbox also! The "ghost item" doesn't
get deleted or Sent when the original item eventually gets flushed
through (either manually or by another item forcing a send/receive),
it has to be manually deleted to remove it.
My predicament gets worse as I have 2 other Citrix clients who want
this "Send and Print HTML" functionality and another 2 who are getting
back to me next week... I don't want to dissapoint them or more
importantly loose their business, it's more than my jobs worth!
Do you have any other ideas on what I can do... Citrix is a very
popular choice here in New Zealand and I'd really like to be
tousingget it to work somehow.
Kris
message
Interesting... And there is no error, it is just nothing
happens,
right?
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
If Version < "11.0" Then 'Outlook XP or lower
Set Btn =
Application.ActiveExplorer.CommandBars.FindControl(1,
5488)
Btn.Execute
Else 'Outlook 2003
Set Btn =
Application.ActiveExplorer.CommandBars.FindControl(1,
7095)
Btn.Execute
End If
K
message
Hmmm... What is your code that simulates a mouse click on
the
Send/Receive
button?
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
Hi Dmitry
Loaded Outlook Spy onto one citrix server as Administrator. I
then
ran
the script you provided via the script editor as suggested
as
both
Administrator and then as a user.
There were no error messages for either, as Administrator
the
flushes immediately and everything works fantastically,
however
when
logged in as a user the mail does not get flushed and sits
in
drafts
until either F5 is pressed, Send/Receive clicked, or a
normal
forces it through.
It looks like it has something to do with the way the
citrix
sessions
work, ie the administrator emails get flushed. This may be
because
it
was the adminstrator that loaded the application. For
some
reason
even though the users run exactly the same files it doesn't
seem
to
want to work for them... do you have any ideas on what I
can
do to
work around this problem? Simulating a send/receive click
does
not
work as mentioned in earlier posts and I'm already
utils.deliverwrote
inOutlookmessage
Can you ask your customer to install OutlookSpy and run
the
script?
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
Hi Dmitry
I ran the code you supplied in Outlook Spy and it
worked
perfectly...
it has always worked on my pc's though it is on a customer
site
that
it doesn't seem to work? I have my addin loaded on 2
citrix
servers
(both running on Windows 2003 server), running
XPmessageSP2.
The
Exchange server is 2003 running on Windows Server 2003.
One of the functions the addin does is to
automatically
send
and
a summary mailitem via a Word template. The
staysain
the
drafts folder until either another messages forces the
queue
to
'flush' or you hit Send/Receive, F5... I have tried
Kens
suggestion of
using utils.delivernow and it didn't make any
difference,
then
I
tried
your suggestion of simulating the 'click' of the
send/recieve
button
and that also makes no difference except I now get
'ghost'toitem
in
the Outbox, that cannot be sent and even when the
queue is
flushed
manually remains and has to be deleted.
I can't see any posts where anyone else has had a similar
problem
so
I'm lost! From what I've read (and seen on my development
pc's)
this
should work just fine on Excgnage without having
usedelivernow
or
simulating clicks etc. Unfortunately this was a
custom
request by
this company so I haven't tried it in any other environment.
Any ideas?
Kristy
"Dmitry Streblechenko \(MVP\)"thewrote
in
message
If you have OutlookSpy, installed, try to run
followingwhatcode
(click
"Script Editor", paste the script, click Run).
Does it run Ok?
set oItem = Application.CreateItem(0)
set sItem = CreateObject("Redemption.SafeMailItem")
sItem.Item = oItem
sItem.Recipients.Add "(e-mail address removed)"
sItem.Recipients.ResolveAll
sItem.Subject = "test subject"
sItem.Send
set sItem=Nothing
set oItem = Nothing
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
Hi
Outlook XP is online. I will try tonight simulating a
click
on
Send/Receive but would rather not use that method
if
there
is
another
way since I can't run the progress bar in the background... or
can
I,
does anyone know how???
I was under the impression from the previous posts
that
I've
read
that
if I'm using exchange server the send function for
redemption
should
work without any problems, but I can't see
I'mdoing
wrong?
Thanks
Kristy
"Dmitry Streblechenko \(MVP\)"towrote
in
message
Is Outlook XP online or offline? Did you try
simulateina
click
on
the
Send/Receive button (http://www.dimastr.com/redemption/faq.htm#1)?
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
"Kristy" <[email protected]> wrote
messagepostsHi
I use Outlook Redemption (3.3.0.315) to
automatically
send
and
HTML emails with an attachment list.
I seem to be having a problem with the
messages
remaining
in
the
Drafts Folder. I have read plenty of
about2000this
and
most
concur
that this is not an issue within an exchange
environment...
however I
am having the issue with Exchange 2003,
Outlook XP
SP2.
The items are marked to send in the Drafts
folder
so
if
Send/Receive
or update (f5) is used then the items go as
expected,
unfortunatley
this is not good enough for my customer as
they
want
it to
go
immediately with no further thought :-(
Also the item once in drafts is 'blocked' by
Outlook
so it
cannot
be
deleted, moved or anything!
Should I try using utils.delivernow or send
keys
to
simulate a
send
receive (which I am going to try in the short
term
as
this
customer is
really giving me grief), I feel that I
shouldn't
have
to
so
this
and
am possibly just covering up a bigger issue?
Code sample below is just like this...
'Call PrintInvoice
With sItem
.Save
.Recipients.ResolveAll
.Send
End With
Is there anything obvious you can see?
BTW... On my development pc's (Exchange
andOutlook
XP)
it
works
as expected.
Thanks K