Your users *shouldn't* be able to shut down Outlook while your code is
running, unless it is a very lengthy operation. However, I'm not quite sure
if Outlook will wait for a macro or Add-In to complete before completing it's
shut down process. And regardless of the application or solution, there's
not much a developer can do to handle OS or hardware failure.
If running your Excel automation code via user intervention (clicking a
button) is not what you'd like, think about when a user may be doing
something that makes sense for this code to execute, like opening an e-mail
(Item_Open), saving (Item_Save) or sending (Item_Send). These and other
events could be handy hooks to launch your custom process.
--
Try Picture Attachments Wizard for Outlook!
http://tinyurl.com/9bby8
--
Eric Legault - B.A, MCP, MCSD, Outlook MVP
Job:
http://www.imaginets.com
Blog:
http://blogs.officezealot.com/legault/
:
Hi Eric,
The operations I want to automate are:
1. Save an Exel attachment of a mail item.
2. Read an Exel database file to get the current largest reference number,
plus one as the reference number of the mail.
3. Save the new reference number to the Excel database file.
4. Set the UserProperty of the mail as "read".
5. Sent back a confirmation letter with the reference number.
If my program stopped at operation 3, then next time the program start
again, the same mail item is read again and set another new reference number,
which is a disaster for the application.
My old design is using a timer to run those operations automatically, but
ignoring the case that the user can close the Outlook and stop the program at
any time. If I add an command button to let user click then run the program
as you suggested, then such exception become much less.
However, the solution still does not prevent the problem completely. In the
case of the computer is shut down for some other reason like hardware
problem, such exception still could happen.
Do you have any other good ideas?
Thanks very much.
Shu
“Eric Legault [MVP - Outlook]â€
What is it exactly that you are automating?
--
Eric Legault - B.A, MCP, MCSD, Outlook MVP
--
Try Picture Attachments Wizard for Outlook!
http://tinyurl.com/9bby8
--
Job:
http://www.imaginets.com
Blog:
http://blogs.officezealot.com/legault/
:
Hi Eric,
Thanks very much for the suggestions. I wanted to completely automate the
operations, but it seems this is impossible on the client side.
Thanks again and regards,
Shu
Eric Legault [MVP - Outlook]"
No, Outlook doesn't support a transactional data model.
I would redesign your solution so that your custom operations are linked to
any of the events exposed by the Object Model. This approach is user-driven,
and would be more stable than having your application doing whatever it wants
without knowing what the user could be doing at any given time, which is a
recipe for disaster.
--
Eric Legault - B.A, MCP, MCSD, Outlook MVP
--
Try Picture Attachments Wizard for Outlook!
http://tinyurl.com/9bby8
--
Job:
http://www.imaginets.com
Blog:
http://blogs.officezealot.com/legault/
:
Hi Experts,
I screw up on handling the exception that user quite the Outlook while VBA
is still running. This normally does not happen so I never thought it before.
But now my program in Outlook is triggered by a timer at a fixed interval,
its operations are invisible to the outlook user. hence very possible that
the user close the Outlook when the program is still running the code. This
would cause the operations uncompleted and causing big trouble. Is there
something like transatcions in database so I can roll back each operation
when such exception happens.
Please give me some hints how to solve such problem.I would appreciat your
help a lot.
Thanks very much and Regards
Shu