Office.DelayDeliveryTime interface

通过 DelayDeliveryTime 对象,可以管理邮件的延迟传递日期和时间。

注解

[ API set: Mailbox 1.13 ]

最低权限级别读取项

适用的 Outlook 模式:撰写

方法

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

可选。 方法完成后,使用单个参数 asyncResult(即 Office.AsyncResult 对象)调用在 参数中callback传递的函数。 在 属性中 asyncResult.value 返回邮件的传递日期和时间。 如果尚未对邮件设置传递日期, 0 则改为返回 。

返回

void

注解

[ API set: Mailbox 1.13 ]

最低权限级别读取项

适用的 Outlook 模式:撰写

getAsync(callback)

获取邮件的传递日期和时间。

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

参数

callback

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

可选。 方法完成后,使用单个参数 asyncResult(即 Office.AsyncResult 对象)调用在 参数中callback传递的函数。 在 属性中 asyncResult.value 返回邮件的传递日期和时间。 如果尚未对邮件设置传递日期, 0 则改为返回 。

返回

void

注解

[ API set: Mailbox 1.13 ]

最低权限级别读取项

适用的 Outlook 模式:撰写

示例

// 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

可选。 方法完成后,使用单个参数 asyncResult(即 Office.AsyncResult 对象)调用在 参数中callback传递的函数。 asyncResult.error 属性中将提供遇到的所有错误。

返回

void

注解

[ API set: Mailbox 1.13 ]

最低权限级别读/写项

适用的 Outlook 模式:撰写

重要提示:当 用于计划消息的传递时 item.delayDeliveryTime.setAsync ,将在服务器上处理延迟。 这样即使 Outlook 客户端未运行,也可以发送邮件。 但是,正因如此,邮件不会显示在 “发件箱” 文件夹中,因此在选择“ 发送”后,你将无法编辑邮件或取消邮件传递。 发送邮件后,只能查看“ 已发送邮件” 文件夹中的 mesasge。 若要了解详细信息,请参阅 管理邮件的传递日期和时间。

错误

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

setAsync(datetime, callback)

设置邮件的传递日期和时间。

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

参数

datetime

Date

应发送消息的未来日期和时间。

callback

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

可选。 方法完成后,使用单个参数 asyncResult(即 Office.AsyncResult 对象)调用在 参数中callback传递的函数。 asyncResult.error 属性中将提供遇到的所有错误。

返回

void

注解

[ API set: Mailbox 1.13 ]

最低权限级别读/写项

适用的 Outlook 模式:撰写

重要提示:当 用于计划消息的传递时 item.delayDeliveryTime.setAsync ,将在服务器上处理延迟。 这样即使 Outlook 客户端未运行,也可以发送邮件。 但是,正因如此,邮件不会显示在 “发件箱” 文件夹中,因此在选择“ 发送”后,你将无法编辑邮件或取消邮件传递。 发送邮件后,只能查看“ 已发送邮件” 文件夹中的 mesasge。 若要了解详细信息,请参阅 管理邮件的传递日期和时间。

错误

  • 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.`);
    }
  });
}