Dynamically find current user of outlook email

I have some code that multiple users use on a regular basis. Currently, when a new user runs the code, they have to manually change the email to their own email address. I was wondering if there was a quick (and easy) way of dynamically pulling their email address out of outlook?

For example, we are currently doing this:

active_email <- "some_user@outlookuser.com" # change this to your outlook email address

Does anyone know of a method of creating the 'active_email' object dynamically? Thanks for any assistance.

is there a predictable correspondence between a users email address and their system level username ?

Sys.getenv("Username")

Sadly no, the user and their email address can be entirely separate.

I think the natural approach would be to have the user record their details (i.e. define a correspondence between their system level username and their email address), and then your script can look up the username in a data.frame, and return the corresponding email address.

You could do it with a human readable two column csv.

Unfortunately I don't think that's going to work either. I think I'll need to use something like: OutApp$Session()$CurrentUser()

Though that doesn't return something useable.

Seems to work by using: outlookNameSpace$Accounts()$Item(1)$SmtpAddress()

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.