Solved

need a script that will email me when items in user1 mailbox inbox hits over 100

Posted on 2014-01-29
4
303 Views
Last Modified: 2014-02-03
im looking for a script that will send me an email when the items in user1 inbox hits over 100
im using exchange 2010 sp1
0
Comment
Question by:dougdog
  • 2
  • 2
4 Comments
 
LVL 7

Expert Comment

by:flaphead_com
ID: 39818567
hope this helps.

Start by getting the users mailbox and the mailbox folder stats, where the folderpath is \Inbox

The is the ItemsInFolder is greater than 100, send an email

$User    = "user smtp"
$Items   = 100
$mailbox = get-mailbox $user | Get-MailboxFolderStatistics | Where {$_.FolderPath -eq "/Inbox"}
If($mailbox.ItemsInFolder -gt $items){
  $emailFrom  = "<from email address>"
  $emailto    = "<to email address>"
  $msgSubject = "$user Exceeds $items in inbox"
  $msgBody    = "$user has " + $mailbox.ItemsInFolder + " in inbox"
  $message    = New-Object Net.Mail.MailMessage($emailFrom, $emailto, $msgsubject, $msgbody)
  $smtp       = New-Object Net.Mail.SmtpClient("<smtp relay>")
  $smtp.Send($message)
  Write-Host "Email Sent"
}
0
 

Author Comment

by:dougdog
ID: 39820425
will i just save this asa *.ps1
then schedule it?
0
 
LVL 7

Accepted Solution

by:
flaphead_com earned 500 total points
ID: 39821611
Aye, so save it a .ps1 and try it first, then you can create a schedule task.

What I like to do is create a cmd file that the scheduled task references and in the cmd have:

powershell <location of script.ps1?
0
 

Author Closing Comment

by:dougdog
ID: 39829245
perfect many thanks
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

This process describes the steps required to Import and Export data from and to .pst files using Exchange 2010. We can use these steps to export data from a user to a .pst file, import data back to the same or a different user, or even import data t…
Following basic email etiquette rules will help you write a professional email and achieve a good, lasting impression with your contacts.
In this video we show how to create a User Mailbox in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Recipients >> Mailb…
In this video we show how to create a Contact in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Recipients >> Contact ta…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now