2017-07-15 79 views
1

this相关,我正在阅读Exchange的一些消息,并希望以纯文本格式(非html)显示正文。我正在使用F#。下面是代码:EWS body plain text使用F#

> let exchangeService = new 
> ExchangeService(ExchangeVersion.Exchange2007_SP1) 
> exchangeService.Credentials <- new 
> WebCredentials(userName,password,domain) 
> exchangeService.AutodiscoverUrl(email) 
> 
> let getEmailText exchangeService itemId = 
>  let propertySet = new PropertySet() 
>  propertySet.RequestedBodyType <- BodyType.Text 
>  propertySet.BasePropertySet <- BasePropertySet.FirstClassProperties 
>  let message = EmailMessage.Bind(exchangeService, itemId, propertySet) 
>  message.TextBody 

编译器是抱怨在这条线:

propertySet.RequestedBodyType <- BodyType.Text 

这表达预计将有类型可空,但这里的类型是体形

如何我使BodyType.Text可空?可空不起作用

+3

尝试'propertySet.RequestedBodyType < - 可空BodyType.Text' –

+0

这就是它- 谢谢! –

回答

0

改变这一行:

propertySet.RequestedBodyType <- BodyType.Text 

对此(刚加入Nullable型):

propertySet.RequestedBodyType <- Nullable BodyType.Text 
相关问题