首页 > 解决方案 > 带有 Graph API 的 Outlook Web 插件 - 将当前项目作为 Outlook 项目附件发送时不显示内联图像

问题描述

我可以将我当前的项目作为附件发送,但我遇到了一个问题,如果我当前的项目中有任何内嵌图像,当我打开我的当前项目作为我新发送的附件时,这些不会正确显示/收到的邮件。我知道在将我的原始电子邮件作为附件发送后,图像 src 不正确,但我不确定如何纠正这个问题,或者这是否是预期的行为,因为我错过了一些东西。

我的目标是将我当前出现的项目/电子邮件作为 Outlook 项目转发到收件人邮箱。

我想知道我如何设置我发布到 Graph API 以发送邮件的 json 是否有错误?我会把它贴在下面,以防万一设置错误。提前致谢!

  var email = client.api('/me/messages/' + restID).get();

    var attachments = client.api('/me/messages/' + restID + '/attachments').get()

    const sendMail = {
        message: {
            subject:  'This contains my original email',// forwardMailSubject,
            body: {
                contentType: "Text",
                content: 'Test' // forwardMailBody
            },
            toRecipients: [
                {
                    emailAddress: {
                        address: 'test12321@outlook.com' //forwardMailbox
                    }
                }
            ],
            attachments: [
                {
                    '@odata.type': "#microsoft.graph.itemAttachment",
                    'name': "attachment",
                    'contentType': "html",
                    'item': {
                        "@odata.type": "#microsoft.graph.message",
                        "id": email.id,
                        "createdDateTime": email.createdDateTime,
                        "lastModifiedDateTime": email.lastModifiedDateTime,
                        "receivedDateTime": email.receivedDateTime,
                        "sentDateTime": email.sentDateTime,
                        "hasAttachments": true,
                        "internetMessageId": email.internetMessageId,
                        "subject": "Reminder - please bring laptop",
                        "importance": "normal",
                        "conversationId": email.conversationId,
                        "isDeliveryReceiptRequested": false,
                        "isReadReceiptRequested": false,
                        "isRead": false,
                        "isDraft": false,
                        "webLink": email.webLink,
                        "body": email.body,
                        "sender": email.sender,
                        "from": email.from,
                        "toRecipients": email.toRecipients,
                        "attachments": attachments
                    }
                }
            ]
        }
    };

    client.api('/me/sendMail')
        .post(sendMail);

标签: javascriptmicrosoft-graph-apioutlook-web-addins

解决方案


推荐阅读