The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.
Microsoft365R is intended to be a simple yet powerful R interface to Microsoft 365 (formerly known as Office 365), leveraging the facilities provided by the AzureGraph package. Currently it supports Microsoft Teams, Outlook, SharePoint Online, and OneDrive.
The primary repo for this package is at
https://github.com/Azure/Microsoft365R; please submit issues and PRs
there. It is also mirrored at the Cloudyr org at
https://github.com/cloudyr/Microsoft365R. You can install the
development version of the package with
devtools::install_github("Azure/Microsoft365R")
.
The first time you call one of the Microsoft365R functions (see below), it will use your Internet browser to authenticate with Azure Active Directory, in a similar manner to other web apps. See app_registration.md for more details on the app registration and permissions requested. The “Authentication” vignette describes the authentication process in greater depth, including optional arguments and troubleshooting common problems.
Microsoft365R defines a number of top-level client functions to access the individual Microsoft 365 services. Below are some simple code examples that show how to use the package. For more information, see the vignettes for the individual services.
To access your personal OneDrive call
get_personal_onedrive()
, and to access OneDrive for
Business, call get_business_onedrive()
. These return an R6
client object of class ms_drive
, which has methods for
working with files and folders. `
<- get_personal_onedrive()
od <- get_business_onedrive()
odb
# list files and folders
$list_items()
od$list_items("Documents")
od
# upload and download files
$upload_file("somedata.xlsx")
od$download_file("Documents/myfile.docx")
od
# create a folder
$create_folder("Documents/newfolder")
od
# open a document for editing in Word Online
$open_item("Documents/myfile.docx")
od
# working with data frames and R objects
$save_dataframe(iris, "Documents/iris.csv")
od<- od$load_dataframe("Documents/iris.csv")
iris2
<- lm(wt ~ ., data=mtcars)
wtmod $save_rds(wtmod, "Documents/wtmod.rds")
od<- od$load_rds("Documents/wtmod.rds") wtmod2
To access a SharePoint site, use the
get_sharepoint_site()
function and provide the site name,
URL or ID. You can also list the sites you’re following with
list_sharepoint_sites()
.
list_sharepoint_sites()
<- get_sharepoint_site("My site")
site
# document libraries
$list_drives()
site
# default document library
<- site$get_drive()
drv
# a drive has the same methods as for OneDrive above
$list_items()
drv$open_item("teamproject/plan.xlsx")
drv
# lists
$get_lists()
site
<- site$get_list("my-list")
lst
# return the items in the list as a data frame
$list_items() lst
To access a team in Microsoft Teams, use the get_team()
function and provide the team name or ID. You can also list the teams
you’re in with list_teams()
. These return objects of R6
class ms_team
which has methods for working with channels;
in turn, a channel has methods for working with messages and
transferring files.
list_teams()
<- get_team("My team")
team
# associated SharePoint site and drive
$get_drive()
team$get_sharepoint_site()
team
# channels
$list_channels()
team
<- team$get_channel("General")
chan
# messages
$list_messages()
chan$send_message("Hello from R", attachments="hello.md")
chan
<- chan$get_message("msg-id")
msg $send_reply("Reply from R")
msg
# files: similar methods to OneDrive
$list_files()
chan$download_file("myfile.docx") chan
Microsoft365R supports sending, receiving and managing emails in
Outlook. Use the get_personal_outlook()
method to access
your emails for your personal account, and
get_business_outlook()
for your work or school account.
Emails can optionally be composed using either the blastula or emayili
packages.
<- get_personal_outlook()
outl <- get_business_outlook()
outlb
# compose an email with blastula
library(blastula)
<- "## Hello!
bl_body
This is an email message that was generated by the blastula package.
We can use **Markdown** formatting with the `md()` function.
Cheers,
The blastula team"
<- compose_email(
bl_em body=md(bl_body),
footer=md("sent via Microsoft365R")
)<- outl$create_email(bl_em, subject="Hello from R", to="bob@example.com")
em
# add an attachment and send it
$add_attachment("mydocument.docx")
em$send()
em
# list the most recent emails in your inbox
<- outl$list_emails()
emlst
# reply to the most recent email
1]]$
emlst[[create_reply("Replying from R")$
send()
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.