Solved

Create a notification when E-Mail is not received.

Posted on 2009-05-19
4
199 Views
Last Modified: 2012-05-07
Hi,
Could you provide some help with creating a power shell script that would generate a notification (by mail possibly) that would provide an alert to the fact that mail was not received at a specific mailbox or group of mailboxes according to a predefined amount of time?
Thanks For your help.
Jason.
0
Comment
Question by:Elad-a
[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 4

Expert Comment

by:peter_field
ID: 24419985
Have a look at:
http://blogs.msdn.com/jmanning/archive/2007/01/25/using-powershell-for-outlook-automation.aspx

I have written some code that you should be able to adapt below.
$outlook = New-Object -ComObject Outlook.Application
$folder = $outlook.Session.GetDefaultFolder(6)
# You can use AddMinutes instead of AddDays if you like. If you want to see what other properties are avaialble for a message uncomment the line below.
#$folder.Items | select -first 1 | fl *
$match = @( $folder.Items | where { $_.CreationTime -ge ([DateTime]::Now).AddDays(-1) -and $_.TaskSubject -eq "Message Subject" } )
 
if ( $match.Count -eq 0 )
{
    # Send alert
    $smtp = New-Object Net.Mail.SmtpClient("your.smtp.server.here")
    $smtp.Send("from@yourdomain.com", "recipient@domain.com", "email hasn't shown up", "better sort out the problem")
}

Open in new window

0
 

Author Comment

by:Elad-a
ID: 24420769
Thats a realy cool solution, but i need to run it on Ms Exchange 2007 where i dont have an outlook installation.
Is tehre a way to do the same with exchange ?
0
 
LVL 4

Accepted Solution

by:
peter_field earned 500 total points
ID: 24427676
There aren't any native Exchange cmdlets that will let you inspect messages in a mailbox. You have a few solutions that I can think of:

1. EWS
2. WebDAV
3. Outlook as above

1. Calling EWS from Powershell can be done, but I'd imagine not trivial. Wait, you might be saved by the EWS managed API that has been recently released. See http://gsexdev.blogspot.com/2009/04/using-ews-managed-api-with-powershell.html, http://blogs.utexas.edu/glenmark/2009/04/17/using-the-ews-managed-api-via-powershell/.

2. I wouldn't recommend this as WebDAV is on its way out, and it's probably harder than EWS anyway.

Hope that helps. If you need me to adapt the code for point 1 let me know, as I'd be interested in playing with it anyway, but don't have time right at the moment (i.e. next 8-10 hours).
0
 

Author Closing Comment

by:Elad-a
ID: 31582891
Thanks
0

Featured Post

Free Tool: IP Lookup

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.

Question has a verified solution.

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

Suggested Solutions

This article explains how to install and use the NTBackup utility that comes with Windows Server.
In previous parts of this Nano Server deployment series, we learned how to create, deploy and configure Nano Server as a Hyper-V host. In this part, we will look for a clustering option. We will create a Hyper-V cluster of 3 Nano Server host nodes w…
The video tutorial explains the basics of the Exchange server Database Availability groups. The components of this video include: 1. Automatic Failover 2. Failover Clustering 3. Active Manager
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

749 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