outlook

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

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

Go to latest
Published: Nov 7, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

README

OutlookMessenger

Simple go package for app-only messaging system

Quickstart

package main

import (
	"fmt"
	"log"

	outlook "github.com/spironan/outlookmessenger"
)

func main() {
	// set up app-only microsoft azure configuration
	config := outlook.Config{
		ClientID:     "exampleClientID",
		TenantID:     "exampleTenantID",
		ClientSecret: "exampleClientSecret",
	}
	// Initialize outlook messenger
	messenger := NewOutlookMessenger(config)
	// Compose Email
	email := outlook.OutlookEmail{
		Sender:     "sender@outlook.com",
		Subject:    "Title of email",
		MailType:   outlook.TEXT_BODYTYPE,
		Body:       "This is a sample email",
		Recipients: {"recipient1@outlook.com", "recipient2@gmail.com", "recipient3@hotmail.com"},
	}
	// Send Email
	err := messenger.SendMail(email)
	if err != nil {
		log.Panicf(err)
	}

	// Debug log access token
	token, err := outlookMessenger.GetAppToken()
	if err != nil {
		log.Panicf("Error getting user token: %v\n", err)
	}

	fmt.Printf("App-only token: %s\n", *token)
	fmt.Println()
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DisplayAccessToken

func DisplayAccessToken(outlookMessenger *OutlookMessenger)

Types

type BodyType

type BodyType int
const (
	TEXT_BODYTYPE BodyType = iota
	HTML_BODYTYPE
)

type Config

type Config struct {
	ClientID     string
	TenantID     string
	ClientSecret string
}

Config holds the configuration for OutlookMessenger

type OutlookEmail

type OutlookEmail struct {
	Sender     string
	Subject    string
	MailType   BodyType
	Body       string
	Recipients []string
}

type OutlookMessenger

type OutlookMessenger struct {
	// contains filtered or unexported fields
}

func NewOutlookMessenger

func NewOutlookMessenger(config Config) *OutlookMessenger

func (*OutlookMessenger) GetAppToken

func (g *OutlookMessenger) GetAppToken() (*string, error)

func (*OutlookMessenger) SendMail

func (g *OutlookMessenger) SendMail(mail OutlookEmail) error

Jump to

Keyboard shortcuts

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