goews

package module
v0.0.0-...-a5e7a2d Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2023 License: MIT Imports: 11 Imported by: 0

README

GO-EWS

golang library for interacion with EWS Exchange Web Service

Elements

All elements from EWS elements has been described and are accessible! (to the ReadMe update time=, and there are several shortcomings))

Operations

Some operations from EWS operations has been described and are accessible!. 100% of fields are mapped.

But you can use all of operation, which you need by the interaction with elements. Example

Described operations
  • GetFolder
  • FindItem
  • FindPeople
  • CreteItem

Usage

some usable examples you can find in Examples folder in this example you can create draft with operation(in examples you can find how to do anything without predefined operation)

package main

import (
    "fmt"
    "os"

    goews "github.com/beorereleverion/go-ews"
    "github.com/beorereleverion/go-ews/elements"
    log "github.com/sirupsen/logrus"
)

var (
    url, user, password string
)

func main() {
    setOSEnvs()
    client := goews.NewClient(url, user, password, goews.Config{
        Dump:    true,
        NTLM:    true,
        SkipTLS: false,
    })
    createItemResponse, err := client.CreateItem(&elements.CreateItem{
        MessageDisposition: getPTR("SendAndSaveCopy"),
        Items: &elements.ItemsNonEmptyArrayOfAllItemsType{
            Message: &elements.Message{
                
                ItemClass: &elements.ItemClass{
                    TEXT: "IPM.Note",
                },
                Subject: &elements.Subject{
                    TEXT: "Project Action",
                },
                Body: &elements.Body{
                    BodyType: getPTR("Text"),
                    TEXT:     "Priority - Update specification",
                },
                ToRecipients: &elements.ToRecipients{
                    Mailbox: &elements.Mailbox{
                        EmailAddress: &elements.EmailAddressNonEmptyStringType{
                            TEXT: "sschmidt@example.com",
                        },
                    },
                },
                IsRead: &elements.IsRead{
                    TEXT: false,
                },
            },
        },
        SavedItemFolderId: &elements.SavedItemFolderId{DistinguishedFolderId: &elements.DistinguishedFolderId{
            Id: getPTR(elements.DistinguishedFolderIddrafts),
        }},
    })
    if err != nil {
        panic(err)
    }
    fmt.Printf("%#v\n", createItemResponse)
}

func setOSEnvs() {
    url = os.Getenv("URL")
    if url == "" {
        log.Fatal("url can not be empty")
    }
    user = os.Getenv("USER")
    if user == "" {
        log.Fatal("user can not be empty")
    }
    password = os.Getenv("PASSWORD")
    if password == "" {
        log.Fatal("password can not be empty")
    }
}

func getPTR[T comparable](t T) *T {
    return &t
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewError

func NewError(resp *http.Response) error

Types

type Client

type Client interface {
	SendAndReceive(e Envelope) ([]byte, error)
	GetServerAddr() string
	GetUsername() string
	DoRequest(e Envelope, oe operations.Element) error
	FindPeople(eItem *elements.FindPeople) (*elements.FindPeopleResponse, error)
	GetFolder(eItem *elements.GetFolder) (*elements.GetFolderResponse, error)
	FindItem(eItem *elements.FindItem) (*elements.FindItemResponse, error)
	CreateItem(eItem *elements.CreateItem) (*elements.CreateItemResponse, error)
}

func NewClient

func NewClient(serverAddress, username, password string, config Config) Client

type Config

type Config struct {
	Dump    bool
	NTLM    bool
	SkipTLS bool
}

type Envelope

type Envelope interface {
	GetEnvelopeBytes() ([]byte, error)
}

type Fault

type Fault struct {
	Faultcode   string `xml:"faultcode"`
	Faultstring string `xml:"faultstring"`
	Detail      detail `xml:"detail"`
}

type HTTPError

type HTTPError struct {
	Status     string
	StatusCode int
}

func (HTTPError) Error

func (s HTTPError) Error() string

type SoapError

type SoapError struct {
	Fault *Fault
}

func (SoapError) Error

func (s SoapError) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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