Sorry, that was a typo with
www.outlookcode.com.
The problem I see with a loop is that it may become infinite. Then the code
is essentially locking up your computer. If I was to use a loop I'd
condition it with a flag that was set before entering the loop and cleared
when any of the relevant events was fired. That way at least you'd know when
to terminate the loop.
In some versions of Outlook you can get an Inspector.Close and not an
Item.Close depending on whether WordMail is being used and if Send is fired.
As I recall there are a couple of other obscure cases but I haven't played
with that for a long time since my template code always handles both Close
events, so I haven't needed to determine the cases in a while. Your mileage
may vary.
--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm
"Michel S." wrote in message
...
Thanks for your answer Ken.
I'm considering a loop because I want the Excel macro execution to be
suspended until the user has finished the e-mail processing (send or
close). Is this what the Modal parameter of the .Display method is for ?
Are there side effects to this to be aware of ?
I wend to the site you mentioned (I guess you meant www.outlookcode.com ?)
and found some interesting samples.
I made a small class module in excel where I create and display a mail
item and containing various event sinking routines containing only code to
get a trace of the events sequence while I edit, save, close or send the
mail item; for now these routines are all like the following one :
Private Sub objMailItem_Send(Cancel AS Boolean)
Debug.Print "MailItem send"
End Sub
From a standard module, I create an instance of this class, and call its
"Display" method. Once the execution is finished, I can see the
Open/Send/Close and the Open/Close sequences in the immediate window
depending on what I did with the message. So far so good. :-)
For some strange reason, I found that few test messages I sent were stored
in the "Inbox" instead of the "Outbox". Since they are datestamped at the
beginning of my tests, I guess it is due to some objects correctly not
closed or set to null during the early steps of programming. I'll post
back if I find this to be false.
So far, I only had to resort to the MailItem object. What are the
circumstances you say the Inspector would be used for ? How an Item close
event wont fire but the Inspector's will ?
Thanks again !