Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Excel email attachment does not show wrapped text in preview #203

Open
asadow opened this issue Mar 12, 2024 · 0 comments
Open

Excel email attachment does not show wrapped text in preview #203

asadow opened this issue Mar 12, 2024 · 0 comments

Comments

@asadow
Copy link

asadow commented Mar 12, 2024

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 = "<[email protected]")$
  add_attachment(file_1)

## Open email in Drafts

Created on 2024-03-12 with reprex v2.0.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant