package module
v0.0.0-...-de2b8b9 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Feb 28, 2019 License: MIT Imports: 9 Imported by: 0



Read calendar information from an Exchange Server using Go. Forked from sgoertzen/xchango. Changed to use NTLM for authentication and how caller interacts with Exchange Client.


package main

import (


func main() {
	xchangconfig := xchango.ExchangeConfig{
		ExchangeUser: xchango.ExchangeUser{
			Domain:   "oz",
			Username: "big.kahuna",
			Password: "charge!",
		MaxFetchSize: 5,
		ExchangeURL:  "https://mail.oz.com/EWS/Exchange.asmx",

	xchang, err := xchango.NewExchangeClient(xchangconfig)
	if err != nil {
		log.Fatalf("%+v", err)

	cal, err := xchang.GetCalendar()
	if err != nil {
		log.Fatalf("%+v", err)

	appointments, err := xchang.GetAppointments(cal)
	if err != nil {
		log.Fatalf("%+v", err)

	newYork, err := time.LoadLocation("America/New_York")
	for _, appointment := range *appointments {
		log.Printf("APPOINTMENT %+v %+v\n", appointment.Start.In(newYork), appointment.Subject)




This section is empty.


This section is empty.


This section is empty.


type Appointment

type Appointment struct {
	ItemID         string
	ChangeKey      string
	Subject        string
	Cc             string
	To             string
	Start          time.Time
	End            time.Time
	IsAllDayEvent  bool
	Location       string
	MyResponseType string
	Organizer      string
	Body           string
	BodyType       string

type Body

type Body struct {
	BodyType string `xml:"BodyType,attr"`
	Body     string `xml:",chardata"`

type CalendarItem

type CalendarItem struct {
	ItemID         ItemID `xml:"ItemId"`
	Subject        string
	DisplayCc      string
	DisplayTo      string
	Start          string
	End            string
	IsAllDayEvent  bool
	Location       string
	MyResponseType string
	Organizer      Organizer
	Body           Body

type ExchangeCalendar

type ExchangeCalendar struct {
	Folderid  string
	Changekey string

ExchangeCalendar definition

type ExchangeClient

type ExchangeClient struct {
	// contains filtered or unexported fields

ExchangeClient the callers reference to us

func NewExchangeClient

func NewExchangeClient(config ExchangeConfig) (ec *ExchangeClient, err error)

NewExchangeClient creates a new ExchangeClient

func (*ExchangeClient) GetAppointments

func (ec *ExchangeClient) GetAppointments(cal *ExchangeCalendar) (appointments []Appointment, err error)

GetAppointments gets users appointments

func (*ExchangeClient) GetCalendar

func (ec *ExchangeClient) GetCalendar() (cal *ExchangeCalendar, err error)

GetCalendar gets the users exchange calendar folder

type ExchangeConfig

type ExchangeConfig struct {
	ExchangeURL   string
	MaxFetchSize  int
	LookAheadDays int

ExchangeConfig defines all the parameters for how we interact with the Exchange server

type ExchangeUser

type ExchangeUser struct {
	Username string
	Password string
	Domain   string

ExchangeUser defines the NTLM authentication parameters to connect to the Exchange server

type ItemID

type ItemID struct {
	ID        string `xml:"Id,attr"`
	ChangeKey string `xml:"ChangeKey,attr"`

type Mailbox

type Mailbox struct {
	Name string

type Organizer

type Organizer struct {
	Mailbox Mailbox

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL