Skip to content

Commit

Permalink
Inline image fix (#158)
Browse files Browse the repository at this point in the history
fixes #107
  • Loading branch information
hongooi73 committed May 23, 2023
1 parent f9303c1 commit abad2c4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 6 additions & 3 deletions R/make_email_attachments.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand All @@ -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")
}
}
Expand Down

0 comments on commit abad2c4

Please sign in to comment.