Clear multiple MsgBox!!!

G

Guest

Hi Everyone

I use a bit of code that gives me the same alert that was used on Outlook
2000 for new mail Items...I am using Outlook 2003. btw i dont like the mail
envelope or desktop alert thats why im using this macro!

This code is in "ThisOutlookSession" and invoked via the Rules and Alerts
wizard for any new mail received without exceptions.

Sub CustomMailMessageRule(Item As Outlook.MailItem)
MsgBox "Mail message arrived: " & Item.Subject
End Sub

I have two problems...
1. When I start Outlook in the morning, all the mail i recieved creates a
new MsgBox, so if i have 10 emails i have to click the OK button 10 times!
2. Sometimes when i restart Outlook, the macro doesn't work...when i open
the Rules and Alerts wizard, the check box is blank for the action.

I need some code that will allow me to just click ok the once for emails,
but still alert me each time a new one arrives during the day. Also, anyone
got any ideas on why the macro may stop working?

Thanks in Advance!!!
 
M

Michael Bauer

Am Tue, 2 May 2006 06:45:02 -0700 schrieb RemySS:

1) You could use an UserForm instead of the message box and show it
non-modal. On that UserForm each mail could be added into a ListBox e.g..
While the form is visible each new mail would be added to the same form.

2) -
 
G

Guest

Hi Michael,

Im a VBA intermediate so could you give me an example of how i would code
such a form?

Thanks
 
M

Michael Bauer

Am Thu, 4 May 2006 04:32:01 -0700 schrieb RemySS:

Please add an UserForm to your VBA project. Then show the Toolbox and drag a
ListBox onto that form.

The code could look like this:

<form>
Public Sub AddItem(Text As String)
ListBox1.AddItem Text
End Sub
</form>

<ThisOutlookSession>
Private fm as Form1

Sub CustomMailMessageRule(Item As Outlook.MailItem)
On Error Resume Next
If fm Is Nothing Then Set fm=new Form1
fm.AddItem Item.Subject
fm.Show
End Sub
</ThisOutlookSession>
 
G

Guest

I think i can work with that!!

Thanks!

Michael Bauer said:
Am Thu, 4 May 2006 04:32:01 -0700 schrieb RemySS:

Please add an UserForm to your VBA project. Then show the Toolbox and drag a
ListBox onto that form.

The code could look like this:

<form>
Public Sub AddItem(Text As String)
ListBox1.AddItem Text
End Sub
</form>

<ThisOutlookSession>
Private fm as Form1

Sub CustomMailMessageRule(Item As Outlook.MailItem)
On Error Resume Next
If fm Is Nothing Then Set fm=new Form1
fm.AddItem Item.Subject
fm.Show
End Sub
</ThisOutlookSession>
 

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