Office.DelayDeliveryTime interface

DelayDeliveryTime 对象使您能够管理消息的延迟传递日期和时间。

方法

getAsync(options, callback)

获取消息的传递日期和时间。

getAsync(callback)

获取消息的传递日期和时间。

setAsync(datetime, options, callback)

设置消息的传递日期和时间。

setAsync(datetime, callback)

设置消息的传递日期和时间。

方法详细信息

getAsync(options, callback)

获取消息的传递日期和时间。

getAsync(options: Office.AsyncContextOptions, callback?: (asyncResult: Office.AsyncResult<Date | 0>) => void): void;

参数

options
Office.AsyncContextOptions

包含以下一个或多个属性的对象文本:- asyncContext:开发人员可以在回调函数中提供他们希望访问的任何对象。

callback

(asyncResult: Office.AsyncResult<Date | 0>) => void

可选。 当该方法完成时,将使用单个参数(一个对象)asyncResultOffice.AsyncResult调用传入参数的callback函数。 在属性中 asyncResult.value 返回消息的传递日期和时间。 如果尚未在邮件上设置送达日期, 0 则改为返回。

返回

void

注解

API 集:邮箱 1.13

最低权限级别读取项目

适用的 Outlook 模式:Compose

getAsync(callback)

获取消息的传递日期和时间。

getAsync(callback?: (asyncResult: Office.AsyncResult<Date | 0>) => void): void;

参数

callback

(asyncResult: Office.AsyncResult<Date | 0>) => void

可选。 当该方法完成时,将使用单个参数(一个对象)asyncResultOffice.AsyncResult调用传入参数的callback函数。 在属性中 asyncResult.value 返回消息的传递日期和时间。 如果尚未在邮件上设置送达日期, 0 则改为返回。

返回

void

注解

API 集:邮箱 1.13

最低权限级别读取项目

适用的 Outlook 模式:Compose

示例

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/delay-message-delivery.yaml

// This snippet gets the delivery date and time of a message.
Office.context.mailbox.item.delayDeliveryTime.getAsync((asyncResult) => {
  if (asyncResult.status === Office.AsyncResultStatus.Failed) {
    console.log(asyncResult.error.message);
    return;
  }

  const deliveryDate = asyncResult.value;
  if (deliveryDate === 0) {
    console.log("Your message will be delivered immediately when you select Send.");
  } else {
    const date = new Date(deliveryDate);
    console.log(`Message delivery date and time: ${date.toString()}`);
  }
});

setAsync(datetime, options, callback)

设置消息的传递日期和时间。

setAsync(datetime: Date, options: Office.AsyncContextOptions, callback?: (asyncResult: Office.AsyncResult<void>) => void): void;

参数

datetime

Date

未来应发送邮件的日期和时间。

options
Office.AsyncContextOptions

包含以下一个或多个属性的对象文本:- asyncContext:开发人员可以在回调函数中提供他们希望访问的任何对象。

callback

(asyncResult: Office.AsyncResult<void>) => void

可选。 当该方法完成时,将使用单个参数(一个对象)asyncResultOffice.AsyncResult调用传入参数的callback函数。 asyncResult.error 属性中将提供遇到的所有错误。

返回

void

注解

API 集:邮箱 1.13

最低权限级别读取/写入项目

适用的 Outlook 模式:Compose

重要说明

  • 当用于计划消息的传递时 item.delayDeliveryTime.setAsync ,在服务器上处理延迟。 这样,即使 Outlook 客户端未运行,也可以发送邮件。 在 Windows 上的经典 Outlook 中,邮件不会显示在发 件箱 文件夹中,因此选择“ 发送”后将无法编辑邮件或取消其发送。 只能从“ 已发送项目 ”文件夹查看邮件。 在 Outlook 网页版、Mac 和 Windows 上的新 Outlook 中,邮件将显示在“草稿”文件夹中,直到计划的送达时间。 当邮件位于“ 草稿” 文件夹中时,可以在发送前对其进行编辑。 要了解详细信息,请参阅 管理邮件的发送日期和时间。

  • 当前使用该loadItemByIdAsync方法加载的消息不支持此setAsync方法。 有关详细信息,请参阅 在多封邮件上激活 Outlook 加载项。

错误

  • InvalidFormatError - 指定数据对象的格式无效。

setAsync(datetime, callback)

设置消息的传递日期和时间。

setAsync(datetime: Date, callback?: (asyncResult: Office.AsyncResult<void>) => void): void;

参数

datetime

Date

未来应发送邮件的日期和时间。

callback

(asyncResult: Office.AsyncResult<void>) => void

可选。 当该方法完成时,将使用单个参数(一个对象)asyncResultOffice.AsyncResult调用传入参数的callback函数。 asyncResult.error 属性中将提供遇到的所有错误。

返回

void

注解

API 集:邮箱 1.13

最低权限级别读取/写入项目

适用的 Outlook 模式:Compose

重要说明

  • 当用于计划消息的传递时 item.delayDeliveryTime.setAsync ,在服务器上处理延迟。 这样,即使 Outlook 客户端未运行,也可以发送邮件。 在 Windows 上的经典 Outlook 中,邮件不会显示在发 件箱 文件夹中,因此选择“ 发送”后将无法编辑邮件或取消其发送。 只能从“ 已发送项目 ”文件夹查看邮件。 在 Outlook 网页版、Mac 和 Windows 上的新 Outlook 中,邮件将显示在“草稿”文件夹中,直到计划的送达时间。 当邮件位于“ 草稿” 文件夹中时,可以在发送前对其进行编辑。 要了解详细信息,请参阅 管理邮件的发送日期和时间。

  • 当前使用该loadItemByIdAsync方法加载的消息不支持此setAsync方法。 有关详细信息,请参阅 在多封邮件上激活 Outlook 加载项。

错误

  • InvalidFormatError - 指定数据对象的格式无效。

示例

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/delay-message-delivery.yaml

function setDeliveryDate(minutes) {
  // This snippet sets the delivery date and time of a message.
  const currentTime = new Date().getTime();
  const milliseconds = totalDelay * 60000;
  const timeDelay = new Date(currentTime + milliseconds);
  Office.context.mailbox.item.delayDeliveryTime.setAsync(timeDelay, (asyncResult) => {
    if (asyncResult.status === Office.AsyncResultStatus.Failed) {
      console.log(asyncResult.error.message);
      return;
    }

    if (minutes === 1440) {
      console.log(`Delayed delivery by an additional one day.`);
    } else {
      console.log(`Delayed delivery by an additional ${minutes} minutes.`);
    }
  });
}