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> TryGetMessagesAsync() { var messages = await EmailSnippets.GetMessagesAsync(); return(messages != null); }