diff --git a/NEWS.md b/NEWS.md index 4648ddf..a831591 100644 --- a/NEWS.md +++ b/NEWS.md @@ -10,6 +10,7 @@ ## Outlook - Fix a bug in specifying multiple addresses in an email (#134, #151). +- Fix multiple inline images not showing up in emails (#107). Many thanks to @vorpalvorpal. # Microsoft365R 2.3.4 diff --git a/R/make_email_attachments.R b/R/make_email_attachments.R index f90be31..17baa46 100644 --- a/R/make_email_attachments.R +++ b/R/make_email_attachments.R @@ -19,7 +19,8 @@ add_external_attachments.blastula_message <- function(object, email) body <- list( `@odata.type`="#microsoft.graph.fileAttachment", contentBytes=object$images[[i]], - name=names(object$images)[1], + contentId=names(object$images)[[i]], + name=names(object$images)[[i]], contentType=attr(object$images[[i]], "content_type"), isInline=TRUE ) @@ -45,14 +46,16 @@ add_external_attachments.envelope <- function(object, email) warning("File attachments from emayili > 3MB not currently supported; will be skipped", call.=FALSE) next } + + name_a <- unclass(gsub('"', "", sub("^.+filename=", "", a$disposition))) att <- list( `@odata.type`="#microsoft.graph.fileAttachment", isInline=FALSE, contentBytes=openssl::base64_encode(a$content), - name=unclass(gsub('"', "", sub("^.+filename=", "", a$disposition))), + contentId=name_a, + name=name_a, contentType=unclass(sub(";.+$", "", a$type)) ) - # print(att) email$do_operation("attachments", body=att, http_verb="POST") } }