在我的PHP脚本中,我需要弄清楚如何检索指定消息ID之后或特定日期之后的所有电子邮件(要么工作,我只需要检索自上次我收集收件箱后新的电子邮件).

此收件箱每天收到数千封电子邮件,我无法删除任何30天的电子邮件.对于初始导入,我只是从收件箱的开头做了一个偏移,但显然一旦我们开始清理电子邮件就无法工作.

我想我必须设置类“EWSType_FindItemType”的$Restriction属性,但我不认为php-ews中存在必要的类来执行此操作.我自己尝试添加它们,但我对EWS或SOAP不够了解.

到目前为止,我唯一想到的是:

$Request->Restriction = new EWSType_RestrictionType();

$Request->Restriction->IsGreaterThan = new stdClass;

$Request->Restriction->IsGreaterThan->FieldURIOrConstant = new stdClass;

$Request->Restriction->IsGreaterThan->FieldURIOrConstant->Constant = '2012-01-02T07:04:00Z';

$Request->Restriction->IsGreaterThan->FieldURI = new stdClass;

$Request->Restriction->IsGreaterThan->FieldURI->FieldURI = 'item:DateTimeReceived';

这不起作用:(

这是我目前用于检索电子邮件的代码:

require( dirname( __FILE__ ) . '/ews/ExchangeWebServicesLoader.php' );

$ews = new ExchangeWebServices( EXCHANGE_HOSTNAME, EXCHANGE_USERNAME, EXCHANGE_PASSWORD, ExchangeWebServices::VERSION_2010_SP1 );

$Request = new EWSType_FindItemType();

$Request->ItemShape = new EWSType_ItemResponseShapeType();

$Request->ItemShape->BaseShape = EWSType_DefaultShapeNamesType::ALL_PROPERTIES;

$Request->ItemShape->BodyType = EWSType_BodyTypeResponseType::TEXT;

$Request->ItemShape->BodyTypeSpecified = true;

$Request->Traversal = EWSType_ItemQueryTraversalType::SHALLOW;

$Request->IndexedPageItemView = new EWSType_IndexedPageViewType();

$Request->IndexedPageItemView->MaxEntriesReturned = 25;

$Request->IndexedPageItemView->BasePoint = 'Beginning';

$Request->IndexedPageItemView->Offset = $offset;

$Request->ParentFolderIds = new EWSType_NonEmptyArrayOfBaseFolderIdsType();

$Request->ParentFolderIds->DistinguishedFolderId = new EWSType_DistinguishedFolderIdType();

$Request->ParentFolderIds->DistinguishedFolderId->Id = 'inbox';

$Request->ParentFolderIds->DistinguishedFolderId->Mailbox = new EWSType_EmailAddressType();

$Request->ParentFolderIds->DistinguishedFolderId->Mailbox->EmailAddress = 'sharedmailbox@company.org';

// sort order

$Request->SortOrder = new EWSType_NonEmptyArrayOfFieldOrdersType();

$Request->SortOrder->FieldOrder = array();

$order = new EWSType_FieldOrderType();

$order->FieldURI = new stdClass;

$order->FieldURI->FieldURI = 'item:DateTimeReceived';

$order->Order = 'Ascending';

$Request->SortOrder->FieldOrder[] = $order;

$response = $ews->FindItem($Request);

$items = $response->ResponseMessages->FindItemResponseMessage->RootFolder->Items->Message;

foreach ( $items as $item ) {

// Do stuff

}

任何帮助将不胜感激!

解决方法:

EWS中的限制很棘手,是的.你可以看一下他们在EWSWrapper中使用的山楂,这里的例子是如何创建AND限制来获取日期范围之间的项目:

//create AND restrction

$request->Restriction = new EWSType_RestrictionType();

$request->Restriction->And = new EWSType_AndType();

$request->Restriction->And->IsGreaterThanOrEqualTo = new EWSType_IsGreaterThanOrEqualToType();

$request->Restriction->And->IsGreaterThanOrEqualTo->ExtendedFieldURI = new EWSType_PathToExtendedFieldType;

$request->Restriction->And->IsGreaterThanOrEqualTo->ExtendedFieldURI->DistinguishedPropertySetId = "Task";

$request->Restriction->And->IsGreaterThanOrEqualTo->ExtendedFieldURI->PropertyId = "33029";

$request->Restriction->And->IsGreaterThanOrEqualTo->ExtendedFieldURI->PropertyType = "SystemTime";

$request->Restriction->And->IsGreaterThanOrEqualTo->FieldURIOrConstant->Constant->Value = date('c', $start);

$request->Restriction->And->IsLessThanOrEqualTo = new EWSType_IsLessThanOrEqualToType();

$request->Restriction->And->IsLessThanOrEqualTo->ExtendedFieldURI = new EWSType_PathToExtendedFieldType;

$request->Restriction->And->IsLessThanOrEqualTo->ExtendedFieldURI->DistinguishedPropertySetId = "Task";

$request->Restriction->And->IsLessThanOrEqualTo->ExtendedFieldURI->PropertyId = "33029";

$request->Restriction->And->IsLessThanOrEqualTo->ExtendedFieldURI->PropertyType = "SystemTime";

$request->Restriction->And->IsLessThanOrEqualTo->FieldURIOrConstant->Constant->Value = date('c', $end);

使用的类型:

class EWSType_RestrictionType extends EWSType {

/**

* SearchExpression property

*

* @var EWSType_SearchExpressionType

*/

public $SearchExpression;

/**

* Constructor

*/

public function __construct() {

$this->schema = array(

array(

'name' => 'SearchExpression',

'required' => false,

'type' => 'SearchExpressionType',

),

); // end $this->schema

} // end function __construct()

} // end class RestrictionType

class EWSType_AndType extends EWSType {

/**

* SearchExpression property

*

* @var EWSType_MultipleOperandBooleanExpressionType

*/

public $SearchExpression;

/**

* Constructor

*/

public function __construct() {

$this->schema = array(

array(

'name' => 'SearchExpression',

'required' => false,

'type' => 'MultipleOperandBooleanExpressionType',

),

); // end $this->schema

} // end function __construct()

} // end class AndType

class EWSType_IsLessThanOrEqualToType extends EWSType {

/**

* SearchExpression property

*

* @var EWSType_TwoOperandExpressionType

*/

public $SearchExpression;

/**

* Constructor

*/

public function __construct() {

$this->schema = array(

array(

'name' => 'SearchExpression',

'required' => false,

'type' => 'TwoOperandExpressionType',

),

); // end $this->schema

} // end function __construct()

} // end class IsLessThanOrEqualToType

class EWSType_IsGreaterThanOrEqualToType extends EWSType {

/**

* SearchExpression property

*

* @var EWSType_TwoOperandExpressionType

*/

public $SearchExpression;

/**

* Constructor

*/

public function __construct() {

$this->schema = array(

array(

'name' => 'SearchExpression',

'required' => false,

'type' => 'TwoOperandExpressionType',

),

); // end $this->schema

} // end function __construct()

} // end class IsGreaterThanOrEqualToType

标签:php,exchangewebservices,php-ews

来源: https://codeday.me/bug/20190902/1788620.html

php-ews发送邮件,使用php-ews在特定日期之后收到电子邮件(Exchange Web服务)相关推荐

  1. Exchange Web Service(EWS) 协议同步邮件

    Exchange Web Service(EWS) 协议 EWS是微软实现的一种客户端和服务器之间的交换信息的协议.Exchange Server提供了包括从电子邮件.会议安排.团体日程管理.任务管理 ...

  2. Java:ews-java-api获取Outlook/Exchange Web Services (EWS)会议日程

    文档 https://learn.microsoft.com/zh-cn/exchange/client-developer/exchange-server-development https://g ...

  3. R语言ggplot2时间序列可视化并在特定日期处添加竖线实战

    R语言ggplot2时间序列可视化并在特定日期处添加竖线实战 目录 R语言ggplot2时间序列可视化并在特定日期处添加竖线实战 #仿真数据</

  4. js计算距离特定日期多少周多少天

    特定日期:2022-1-1 今天是2022-1-3,则显示 3天 今天是2022-1-7,则显示 1周 今天是2022-1-8,则显示 1周 1天 <script>console.log( ...

  5. python使用_获取常用特定日期(如去年/季度/当月/上月/本周/首日等)

    通过datetime和dateutil进行常用日期的获取: 如: 今年,去年,明年 当前季度 本月,上月,去年同期,今年一月 今天,昨天,明天, 本周.本月.本季度.本年第一天, 本周.本月.本季度. ...

  6. R语言筛选dataframe中某一日期之后的数据集、特定日期之后的数据行

    R语言筛选dataframe中某一日期之后的数据集.特定日期之后的数据行 目录 R语言筛选dataframe中某一日期之后的数据集.特定日期之后的数据行

  7. android指定日期闹钟,如何在android中设置特定日期的闹钟?

    嗨我需要使用时间选择器来设置特定日期的闹钟.当我给出静态输入时,闹钟设置不正确并响铃. 例如:我给静态输入(与日期,月份和年份),但它不振铃.这是我的代码.如何在android中设置特定日期的闹钟? ...

  8. 根据特定日期生成date对象

    一直想写一篇关于js 日期类型date的文章 我们都知道 new Date() //没有任何参数,创建的对象自动获取当前日期 new Date(1535610732881); //如果我们想要根据特定 ...

  9. .NET CORE Microsoft.Exchange.WebServices EWS发送邮件

    使用Exchange服务发送邮件服务,主要是发附件,和嵌入式图片 首先NuGet   . .NetFrameWork   Microsoft.Exchange.WebServices .net Cor ...

最新文章

  1. 避不开的算法,如何吃透?
  2. html5 酒店入住插件,jQuery酒店类入住日期时间范围选择器插件
  3. python字典高级用法_Python 字典的高级用法
  4. ajax 上传读取excel
  5. 线程间通信之eventfd
  6. tcp总结与简单实现
  7. Wireshark实战分析之ARP协议(一)
  8. gogs 迁移外部仓库
  9. 无盘网吧服务器比单机快吗,锐起无盘网吧系统打造比有盘更快的速度
  10. Struts2——OGNL表达式
  11. java面经合集(面试遇到的)
  12. 八皇后问题 (25分)
  13. 卷积神经网络中的“池化层”
  14. linux翻页查看,【转载】linux-查看日志
  15. 20154322杨钦涵 Exp6 信息搜集与漏洞扫描
  16. ChatGPT 类大语言模型为什么会带来“神奇”的涌现能力?
  17. 用Python学习吴恩达机器学习——梯度下降算法理论篇
  18. 【51单片机】:智能台灯设计(自动、手动双模式)
  19. 模式识别与图像处理课程实验一:图像处理实验(颜色算子实验、Susan、Harris角点检测实验、 sobel边缘算子检测实验)
  20. java 数组取接近值_java – 获取数组中最接近的数值

热门文章

  1. ios php mysql实例_如何用PHP/MySQL为 iOS App 写一个简单的web服务器(译) PART1
  2. 亚马逊出的平板电脑_亚马逊推出新款平板电脑,售价90美元
  3. mysql架构 三级主从同步_MySQL 主从同步架构中你不知道的“坑”
  4. android关闭系统弹窗,Android 禁止 EditText 弹出软件盘
  5. md5 java .net_.net, java MD5 加密 互换
  6. qchart画完以后删除_身为宫廷画师,郎世宁为何要偷偷画乾隆的侧身像?跟一次惩罚有关...
  7. 图标,专业设计师基本素材要件
  8. 元宵节电商促销活动首页PSD分层模板
  9. UI设计灵感|这才是分享美图的正确姿势!
  10. 寻找设计独特标识LOGO的灵感?可编辑模板帮你轻松解决!