EWS Exchange Email Body Text Instead of HTML


i found script below displaying email on new item event in microsoft exchange using ews. tell me how make body display in plaintext rather default html format?

thanks!

zach

$mailboxname

= "user@domain.com"

$dllpath

= "c:\program files\microsoft\exchange\web services\1.1\microsoft.exchange.webservices.dll"

[

void][reflection.assembly]::loadfile($dllpath)

$service

= new-object microsoft.exchange.webservices.data.exchangeservice([microsoft.exchange.webservices.data.exchangeversion]::exchange2010_sp1)

$service

.traceenabled = $false

$service

.credentials = new-object system.net.networkcredential("user@domain.com","password")

$service

.autodiscoverurl($mailboxname ,{$true})

$fldarray

= new-object microsoft.exchange.webservices.data.folderid[] 1

$inboxid

= new-object microsoft.exchange.webservices.data.folderid([microsoft.exchange.webservices.data.wellknownfoldername]::inbox,$mailboxname)

$fldarray

[0] = $inboxid

$stmsubscription

= $service.subscribetostreamingnotifications($fldarray, [microsoft.exchange.webservices.data.eventtype]::newmail)

$stmconnection

= new-object microsoft.exchange.webservices.data.streamingsubscriptionconnection($service, 30);

$stmconnection

.addsubscription($stmsubscription)

register-objectevent

-inputobject $stmconnection -eventname "onnotificationevent" -action {

foreach($notevent in $event.sourceeventargs.events){

[

string]$itmid = $notevent.itemid.uniqueid.tostring()

$message = [microsoft.exchange.webservices.data.emailmessage]::bind($event.messagedata,$itmid)

"subject : " + $message.subject + " " + $message.body (get-date) | out-file c:\temp\log2.txt -append

}

}

-messagedata $service

register-objectevent

-inputobject $stmconnection -eventname "ondisconnect" -action {$event.messagedata.open()} -messagedata $stmconnection

$stmconnection

.open()



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

server manager error: ADAM.events.xml could not be enumerated.

Cannot access Anywhere Access using domain name?

WMI Failure: Unable to update Local Resource Group