Check your Outlook Inbox for new messages

By | 2002-06-01

Checks you Microsoft Outlook Inbox for new Mail Items.

Original Author: Tim Ford

Assumptions

Need to set “References” to Microsoft Outlook.

Returns

The number of new messages

Code

Dim objOutlook As Outlook.Application
Dim objMapiName As Outlook.NameSpace
Dim intCountUnRead As Integer
Private Sub Check_Mail_Click()
Set objOutlook = New Outlook.Application
Set objMapiName = objOutlook.GetNamespace("MAPI")

For I = 1 To objMapiName.GetDefaultFolder(olFolderInbox).UnReadItemCount

  intCountUnRead = intCountUnRead + 1

Next

  MsgBox "You have " & intCountUnRead & " new messages in your Inbox . .
  ",   vbInformation + vbOKOnly, "New Messages . . ."
  intCountUnRead = 0
Set objMapiName = Nothing
Set objOutlook = Nothing

End Sub

Author: dwirch

Derek Wirch is a seasoned IT professional with an impressive career dating back to 1986. He brings a wealth of knowledge and hands-on experience that is invaluable to those embarking on their journey in the tech industry.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.