douchongbc72264 2012-06-01 07:34
浏览 114
已采纳

PHP Exchange Web服务 - 获取消息正文

I'm using a PHP EWS library, and took this example to get a list of messages, which works perfectly.

It pulls through details such as the sender, receiver, subject, time etc. I tried looking through all the library, but I can't workout how to pull through the message body and attachments.

Any ideas?

  • 写回答

1条回答 默认 最新

  • doujiao3016 2012-06-04 13:35
    关注

    It is well described in PHP EWS wiki, right here: https://github.com/jamesiarmes/php-ews/wiki/Email-:-Retrieve-All-Email-Attachments

    Edit: use whole example linked above to fetch email attachments and just part of it to get the message:

    $message_id = ''; // Id of the email message
    
    $ews = new ExchangeWebServices($host,  $user, $password);
    
    $request = new EWSType_GetItemType();
    
    $request->ItemShape = new EWSType_ItemResponseShapeType();
    $request->ItemShape->BaseShape = EWSType_DefaultShapeNamesType::ALL_PROPERTIES;
    
    $request->ItemIds = new EWSType_NonEmptyArrayOfBaseItemIdsType();
    $request->ItemIds->ItemId = new EWSType_ItemIdType();
    $request->ItemIds->ItemId->Id = $message_id; 
    
    $response = $ews->GetItem($request);
    
    if( $response->ResponseMessages->GetItemResponseMessage->ResponseCode == 'NoError' &&
        $response->ResponseMessages->GetItemResponseMessage->ResponseClass == 'Success' ) {
    
        $message = $response->ResponseMessages->GetItemResponseMessage->Items->Message;
    }
    

    At this point you have the $message. To access body use $message->body - it's an object with bodyType etc - to actually read the message body content use $message->body->_

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号