#  Other Applications & Softwares  > Outlook Formatting & Functions >  > [SOLVED] Outlook Freezes with macro

## dflak

The following VB code checks a list of mailboxes and mails me a message with the number of messages in each mailbox every 15 minutes. The works perfectly except for one problem. If I am composing an email or responding to one when the code kicks off, Outlook Freezes. I put in more DoEvents than code, I think. I also "instrumented" the code to write a log as it takes various steps. It consistently fails at the step indicated. Outlook issues no errors and I kill outlook with the windows task manager and I restart it and it restarts normally with no messages.

Log extract:
"11/21/2018 11:13:00 Initalizing Variables"
"11/21/2018 11:13:00 Initalizing Outlook"
"11/21/2018 11:13:00 Looping through folders"
"11/21/2018 11:13:00 Processing Amazon Daily Ops Reports"
"11/21/2018 11:13:00 Getting number of messages in Amazon Daily Ops Reports"

The issue is also discussed in this forum: https://www.utteraccess.com/forum/in...&#entry2705093

This is the code in the ThisOutlookSession Module. It doesn't seem to have a problem



```
Please Login or Register  to view this content.
```


Here is the complete rest of the code which is in a regular module. The mail workbook routine never crashes. The issue is with the Mail Alert routine.



```
Please Login or Register  to view this content.
```

----------


## dflak

I have not been able to keep the program from freezing, however I found a work-around. I can check if a message is open for editing and put in a sleep loop to delay the program until the message is no longer being edited. I will post a link to this solution once I test it and clean up the code.

----------


## dflak

Here is the solution: https://www.excelforum.com/tips-and-...ml#post5029090

----------

