outlook

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

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

Go to latest
Published: Feb 20, 2025 License: Apache-2.0 Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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
⌂ 换网址