Thanks to visit codestin.com
Credit goes to github.com

Skip to content
/ ews Public
forked from andlabs/ews

Go package to send emails via Exchange using EWS instead of SMTP with support for CC, BCC, ReplyTo and attachments

License

Notifications You must be signed in to change notification settings

arawal/ews

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Golang wrapper for send email functionality with Exchange server via EWS

Credits: andlabs

Note: Currently only a single attachment is supported

Example usage

package main

import (
	"encoding/base64"
	"fmt"
	"io/ioutil"
	"log"

	"github.com/arawal/ews"
)

func main() {
	fileData, err := ioutil.ReadFile("sample.txt")
	fileEncoding := base64.StdEncoding.EncodeToString(fileData)

	var amd ews.AttachmentMetadata
	amd.Name = "some.txt"
	amd.Content = fileEncoding

	var email ews.EmailMetadata
	email.To = []string{"[email protected]", "[email protected]"}
	email.Subject = "sample"
	email.Body = "sample email body"
	email.Cc = []string{"[email protected]", "[email protected]"}
	email.Bcc = []string{"[email protected]", "[email protected]"}
	email.ReplyTo = "[email protected]"

	var creds ews.Credentials
	creds.Server = "https://outlook.office365.com/EWS/exchange.asmx"
	creds.Username = "yourusername"
	creds.Password = "yourpassword"

	resp, err := ews.SendEmailWithAttachment(creds, email, amd)
	fmt.Println(resp, err)
	return

	fileData, err = ioutil.ReadFile("sample.txt")
	if err != nil {
		log.Fatal(err)
	}

	fileEncoding = base64.StdEncoding.EncodeToString(fileData)
	fmt.Printf("File contents: %s", fileEncoding)
}

About

Go package to send emails via Exchange using EWS instead of SMTP with support for CC, BCC, ReplyTo and attachments

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%