Search…
Sending Emails
Email notifications utility
There is nothing simpler than sending email notifications using SharePoint REST and Gosip Fluent API. However, when building workflow workers or custom subscription services email functionality is vital. And what can be better than embedded OOTB functionality? No extra knowledge of SMTP server and mail credentials, just a usual API call to _api/SP.Utilities.Utility.SendEmail utility endpoint.
There are some limitations to this method:
  • recipients only from the site
  • impossibility to change the sender
  • no attachments
but as embedded solution it's OK. And probably sort of workflow notification service should stay in such margins anyways.

Sending email notification

1
user, err := sp.Web().SiteUsers().
2
GetByEmail("[email protected]").Get()
3
​
4
if err != nil {
5
log.Fatal(err)
6
}
7
​
8
if err := sp.Utility().SendEmail(&api.EmailProps{
9
Subject: "Say hi to Gosip!",
10
Body: "Text or HTML body here...",
11
To: []string{user.Data().Email},
12
}); err != nil {
13
log.Fatal(err)
14
}
Copied!
Send email utility is not sophisticated but it works and enough for an embedded functionality.
Export as PDF
Copy link