Improve company productivity with a Business Account.Sign Up
Administration of Active Directory does not have to be hard. Too often what should be a simple task is made more difficult than it needs to be.The solution? Hyena from SystemTools Software. With ease-of-use as well as powerful importing and bulk updating capabilities.
'--> Create some constants
'On the next line enter the name of the profile the mailbox is in
Const PROFILE_NAME = "Outlook"
'On the next line set the message count threshold.
Const MSG_COUNT_LIMIT = 500
'On the next line set the message size threshold
Const MSG_SIZE_LIMIT = 50000000
'On the next line set the subject of the warning message the script will send if the mailbox is over either threshold
Const WARNING_SUBJECT = "Mailbox Over Limit"
'On the next line set the eamil address the warning message will go to if the mailbox is over either threshold
Const WARNING_ADDRESS = "firstname.lastname@example.org"
Const SCRIPT_NAME = "Check Mailbox Size"
Const olMailItem = 0
Const olFormatPlain = 1
Const olFolderInbox = 6
'--> Create some variables
Dim olkApp, olkSes, olkFld, olkItm, olkMsg, varSiz, bolSiz, bolCnt
'--> Connect to Outlook
Set olkApp = CreateObject("Outlook.Application")
Set olkSes = olkApp.GetNamespace("MAPI")
Set olkFld = olkSes.GetDefaultFolder(olFolderInbox)
'--> Check the mailbox size and item count
varSiz = 0
For Each olkItm In olkFld.Items
varSiz = varSiz + olkItm.Size
bolSiz = (varSiz > MSG_SIZE_LIMIT)
bolCnt = (olkFld.Items.Count > MSG_COUNT_LIMIT)
If bolSiz Or bolCnt Then
Set olkMsg = olkApp.CreateItem(olMailItem)
.subject = WARNING_SUBJECT
.to = WARNING_ADDRESS
.bodyformat = olFormatPlain
If bolSiz And bolCnt Then
.body = "The mailbox is over both the size and count limits." & vbCrLf & vbCrLf & "Size: " & varSiz & vbCrLf & "Count: " & olkFld.Items.Count
If bolSiz Then
.body = "The mailbox is over the size limit." & vbCrLf & vbCrLf & "Size: " & varSiz
If bolCnt Then
.body "The mailbox is over the count limit." & vbCrLf & vbCrLf & "Count: " & olkFld.Items.Count
'--> Disconnect from Outlook
Set olkMsg = Nothing
Set olkItm = Nothing
Set olkFld = nothing
Set olkSes = Nothing
Set olkApp = Nothing
Open in new window
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Please enter a first name
Please enter a last name
Must be at least 4 characters long.
Join and Comment
Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.
One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.