currently developping office add-in in javascript, notice differences in api usability between outlook windows rich client , office365 web portal.
my add-in works charm in "web" mode not expected in rich client.
the add-in fetches email body + attachments , sends remote app server.
office.context.mailbox.item.body.getasync(office.coerciontype.html, { asynccontext: "html" }, function callback(reshtml) { // dealing email in html format });
for attachments, i'm doing :
for (var = 0; < office.context.mailbox.item.attachments.length; i++) { var _att = office.context.mailbox.item.attachments[i]; attachments.assets.push({ name: _att.name, id: _att.id, contenttype: _att.contenttype, size: _att.size, attachmenttype: _att.attachmenttype, isinline: _att.isinline }); }
(the js add-in sends attachment meta-data remote app. remote app has connect exchange ews fetch attachments provided meta-data)
the issue
when there inlined images attached in email, web portal , rich client shows differently in output html :
web portal
<img originalsrc="cid:image004.png@01d18392.e4a15fe0" src="data:image/gif;base64,..." width="310" height="15" id="x__x0000_i1030" alt="...">
rich client
<img src="~wrs%7b0e0ffaa4-6fc0-49c1-9bb6-3d1a2f5211f1%7d_fichiers/image001.jpg" width=906 height=245 id="picture 6">
on other hand, method office.context.mailbox.item.attachments
returns kind of objects :
{ "_data$p$0": { "id": "aamkagi2mjy4mgq....", "name": "image004.png", "contenttype": "image/png", "size": 427, "attachmenttype": 0, "isinline": true } }
as pretty clear map inlined images names "cid:xyz" in html web portal, how supposed map them in rich client ?
little observation : attachment
js object says image image003.png
, <img>
tag image doesn't reflet @ , shows ~wrs...../image001.gif
. (filename not identicals, extensions mismatch)
thank :)
i've found workaround, post here in case faces same issue.
with js api, 1 can retrieve access token can furtherly used back-end side connect soap exchange web services (ews).
the access token retrievable via office.context.mailbox.getcallbacktokenasync
method
once token, itemid , ewsurl gathered , sent back-end, can use ews retrieve mail body either in plain text or full html inlined images correctly specified in html.
you'll receive <img src="cid:xyz@123" />
matchable attachment object retrieved.
bonus: when connecting ews, traditionally connect login/password couple. in case, don't know these credentials. http headers contains :
authorization: basic [credentials]
for authenticating ews via access token, have set follow :
authorization: bearer [accesstoken]
Comments
Post a Comment