10

I would like to integrate the calendar from my outlook into my orgmode agenda.

I am looking for a solution with the following features

  • Should be implemented in elisp only, so that I can run this on any system that has emacs
  • Should use Microsoft Exchange EWS Webservices to retrieve the calendar items.
  • Should create an org file containing the items for a predefined period (i.e. next two weeks or similar...)
  • Should be compatible with Office 365

I found some solutions, that come close, but are not quite there.

  • The ews-orgmode solution (see https://github.com/kautsig/ews-orgmode). This is implemented in python and generates an org file. This is problematic, because this obviously requires a python implementation and a scheduling solution. This makes this hard to use across platforms (e.g. windows vs linux) and requires significant effort to set up.

  • excorporate (see https://github.com/emacsmirror/excorporate). This is implemented in elisp, but does not provide any orgmode integration. I can create a buffer containing the calendar entries for a specific date, but cannot integrate it into the org agenda, because the buffer is not persisted and I am not aware of any way to call excorporate on agenda creation (with a specific date or date range) and to show those entries in the agenda

Is there any way to achieve an exchange calendar integration into the agenda using excorporate or something similar?

bombadil
  • 547
  • 4
  • 13

1 Answers1

16

I solved this myself using excorporate. To activate and integrate excorporate I used the following configuration in my .spacemacs (since I am using spacemacs)

I added excorporate to dotspacemacs-additional-packages and added the following to the user-config section of .spacemacs

;; configure excorporate
;; allow opening the exchange calendar with 'e' from calendar 
(evil-define-key 'motion calendar-mode-map "e" #'exco-calendar-show-day)

(setq-default
 ;; configure email address and office 365 exchange server adddress for exchange web services
 excorporate-configuration
  (quote
   ("my.email@myorg.com" . "https://outlook.office365.com/EWS/Exchange.asmx"))
  ;; integrate emacs diary entries into org agenda
  org-agenda-include-diary t
  )

;; activate excorporate and request user/password to start connection
(excorporate)

;; enable the diary integration (i.e. write exchange calendar to emacs diary file -> ~/.emacs.d/diary must exist)
(excorporate-diary-enable)
(defun ab/agenda-update-diary ()
  "call excorporate to update the diary for today"
  (exco-diary-diary-advice (calendar-current-date) (calendar-current-date) #'message "diary updated"))

;; update the diary every time the org agenda is refreshed
(add-hook 'org-agenda-cleanup-fancy-diary-hook 'ab/agenda-update-diary )

With this configuration, the exchange calendar is added to the emacs diary and the diary is integrated into the orgmode agenda. The exchange calendar is update every time my agenda is refreshed.

Only the exchange calendar for today is added to the diary.

If I want to see the calendar for a different day, I use the calendar, navigate to the desired date and press 'e'. The appointment for that day are then displayed in a orgmode formatted buffer

The user and password for the exchange server is requested on emacs startup..

Zeta
  • 1,045
  • 9
  • 18
bombadil
  • 547
  • 4
  • 13
  • 1
    So this is a one-way connection, where you can see your Office 365 agenda in your local emacs - you cannot add new org mode events and sync them to the exchange server, correct? Thanks for sharing! – AstroFloyd May 29 '19 at 19:19
  • @bombadil: any idea how to efficiently retrieve meetings all the displayed date in org-mode agenda? – M. Toya Jul 01 '21 at 12:58
  • Excorporate does not work, when multi factor authentication is active. I am not using it anymore.. – bombadil May 12 '22 at 18:10