-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoutlook.psm1
69 lines (57 loc) · 2 KB
/
outlook.psm1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
function Send-Email {
param(
[string]$to,
[string]$subject,
[string]$body
)
$outlook = New-Object -ComObject Outlook.Application
$mail = $outlook.CreateItem(0)
$mail.to = $to
$mail.Subject = $subject
$mail.Body = $body
$mail.Send()
$namespace = $outlook.GetNameSpace("MAPI")
$outbox = $namespace.GetDefaultFolder(4)
while ($outbox.Items.Count -gt 0) {Write-Host "Sending..."; sleep 1}
#ps outlook | select id | kill
}
function day {
Date
# Grab Today
$rangeStart = [DateTime]::Now.Date
$rangeEnd = [DateTime]::Now.Date.AddHours(24)
$outlook = New-Object -ComObject Outlook.Application
$namespace = $outlook.GetNamespace('MAPI')
$folder = $namespace.Folders('[email protected]')
$calendar = $folder.Folders('Calendar').Items
$calendar.Sort("Start")
$calendar.IncludeRecurrences = $true
$restriction = "[End] >= '{0}' AND [Start] <= '{1}'" -f $rangeStart.ToString("g"), $rangeEnd.ToString("g")
$meetings = $calendar.Restrict($restriction)
Write-Host ""
foreach($appt in $meetings) {
"{0:HH:mm}-{1:HH:mm}: {2}" -f [DateTime]$appt.Start, [DateTime]$appt.End, $appt.Subject
}
Write-Host ""
#$outlook.Quit()
}
function week {
Date
# Grab Today
$rangeStart = [DateTime]::Now.Date
$rangeEnd = [DateTime]::Now.AddDays(7)
$outlook = New-Object -ComObject Outlook.Application
$namespace = $outlook.GetNamespace('MAPI')
$folder = $namespace.Folders('[email protected]')
$calendar = $folder.Folders('Calendar').Items
$calendar.Sort("Start")
$calendar.IncludeRecurrences = $true
$restriction = "[End] >= '{0}' AND [Start] <= '{1}'" -f $rangeStart.ToString("g"), $rangeEnd.ToString("g")
$meetings = $calendar.Restrict($restriction)
Write-Host ""
foreach($appt in $meetings) {
"{0:ddd: MM/dd: HH:mm}-{1:HH:mm}: {2}" -f [DateTime]$appt.Start, [DateTime]$appt.End, $appt.Subject
}
Write-Host ""
#$outlook.Quit()
}