如何获得“身体"?和“主题";扩展撰写UI时草稿的字段? [英] How to get the "body" and "subject" fields of a draft when extending compose UI?
问题描述
我们正在开发Gmail插件,其中我们扩展了撰写用户界面.
We are developing a Gmail Addon in which we extend the compose UI.
这扩展了撰写窗口,您可以在其中撰写电子邮件.
This extends the compose window in which you can compose your e-mail.
我们需要正在编写的消息的发件人",收件人",主题"和正文".
We need the 'From', 'To', 'Subject' and 'Body' of the message that is being composed.
可以像这样从Session对象中读取发件人"
The 'From' can be read from the Session object like this
var mySelf = Session.getEffectiveUser().getEmail();
可以从正在调用的函数的事件对象的draftMetadata中读取"To".
The 'To' can be read from the draftMetadata from the event object of the function being called.
function composeEmail(event) { console.log(event.draftMetadata.toRecipients); }
由于是composeTrigger,因此无法从函数的事件对象中读取主题"和正文".该参数包含以下对象:
The 'Subject' and 'Body' can't be read from the event object of the function since it is a composeTrigger. The argument contains these objects:
{
formInput = {},
clientPlatform = web,
formInputs = {},
parameters = {},
draftMetadata = {
toRecipients = [test @test.com],
subject = ,
bccRecipients = [],
ccRecipients = []
}
}
令我惊讶的是,主题键在那里但没有填写(是的,我确实输入了主题).
Surprisingly to me, the subject key is there but not being filled in (yes I did type in a subject).
问题:
如何在扩展的Composer UI中获取用户正在撰写的电子邮件的主题"和正文"?
How can I get the 'Subject' and 'Body' of the E-mail being composed by the user in the extended composer UI?
其他信息:
上下文触发操作包含以下对象作为事件对象:
The contextual trigger action contains the following object as event object:
{
clientPlatform = web,
messageMetadata = {
messageId = 16e agg7323451256989f68,
accessToken = AAGdOAawdaAOW8PWchmdawdk0N13STKnBPMAOXVjZVHyQMfAawdBtgEIrS6N8y5h2BOZnKFPlfsl5VBsyPiF7YiONOoP7XVjKZawdi - E6vI - jVU92dPmfj3RNmXfawdawdeaNMrXehAFLm
}
}
通过上下文触发器阅读电子邮件,将添加messageId
,可以在其中使用getBody
和getSubject
方法.
By reading an email through the contextual trigger a messageId
is being added in which the getBody
and getSubject
methods can be used.
推荐答案
到目前为止,撰写触发器事件"从不返回subject
字段的值.
As of now, the Compose Trigger Event never returns the value of the subject
field.
我已经在此处处填充了一个错误.单击★图标以关注此问题并获取更新.这也将有助于确定此问题的优先级.
I have filled a bug for this here. Click the ★ icon to follow this Issue and get updates. This will also help prioritize this Issue.
作为一种解决方法,您可以使用上下文触发器进行以下操作:
As a workaround, you can use the contextual trigger to:
- 获取
messageId
- 查找与该
messageId
相关联的草稿 - 通过他们的
draftId
获取草稿
- 从草稿上的
Headers
对象获取主题行.
- Get the
messageId
- Find drafts that have that
messageId
associated to them - Get the draft by their
draftId
- Fetch the subject line from the
Headers
object on the draft.
这仅适用于答复特定消息的草稿.
This only works on drafts that are replying to a specific message.
这篇关于如何获得“身体"?和“主题";扩展撰写UI时草稿的字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!