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 message
Well, 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
Kristy said:
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 message
Hmmm... I am pretty much out of ideas. Would it work if you leave
all
the
Redemption code intact but comment out SafeMailItem.Send? Can you
post
the
code 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
message
Regarding the "ghost" item: Open it and check its Options dialog
to
see
what'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
loaded
the
application 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
able
to
get it to work somehow.
Kris
"Dmitry Streblechenko \(MVP\)" <
[email protected]> wrote in
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
email
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
email
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
using
utils.deliver
now as Ken suggested.
Thanks
Kristy
"Dmitry Streblechenko \(MVP\)" <
[email protected]>
wrote
in
message
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
Outlook
XP
SP2.
The
Exchange server is 2003 running on Windows Server 2003.
One of the functions the addin does is to automatically
send
and
print
a summary mailitem via a Word template. The
message
stays
in
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
a
'ghost'
item
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
to
use
delivernow
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\)"
the
following method
if
there what
I'm
to
simulate in
message posts
about
Outlook XP
SP2. send
keys
to short
term
as 2000
and