我如何向未在电子邮件 headers 中列出的收件人发送电子邮件(使用 EWS 或 office-js,或者使用 MS 堆栈模拟 SMTP)?
How can I originate emails to recipients NOT listed in email headers (using EWS or office-js, or maybe emulating SMTP using the MS stack)?
我的 add-in 进行“取证邮件”(所有电子邮件收件人都会收到难以察觉的不同隐写邮件 body 内容),以识别违反政策的行为(例如“泄密”)。例如这意味着发送电子邮件时:-
From: Person A
To: person B
Cc: person C
Bcc: person D
生成了 4 封不同的个人电子邮件(发件人“已发送”文件夹中的原始邮件,加上 3 个收件人中的每一个的新版本 = 总共 4 封)。
使用SMTP,设置合适的headers,每封邮件发送3次“RCPT TO”是一件简单的事情。
什么是 Office-JS 或 EWS 或任何其他可用的等效方式来使用“Microsoft 技术”来创建我的电子邮件?是否可以执行“SMTP over EWS”或类似的操作,这样我就可以 re-use 我现有的 (Linux) 代码库?
有什么方法可以指定“密件抄送”收件人以及“收件人:”和“抄送:”电子邮件 headers,然后将邮件传送给该密件抄送收件人 仅,模拟 SMTP ?
在 Outlook Web 加载项中,您需要使用 OfficeJS
方法和属性来设置收件人:
var item;
Office.initialize = function () {
item = Office.context.mailbox.item;
// Checks for the DOM to load using the jQuery ready function.
$(document).ready(function () {
// After the DOM is loaded, app-specific code can run.
// Set recipients of the composed item.
setRecipients();
});
}
// Set the display name and email addresses of the recipients of
// the composed item.
function setRecipients() {
// Local objects to point to recipients of either
// the appointment or message that is being composed.
// bccRecipients applies to only messages, not appointments.
var toRecipients, ccRecipients, bccRecipients;
// Verify if the composed item is an appointment or message.
if (item.itemType == Office.MailboxEnums.ItemType.Appointment) {
toRecipients = item.requiredAttendees;
ccRecipients = item.optionalAttendees;
}
else {
toRecipients = item.to;
ccRecipients = item.cc;
bccRecipients = item.bcc;
}
// Use asynchronous method setAsync to set each type of recipients
// of the composed item. Each time, this example passes a set of
// names and email addresses to set, and an anonymous
// callback function that doesn't take any parameters.
toRecipients.setAsync(
[{
"displayName":"Graham Durkin",
"emailAddress":"graham@contoso.com"
},
{
"displayName" : "Donnie Weinberg",
"emailAddress" : "donnie@contoso.com"
}],
function (asyncResult) {
if (asyncResult.status == Office.AsyncResultStatus.Failed){
write(asyncResult.error.message);
}
else {
// Async call to set to-recipients of the item completed.
}
}); // End to setAsync.
// Set any cc-recipients.
ccRecipients.setAsync(
[{
"displayName":"Perry Horning",
"emailAddress":"perry@contoso.com"
},
{
"displayName" : "Guy Montenegro",
"emailAddress" : "guy@contoso.com"
}],
function (asyncResult) {
if (asyncResult.status == Office.AsyncResultStatus.Failed){
write(asyncResult.error.message);
}
else {
// Async call to set cc-recipients of the item completed.
}
}); // End cc setAsync.
// If the item has the bcc field, i.e., item is message,
// set bcc-recipients.
if (bccRecipients) {
bccRecipients.setAsync(
[{
"displayName":"Lewis Cate",
"emailAddress":"lewis@contoso.com"
},
{
"displayName" : "Francisco Stitt",
"emailAddress" : "francisco@contoso.com"
}],
function (asyncResult) {
if (asyncResult.status == Office.AsyncResultStatus.Failed){
write(asyncResult.error.message);
}
else {
// Async call to set bcc-recipients of the item completed.
// Do whatever appropriate for your scenario.
}
}); // End bcc setAsync.
}
}
// Writes to a div with id='message' on the page.
function write(message){
document.getElementById('message').innerText += message;
}
调用 setAsync
时,以下列格式之一提供一个数组作为 recipients 参数的输入参数。
- 作为 SMTP 地址的字符串数组。
- 一个字典数组,每个字典包含一个显示名称和电子邮件地址,如以下代码示例所示。
- 一组
EmailAddressDetails
个对象,类似于 getAsync
方法返回的对象。
如果您不想覆盖约会或消息中的任何现有收件人,而不是使用 Recipients.setAsync
,您可以使用 Recipients.addAsync
异步方法来附加收件人。 addAsync
与 setAsync
的工作方式类似,因为它需要收件人输入参数。您可以选择提供回调方法,并使用 asyncContext
参数为回调提供任何参数。然后,您可以使用回调方法的 asyncResult
输出参数检查异步 addAsync
调用的状态、结果和任何错误。
在 Get, set, or add recipients when composing an appointment or message in Outlook 文章中阅读更多相关信息。
不,与 SMTP 不同,EWS、扩展 MAPI 和 Outlook 对象模型不允许您指定与实际接收邮件的收件人不同的收件人。
在这种情况下,SMTP 是您最好且唯一的选择。
我的 add-in 进行“取证邮件”(所有电子邮件收件人都会收到难以察觉的不同隐写邮件 body 内容),以识别违反政策的行为(例如“泄密”)。例如这意味着发送电子邮件时:-
From: Person A
To: person B
Cc: person C
Bcc: person D
生成了 4 封不同的个人电子邮件(发件人“已发送”文件夹中的原始邮件,加上 3 个收件人中的每一个的新版本 = 总共 4 封)。
使用SMTP,设置合适的headers,每封邮件发送3次“RCPT TO”是一件简单的事情。
什么是 Office-JS 或 EWS 或任何其他可用的等效方式来使用“Microsoft 技术”来创建我的电子邮件?是否可以执行“SMTP over EWS”或类似的操作,这样我就可以 re-use 我现有的 (Linux) 代码库?
有什么方法可以指定“密件抄送”收件人以及“收件人:”和“抄送:”电子邮件 headers,然后将邮件传送给该密件抄送收件人 仅,模拟 SMTP ?
在 Outlook Web 加载项中,您需要使用 OfficeJS
方法和属性来设置收件人:
var item;
Office.initialize = function () {
item = Office.context.mailbox.item;
// Checks for the DOM to load using the jQuery ready function.
$(document).ready(function () {
// After the DOM is loaded, app-specific code can run.
// Set recipients of the composed item.
setRecipients();
});
}
// Set the display name and email addresses of the recipients of
// the composed item.
function setRecipients() {
// Local objects to point to recipients of either
// the appointment or message that is being composed.
// bccRecipients applies to only messages, not appointments.
var toRecipients, ccRecipients, bccRecipients;
// Verify if the composed item is an appointment or message.
if (item.itemType == Office.MailboxEnums.ItemType.Appointment) {
toRecipients = item.requiredAttendees;
ccRecipients = item.optionalAttendees;
}
else {
toRecipients = item.to;
ccRecipients = item.cc;
bccRecipients = item.bcc;
}
// Use asynchronous method setAsync to set each type of recipients
// of the composed item. Each time, this example passes a set of
// names and email addresses to set, and an anonymous
// callback function that doesn't take any parameters.
toRecipients.setAsync(
[{
"displayName":"Graham Durkin",
"emailAddress":"graham@contoso.com"
},
{
"displayName" : "Donnie Weinberg",
"emailAddress" : "donnie@contoso.com"
}],
function (asyncResult) {
if (asyncResult.status == Office.AsyncResultStatus.Failed){
write(asyncResult.error.message);
}
else {
// Async call to set to-recipients of the item completed.
}
}); // End to setAsync.
// Set any cc-recipients.
ccRecipients.setAsync(
[{
"displayName":"Perry Horning",
"emailAddress":"perry@contoso.com"
},
{
"displayName" : "Guy Montenegro",
"emailAddress" : "guy@contoso.com"
}],
function (asyncResult) {
if (asyncResult.status == Office.AsyncResultStatus.Failed){
write(asyncResult.error.message);
}
else {
// Async call to set cc-recipients of the item completed.
}
}); // End cc setAsync.
// If the item has the bcc field, i.e., item is message,
// set bcc-recipients.
if (bccRecipients) {
bccRecipients.setAsync(
[{
"displayName":"Lewis Cate",
"emailAddress":"lewis@contoso.com"
},
{
"displayName" : "Francisco Stitt",
"emailAddress" : "francisco@contoso.com"
}],
function (asyncResult) {
if (asyncResult.status == Office.AsyncResultStatus.Failed){
write(asyncResult.error.message);
}
else {
// Async call to set bcc-recipients of the item completed.
// Do whatever appropriate for your scenario.
}
}); // End bcc setAsync.
}
}
// Writes to a div with id='message' on the page.
function write(message){
document.getElementById('message').innerText += message;
}
调用 setAsync
时,以下列格式之一提供一个数组作为 recipients 参数的输入参数。
- 作为 SMTP 地址的字符串数组。
- 一个字典数组,每个字典包含一个显示名称和电子邮件地址,如以下代码示例所示。
- 一组
EmailAddressDetails
个对象,类似于getAsync
方法返回的对象。
如果您不想覆盖约会或消息中的任何现有收件人,而不是使用 Recipients.setAsync
,您可以使用 Recipients.addAsync
异步方法来附加收件人。 addAsync
与 setAsync
的工作方式类似,因为它需要收件人输入参数。您可以选择提供回调方法,并使用 asyncContext
参数为回调提供任何参数。然后,您可以使用回调方法的 asyncResult
输出参数检查异步 addAsync
调用的状态、结果和任何错误。
在 Get, set, or add recipients when composing an appointment or message in Outlook 文章中阅读更多相关信息。
不,与 SMTP 不同,EWS、扩展 MAPI 和 Outlook 对象模型不允许您指定与实际接收邮件的收件人不同的收件人。
在这种情况下,SMTP 是您最好且唯一的选择。