Skip to content

Instantly share code, notes, and snippets.

@baywet
Last active November 29, 2021 17:49
Show Gist options
  • Save baywet/7b5696a6ccec6d2773fe44d1c3313bea to your computer and use it in GitHub Desktop.
Save baywet/7b5696a6ccec6d2773fe44d1c3313bea to your computer and use it in GitHub Desktop.
msgraph go sdk fluent api demo
// indexes into the users and message folders collections using the fluent style API to list out messages
client.UserById("[email protected]").MessageFoldersById("Inbox").Messages().Get(nil)
// sends a message using the models and the fluent style API POST method
requestBody := msgraphsdk.NewSendMailRequestBody()
message := msgraphsdk.NewMessage()
requestBody.SetMessage(message)
subject := "Meet for lunch?"
message.SetSubject(&subject)
body := msgraphsdk.NewItemBody()
message.SetBody(body)
contentType := "Text"
body.SetContentType(&contentType)
content := "The new cafeteria is open."
body.SetContent(&content)
recipient := msgraphsdk.NewRecipient()
emailAddress := msgraphsdk.NewEmailAddress()
address := "[email protected]"
emailAddress.SetAddress(&address)
recipient.SetEmailAddress(emailAddress)
message.SetToRecipients([]Recipient {
recipient,
}
options := &msgraphsdk.SendMailRequestBuilderPostOptions{
Body: requestBody,
}
gclientMe().SendMail().Post(options)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment