Messages stuck in outbox

G

Guest

Hi!
I'm sending emails and saving the same item to a .pst. I am changing the
sent item destination using:
StoreID = objDestinationFolder.StoreID
FolderID = objDestinationFolder.EntryID
Set olNewMessage.SaveSentMessageFolder = objDestinationFolder

It is working fine, but when all the messages are sent the outbox still
shows all the emails there. It seems like it won't move the sent items to the
..pst until I do a "send and receive" (F9). Is there a way to do this from
code? or how can I avoid saving it to the sent items at all?

Thanks!!
 
K

Ken Slovak - [MVP - Outlook]

You can find the CommandBarControl that represents the Send/Receive menu
item and call its Execute method to perform a Send/Receive action.

Try the DeleteAfterSubmit Boolean, set it true on the mail item and no copy
will be saved after sending.
 
G

Guest

Hi Ken,

Thanks for the help. It's working now, but I have another problem. After all
the messages are sent I close the .pst file. The problem is that for the last
messages the send/receive is still active when the close .pst command
executes. I tried with the "Doevents" after the Send/Receive, but it didn't
work. Is there a way of telling the macro to wait until the send/receive
finishes?

Thx!
 
K

Ken Slovak - [MVP - Outlook]

There's no way to tell if the send/receive is finished usually.

You can use the SyncObjects collection and initiate a synch in your code and
then handle the synch end event. That would work, usually most people have 1
defined send/receive group, but if there are more it can be very hard to
tell which accounts are being sent with which groups.

Look at http://www.outlookcode.com/threads.aspx?forumid=4&messageid=16184
for some sample code using syncobjects, it might help.
 

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