问题描述
我正在尝试为Outlook Windows应用程序创建一个加载项。 以下代码应将电子邮件正文复制到剪贴板,但不会这样做。 我需要按两次“运行”按钮才能复制内容,但是我需要从第一次复制内容! 我的代码有什么问题?
var messageBody = "";
export async function run() {
Office.context.mailBox.item.body.getAsync(
Office.CoercionType.Text,function (asyncResult) {
if (asyncResult.status !== Office.AsyncResultStatus.Succeeded) {
messageBody = asyncResult.error;
} else {
messageBody = asyncResult.value;
}
});
copyToClipboard(messageBody)
}
function copyToClipboard(text) {
var copyhelper = document.createElement("input");
copyhelper.className = 'copyhelper'
document.body.appendChild(copyhelper);
copyhelper.value = text;
copyhelper.select();
document.execCommand("copy");
document.body.removeChild(copyhelper);
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)