OOF 回复的字体

Font of OOF Replies

我目前正在开发 Outlook 加载项。此加载项编辑已登录 Outlook 用户的 OOF 设置。我必须从 .oft 文件中获取外部消息的文本。
加载项 运行 正常,一切正常。字体只有一个小问题。我想将两个回复的字体更改为我们公司的标准,但我看不到实现它的方法。

有没有办法改变字体?

您可以获取要更改的项目,然后更新它,如outlined here。您需要做的是获取邮件的 Body-属性,然后更改此正文中的 <body>-标签:

// As a best practice, limit the properties returned to only those that are required.
PropertySet propSet = new PropertySet(BasePropertySet.IdOnly, ItemSchema.Body);

// Bind to the existing item by using the ItemId.
// This method call results in a GetItem call to EWS.
Item item = Item.Bind(service, itemId, propSet);

// item.Body.value = "<html><body> Example body </body></html>"

// Update the style of the mail's body.
item.Body.value = "<html><body style='font-family: Arial'> Example body </body></html>"

// Save the updated email.
// This method call results in an UpdateItem call to EWS.
item.Update(ConflictResolutionMode.AlwaysOverwrite);

Body.Html 允许您指定强制转换类型。在这里你可以指定HTML并为正文中的文本添加样式。
例如:

Office.context.mailbox.item.body.setAsync(
  "<p style=\"font-family: 'Arial Black', 'Arial Bold', Gadget, sans-serif;\">text</p>",
  { coercionType:"html"},
  function callback(result) {
    // Process the result
  });

供参考:https://dev.outlook.com/reference/add-ins/Body.html

感谢您的帮助!
最简单的方法是将 html 标记添加到我用于 OofReply 对象的字符串中。像这样:string message = "<html><div style='font-size:11pt; font-family:Calibri;'>" + template.body + "</div></html>";