EWS.types.ps1xml

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
<?xml version="1.0" encoding="utf-8"?>
<Types>
    <Type>
        <Name>Microsoft.Exchange.WebServices.Data.EmailMessage</Name>
        <Members>
            <ScriptProperty >
                <Name>BodyText</Name>
                <GetScriptBlock>
                    switch ($this.Body.BodyType) {
                        HTML {
                            $html = New-Object -ComObject htmlfile
                            $html.IHTMLDocument2_write($this.Body.Text)
                            $html.body.innerText
                        }
                        Text {
                            $this.Body.Text
                        }
                        default {
                            return
                        }
                    }
                </GetScriptBlock>
            </ScriptProperty>
            <ScriptMethod>
                <Name>BodyPreview</Name>
                <Script>
                    param ([int]$First = 10)
                    switch ($this.Body.BodyType) {
                        HTML {
                            $html = New-Object -ComObject htmlfile
                            $html.IHTMLDocument2_write($this.Body.Text)
                            ($html.body.innerText.Split("`n") | select -First $First) -join "`n"
                        }
                        Text {
                            ($this.Body.Text.Split("`n") | select -First $First) -join "`n"
                        }
                        default {
                            return
                        }
                    }
                </Script>
            </ScriptMethod>
        </Members>
    </Type>
</Types>