search
Categories
Sponsors
VirtualMetric Hyper-V Monitoring, Hyper-V Reporting
Archive
Blogroll

Badges
MCSE
Community

Cozumpark Bilisim Portali
Posted in Windows Powershell | No Comment | 2,628 views | 07/06/2009 10:25

You can parse your mails with Powershell.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# Create TimeStamp
$timestamp = TimeStamp
 
# Save support mail with TimeStamp.
$_.body > C:\support.$timestamp.txt
 
# Parse mail.
$supporttxt = "C:\support.$timestamp.txt"
$pattern_email = Select-String "$supporttxt" -pattern "EMAIL"
$pattern_email = $pattern_email.get_Line()
$pattern_name = Select-String "$supporttxt" -pattern "NAME"
$pattern_name = $pattern_name.get_Line()
$pattern_priority = Select-String "$supporttxt" -pattern "PRIORITY"
$pattern_priority = $pattern_priority.get_Line()
$email = $pattern_email.TrimStart(": ")
$name = $pattern_name.TrimStart("NAME: ")
$priority = $pattern_priority.TrimStart("PRIORITY: ")

I posted “TimeStamp” and “$_.body” parts on my before posts. You can check Powershell category to check them.


Posted in Windows Powershell, Windows Server | No Comment | 3,524 views | 07/06/2009 09:45

You can check new mails with Powershell. But you need Outlook Connector.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
$InboxFolder = 6
$Outlook = new-object -com outlook.application;
$NameSpace = $Outlook.GetNameSpace("MAPI");
$Inbox = $NameSpace.GetDefaultFolder($InboxFolder)
$Inbox.items | foreach {
    if($_.body -match "Support") 
        {
            write-host You have a new mail.
        }
        else
        {
            write-host No new mail.
        }
}

By default, Inbox folder number is 6. You can change that number for other directories.