Exchange Web Service client for golang, base on mhewedy/ews , if you feel useful,please give me a star, and if you find some bug, please send a issue or pull a request, thanks.
- fixed some bug about
NTLM(updateChangegithub.com/Azure/go-ntlmssppackage versiongithub.com/Azure/go-ntlmssptogithub.com/vadimi/go-http-ntlm/v2,becausego-ntlmssphas so many bugs....). - fixed some service not support
HTTP1.1,but go will useHTTP2.0if our service URL isHTTPS(AfterGo 1.6,See THIS). - Add support for email with Attachment.
- Using strategy like ews-java-api deal with email with attachment.which is save the mail content and subject,than save mail attachment,finally send the mail we saved.(Because ews-java-api project comment said, see below)
// Bug E14:80316 -- If the message has attachments, save as a
// draft (and add attachments) before sending.- Inline Attachment - like picture in email body.
- Support html email body with inline attachment.
- Support Mail CC and BCC.
package main
import (
"fmt"
"github.com/johnchenkzy/ews"
"github.com/johnchenkzy/ews/ewsutil"
"log"
)
func main() {
conf := ews.GetDefaultConfig()
c := ews.NewClient(
"https://outlook.office365.com/EWS/Exchange.asmx",
"email@exchangedomain",
"password",
&conf,
)
email := ewsutil.Email{
To: "[email protected]",
Cc: "[email protected]",
Bcc: "[email protected]",
Attachments: []string {"./path/to/file1", "./path/to/file2"},
Subject: "An email subject",
Body: "The email body, as plain text",
BodyType: ewsutil.BodyTypeText,
}
return ewsutil.SendEmails(client, email)
}Note: if you are using an on-premises Exchange server (or even if you manage your servers at the cloud), you need to pass the username as
AD_DOMAINNAME\usernameinstead, for examleMYCOMANY\mhewedy.
| Category | Operation | Supported* |
|---|---|---|
| eDiscovery operations | ||
| Exchange mailbox data operations | ||
| CreateItem operation | ✔️ (Email & Calendar & Attachment) | |
| GetUserPhoto | ✔️ | |
| CreateAttachment operation | FileAttachment | ✔️ |
| FileInlineAttachment | ✔️ | |
| Availability operations | ||
| GetUserAvailability | ✔️ | |
| GetRoomLists | ✔️ | |
| Bulk transfer operations | ||
| Delegate management operations | ||
| Inbox rules operations | ||
| Mail app management operations | ||
| Mail tips operation | ||
| Message tracking operations | ||
| Notification operations | ||
| Persona operations | ||
| FindPeople | ✔️ | |
| GetPersona | ✔️ | |
| Retention policy operation | ||
| Service configuration operation | ||
| Sharing operations | ||
| Synchronization operations | ||
| Time zone operation | ||
| Unified Messaging operations | ||
| Unified Contact Store operations | ||
| User configuration operations |
- Not always 100% of fields are mapped.
Besides the operations supported above, few new operations under the namespace ewsutil has been introduced:
ewsutil.SendEmailewsutil.CreateEventewsutil.ListUsersEventsewsutil.FindPeopleewsutil.GetUserPhotoewsutil.GetUserPhotoBase64ewsutil.GetUserPhotoURLewsutil.GetPersona
NTLM is supported as well as Basic authentication