This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get the messages | |
MessageCollectionResponse messages = graphClient.me().messages().get(); | |
// Instantiate collection to store all messgaes | |
List<Message> messagesList = new LinkedList<Message>(); | |
// Configure iterator | |
PageIterator iterator = new PageIterator.Builder<Message, MessageCollectionResponse>() | |
.client(graphClient) | |
.collectionPage(messages) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
messagesIds := [100]string{"messageId2", "messageId2"} // collection of message ids | |
batchCollection := msgraphgocore.NewBatchRequestCollection(client.GetAdapter()) | |
for _, messageId := range messagesIds { | |
deleteReq, err := client.Me().MailFolders().ByMailFolderId("Inbox").Messages().ByMessageId(messageId).ToDeleteRequestInformation(context.Background(), nil) | |
if err != nil { | |
return err | |
} | |
_, err = batchCollection.AddBatchRequestStep(*deleteReq) | |
if err != nil { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
meRequest, err := client.Me().ToGetRequestInformation(context.Background(), nil) | |
if err != nil { | |
return err | |
} | |
mePhoto, err := client.Me().Photo().ToGetRequestInformation(context.Background(), nil) | |
if err != nil { | |
return err | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scopes := []string{"Mail.Read", "Mail.Send", "User.Read"} | |
// Create the device code credential | |
credential, _ := azidentity.NewDeviceCodeCredential(&azidentity.DeviceCodeCredentialOptions{ | |
ClientID: "app_id", | |
TenantID: "tenant_id", | |
UserPrompt: func(ctx context.Context, message azidentity.DeviceCodeMessage) error { | |
fmt.Println(message.Message) | |
return nil | |
}, | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
result, _ := g.userClient.Me().Messages().Get(context.Background(), &requestConfiguration) | |
// Initialize iterator | |
pageIterator, _ := msgraphcore.NewPageIterator[models.Message](result, g.userClient.GetAdapter(), models.CreateMessageCollectionResponseFromDiscriminatorValue) | |
// Any custom headers sent in original request should also be added | |
// to the iterator | |
pageIterator.SetHeaders(headers) | |
// Iterate over all pages |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ( | |
"context" | |
"fmt" | |
"log" | |
"os" | |
"strings" | |
"github.com/Azure/azure-sdk-for-go/sdk/azidentity" | |
auth "github.com/microsoft/kiota-authentication-azure-go" | |
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ( | |
"context" | |
"fmt" | |
"log" | |
"github.com/Azure/azure-sdk-for-go/sdk/azidentity" | |
auth "github.com/microsoft/kiota-authentication-azure-go" | |
msgraphbeta "github.com/microsoftgraph/msgraph-beta-sdk-go" | |
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
messages, err := client.Me().MailFolders().ByMailFolderId("Inbox").Messages().Get(context.Background(), nil) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (g *GraphHelper) SendMail() error { | |
message := models.NewMessage() | |
subject := "Meet for lunch?" | |
content := "The new cafeteria is open." | |
body := models.NewItemBody() | |
message.SetSubject(&subject) | |
message.SetBody(body) | |
contentType := models.TEXT_BODYTYPE | |
body.SetContentType(&contentType) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//var message = .... | |
//var saveToSentItems = ... | |
var body = new SendMailPostRequestBody | |
{ | |
Message = message, | |
SaveToSentItems = saveToSentItems | |
}; | |
await graphServiceClient.Me | |
.SendMail //method SendMail |