public static async Task <bool> TryReplyMessageAsync() { // Create a draft message and then send it. If you send the message without first creating a draft, you can't easily retrieve // the message Id. var newMessageId = await EmailSnippets.CreateDraftAndSendAsync( STORY_DATA_IDENTIFIER, DEFAULT_MESSAGE_BODY, AuthenticationHelper.LoggedInUserEmail ); if (newMessageId == null) { return(false); } // Find the sent message. var sentMessageId = await GetSentMessageIdAsync(); if (String.IsNullOrEmpty(sentMessageId)) { return(false); } // Reply to the message. bool isReplied = await EmailSnippets.ReplyMessageAsync( sentMessageId, DEFAULT_MESSAGE_BODY); return(isReplied); }
public static async Task <bool> TryGetMessageWebLinkAsync() { // Create a draft message and send it. var newMessageId = await EmailSnippets.CreateDraftAndSendAsync( STORY_DATA_IDENTIFIER, DEFAULT_MESSAGE_BODY, AuthenticationHelper.LoggedInUserEmail ); if (newMessageId == null) { return(false); } // Find the sent message. var sentMessageId = await GetSentMessageIdAsync(); if (String.IsNullOrEmpty(sentMessageId)) { return(false); } var webLink = await EmailSnippets.GetMessageWebLinkAsync(sentMessageId); if (String.IsNullOrEmpty(webLink)) { return(false); } return(true); }
public static async Task <bool> TryGetFileAttachmentsAsync() { var newMessageId = await EmailSnippets.CreateDraftAsync( STORY_DATA_IDENTIFIER, DEFAULT_MESSAGE_BODY, AuthenticationHelper.LoggedInUserEmail ); if (newMessageId == null) { return(false); } await EmailSnippets.AddFileAttachmentAsync(newMessageId, new MemoryStream(Encoding.UTF8.GetBytes("TryAddMailAttachmentAsync"))); // Find the sent message. var sentMessageId = await GetSentMessageIdAsync(); if (String.IsNullOrEmpty(sentMessageId)) { return(false); } await EmailSnippets.GetFileAttachmentsAsync(sentMessageId); return(true); }
public static async Task <bool> TryDeleteMailFolderAsync() { var folderId = await EmailSnippets.CreateMailFolderAsync("Inbox", "FolderToDelete"); var isFolderDeleted = await EmailSnippets.DeleteMailFolderAsync(folderId); return(isFolderDeleted); }
public static async Task <bool> TrySendMessageAsync() { bool isSent = await EmailSnippets.SendMessageAsync( STORY_DATA_IDENTIFIER, DEFAULT_MESSAGE_BODY, AuthenticationHelper.LoggedInUserEmail ); return(isSent); }
public static async Task <bool> TryCreateMailFolderAsync() { var folderId = await EmailSnippets.CreateMailFolderAsync("Inbox", "FolderToDelete"); if (!string.IsNullOrEmpty(folderId)) { //Cleanup await EmailSnippets.DeleteMailFolderAsync(folderId); return(true); } return(false); }
public static async Task <bool> TryMoveMailFolderAsync() { var folderId = await EmailSnippets.CreateMailFolderAsync("Inbox", "FolderToDelete"); if (!string.IsNullOrEmpty(folderId)) { bool isFolderMoved = await EmailSnippets.MoveMailFolderAsync(folderId, "Drafts"); //Cleanup await EmailSnippets.DeleteMailFolderAsync(folderId); return(isFolderMoved); } return(false); }
public static async Task <bool> TryGetMailFoldersAsync() { // The example gets the Inbox and its siblings. var foldersResults = await EmailSnippets.GetMailFoldersAsync(); foreach (var folder in foldersResults.CurrentPage) { if ((folder.DisplayName == "Inbox") || (folder.DisplayName == "Drafts") || (folder.DisplayName == "DeletedItems") || (folder.DisplayName == "SentItems")) { return(true); } } return(false); }
public static async Task <bool> TryCreateDraftAsync() { // Create the draft message. var newMessageId = await EmailSnippets.CreateDraftAsync( STORY_DATA_IDENTIFIER, DEFAULT_MESSAGE_BODY, AuthenticationHelper.LoggedInUserEmail ); if (newMessageId == null) { return(false); } //Cleanup await EmailSnippets.DeleteMessageAsync(newMessageId); return(true); }
public static async Task <bool> TryDeleteMessageAsync() { // Create a draft message. If you send the message without first creating a draft, you can't easily retrieve the message Id. var newMessageId = await EmailSnippets.CreateDraftAsync( STORY_DATA_IDENTIFIER, DEFAULT_MESSAGE_BODY, AuthenticationHelper.LoggedInUserEmail ); if (newMessageId == null) { return(false); } // Delete the message. var isDeleted = await EmailSnippets.DeleteMessageAsync(newMessageId); return(isDeleted); }
private static async Task <string> GetSentMessageIdAsync() { // Search for a maximum of 10 times for (int i = 0; i < 10; i++) { var message = await EmailSnippets.GetMessagesAsync(STORY_DATA_IDENTIFIER , DateTimeOffset.Now.Subtract(new TimeSpan(0, 1, 0))); if (message != null) { return(message.Id); } // Delay before trying again. Increase this value if you connection to the server // is slow and causes false results. await Task.Delay(200); } // Couldn't find the sent message return(string.Empty); }
public static async Task <bool> TryAddFileAttachmentAsync() { var newMessageId = await EmailSnippets.CreateDraftAsync( STORY_DATA_IDENTIFIER, DEFAULT_MESSAGE_BODY, AuthenticationHelper.LoggedInUserEmail ); if (newMessageId == null) { return(false); } // Pass a MemoryStream object for the sake of simplicity. using (MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes("TryAddMailAttachmentAsync"))) { await EmailSnippets.AddFileAttachmentAsync(newMessageId, ms); } return(true); }
public static async Task <bool> TryCopyMailFolderAsync() { var folderId = await EmailSnippets.CreateMailFolderAsync("Inbox", "FolderToCopyAndDelete"); if (!string.IsNullOrEmpty(folderId)) { string copiedFolderId = await EmailSnippets.CopyMailFolderAsync(folderId, "Drafts"); if (!string.IsNullOrEmpty(copiedFolderId)) { //Cleanup await EmailSnippets.DeleteMailFolderAsync(folderId); await EmailSnippets.DeleteMailFolderAsync(copiedFolderId); return(true); } } return(false); }
public static async Task <bool> TryUpdateMessageAsync() { // Create a draft message. If you send the message without first creating a draft, you can't easily retrieve the message Id. var newMessageId = await EmailSnippets.CreateDraftAsync( STORY_DATA_IDENTIFIER, DEFAULT_MESSAGE_BODY, AuthenticationHelper.LoggedInUserEmail ); if (newMessageId == null) { return(false); } // Update the message. bool isUpdated = await EmailSnippets.UpdateMessageAsync( newMessageId, DEFAULT_MESSAGE_BODY); //Cleanup. Comment if you want to verify the update in your Drafts folder. await EmailSnippets.DeleteMessageAsync(newMessageId); return(isUpdated); }
public static async Task <bool> TryGetMessagesAsync() { var messages = await EmailSnippets.GetMessagesAsync(); return(messages != null); }
public static async Task <bool> TryGetOutlookClientAsync() { var exchangeClient = await EmailSnippets.GetOutlookClientAsync(); return(exchangeClient != null); }