diff --git a/GmailAPIHelper/GmailHelper.cs b/GmailAPIHelper/GmailHelper.cs index 62cdfe7..9e61b1b 100644 --- a/GmailAPIHelper/GmailHelper.cs +++ b/GmailAPIHelper/GmailHelper.cs @@ -24,6 +24,7 @@ public static class GmailHelper private static List _scopes; private static string _applicationName; private const string _tokenFile = "token.json"; + private const string _labelUnread = "UNREAD"; /// /// 'Token Path Type' enum. @@ -198,7 +199,7 @@ public static Message GetMessage(this GmailService gmailService, string query, b requiredLatestMessage = messageRequest.Execute(); if (markRead) { - var labelToRemove = new List { "UNREAD" }; + var labelToRemove = new List { _labelUnread }; service.RemoveLabels(requiredLatestMessage.Id, labelToRemove, userId: userId); } } @@ -245,7 +246,7 @@ public static List GetMessages(this GmailService gmailService, string q messages.Add(currentMessage); if (markRead) { - var labelToRemove = new List { "UNREAD" }; + var labelToRemove = new List { _labelUnread }; service.RemoveLabels(message.Id, labelToRemove, userId: userId); } } @@ -313,7 +314,7 @@ public static string GetLatestMessage(this GmailService gmailService, string que requiredMessage = Encoding.UTF8.GetString(data); if (markRead) { - var labelToRemove = new List { "UNREAD" }; + var labelToRemove = new List { _labelUnread }; service.RemoveLabels(latestMessage.Id, labelToRemove, userId: userId); } } @@ -968,7 +969,7 @@ public static bool MarkMessageAsRead(this GmailService gmailService, string quer { var mods = new ModifyMessageRequest { - RemoveLabelIds = new List { "UNREAD" } + RemoveLabelIds = new List { _labelUnread } }; var service = gmailService; List result = new List(); @@ -1020,7 +1021,7 @@ public static int MarkMessagesAsRead(this GmailService gmailService, string quer { var mods = new ModifyMessageRequest { - RemoveLabelIds = new List { "UNREAD" } + RemoveLabelIds = new List { _labelUnread } }; int counter = 0; var service = gmailService; @@ -1057,7 +1058,7 @@ public static bool MarkMessageAsUnread(this GmailService gmailService, string qu { var mods = new ModifyMessageRequest { - AddLabelIds = new List { "UNREAD" } + AddLabelIds = new List { _labelUnread } }; var service = gmailService; List result = new List(); @@ -1109,7 +1110,7 @@ public static int MarkMessagesAsUnread(this GmailService gmailService, string qu { var mods = new ModifyMessageRequest { - AddLabelIds = new List { "UNREAD" } + AddLabelIds = new List { _labelUnread } }; int counter = 0; var service = gmailService;