如何在发送邮件之前确保加载图像?我目前正在使用setTimeout()
功能提供更自然的聊天体验以及session.sendTyping()
。这也有点确保在发送之前正确构建消息,但我仍然有时会遇到未加载的图像。
图像托管在Azure文件中,并通过HTTP使用SAS密钥进行访问。
如图所示,该消息返回带有空白图像的英雄卡。'
更新:一些代码供参考
// The function returns a message object with either a Hero Card or a text string
function addImgToMsg(table) {
let msg = new builder.Message(session);
let mainCard = new builder.HeroCard(session);
// Check if the given DB entry has an image link
if (table.img) {
mainCard.images([
builder.CardImage.create(session, 'link_to_my_image')
]);
}
// Attach the Hero Card to the message if has gotten any content
if (mainCard.data.content.images) {
msg.attachmentLayout(builder.AttachmentLayout.carousel);
msg.attachments([mainCard]);
} else {
msg.text('No was image provided.')
}
return msg;
}