Solved

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

Posted on 2014-01-29
4
320 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you troubleshoot Outlook for clients, you may want to know a bit more about the OST file before doing your next job. IMAP can cause a lot of drama if removed in the accounts without backing up.
There are times when we need to generate a report on the inbox rules, where users have set up forwarding externally in their mailbox. In this article, I will be sharing a script I wrote to generate the report in CSV format.
In this video we show how to create an Accepted Domain 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 Mail Flow >> Ac…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Suggested Courses

636 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