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

Badges
MCSE
Community

Cozumpark Bilisim Portali
How to parse mail with Powershell?
Posted in Windows Powershell | No Comment | 2,590 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.



Leave a Reply