Redemption Send/Drafts problem

K

Kristy

Hi

I use Outlook Redemption (3.3.0.315) to automatically send and print
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 posts about this 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 2000 and Outlook XP) it works
as expected.

Thanks K
 
K

Ken Slovak - [MVP - Outlook]

After the item is sent you then active the transport mechanism to actually
send it out. Use MAPIUtils.DeliverNow for that.
 
K

Kristy

Thanks Ken

For some reason I thought that you didn't have to use utils.delivernow
with exchange server but I'll put it in and hopefully that will fix
it.

Cheers
 
K

Kristy

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 what I'm doing wrong?

Thanks

Kristy
 
D

Dmitry Streblechenko \(MVP\)

If you have OutlookSpy, installed, try to run the following code (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
 
K

Kristy

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
 
K

Kristy

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
 
D

Dmitry Streblechenko \(MVP\)

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
 
K

Kristy

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
 
K

Kristy

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
 
S

Sue Mosher [MVP-Outlook]

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
 
K

Kristy

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
 
D

Dmitry Streblechenko \(MVP\)

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


Kristy said:
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




Application.ActiveExplorer.CommandBars.FindControl(1,
5488) Application.ActiveExplorer.CommandBars.FindControl(1,
7095) message
then
ran however
when because
it seem
to does
not
message
citrix
servers SP2.
The send
and
print in
the queue
to then
I
tried send/recieve
button 'ghost'
item
in following
code
(click there
is
another that
I've doing
wrong? wrote
in simulate
a
click automatically
send this
and so
if
Send/Receive expected,
unfortunatley want
it to
go Outlook
so it as
this
customer is have
to
so
 
K

Kristy

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\) said:
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


Kristy said:
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


"Dmitry Streblechenko \(MVP\)" <[email protected]> wrote in
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



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




message
If you have OutlookSpy, installed, try to run the following
code
(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 what I'm
doing
wrong?
Thanks

Kristy


"Dmitry Streblechenko \(MVP\)" <[email protected]>
wrote
in
message
Is Outlook XP online or offline? Did you try to simulate
a
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


Hi

I use Outlook Redemption (3.3.0.315) to
automatically
send
and
print
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 posts about
this
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
 
D

Dmitry Streblechenko \(MVP\)

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


Kristy said:
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


"Dmitry Streblechenko \(MVP\)" <[email protected]> wrote in
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



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\)" <[email protected]>
wrote
in
message
If you have OutlookSpy, installed, try to run the following
code
(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 what
I'm
doing
wrong?
Thanks

Kristy


"Dmitry Streblechenko \(MVP\)"
messages
remaining about
this
and Outlook XP
SP2. folder
so they
want
Outlook
so it keys
to term
as shouldn't
have
 
K

Kristy

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\) said:
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
the
script? worked
perfectly... automatically
send
Kens
suggestion of
difference,
then
queue is
flushedcustom
request by
wrote
in if
there messages
remaining
Outlook XP
SP2.
folder
so they
want keys
to term
as shouldn't
have
 
D

Dmitry Streblechenko \(MVP\)

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 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
 

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