After downloading the attached email, the text is properly wrapped. However if left-clicking the attachment to preview, the text is not wrapped. And if you attach the file manually, the text will wrap in preview.
library(openxlsx2)
library(glue)
library(Microsoft365R)
.data <- structure(
list(
bldg = "5",
wo_num = "123421",
type = "BE",
category = "",
Description = "I am a description..............................................................................................................................................................................",
date = "02-22-24",
status = "S",
est_time = 1
),
row.names = c(NA, -1L),
class = c("tbl_df", "tbl", "data.frame")
)
wb_backlog <- function(.data) {
nm <- names(.data)
letter_desc <- letters[which(nm == "Description")] |> toupper()
letter_last <- letters[ncol(.data)] |> toupper()
wb_workbook() |>
wb_add_worksheet("Sheet1") |>
wb_add_data("Sheet1", .data) |>
wb_add_cell_style(
dims = glue("{letter_desc}2:{letter_desc}{nrow(.data) + 1}"),
wrap_text = "1"
) |>
wb_set_col_widths(cols = which(nm == "Description"), widths = 75)
}
wb <- .data |> wb_backlog()
## Text is wrapped
if (interactive()) wb |> wb_open()
tenant <- Sys.getenv("M365_TENANT")
app <- Sys.getenv("M365_APP")
user <- Sys.getenv("M365_USER")
pwd <- Sys.getenv("M365_KEY")
ol <- get_business_outlook(
tenant = tenant, app = app,
username = user, password = pwd,
auth_type = "resource_owner"
)
#> Loading Microsoft Graph login for tenant 'redacted'
file_1 <- tempfile(fileext = ".xlsx")
wb |> wb_save(file_1)
email <- ol$create_email(
subject = "Email subject",
to = "<your.email@gmail.com")$
add_attachment(file_1)
## Open email in Drafts
After downloading the attached email, the text is properly wrapped. However if left-clicking the attachment to preview, the text is not wrapped. And if you attach the file manually, the text will wrap in preview.
Created on 2024-03-12 with reprex v2.0.2