public void SaveHeader(LetterInfo letterInfo) { using (FileStream fileStream = new FileStream(_pathFileHeader, FileMode.OpenOrCreate)) { int idx = 0; int cnt = letterInfo.Count(); while (idx < cnt) { Letter letter = letterInfo.Item(idx); byte[] array = Encoding.UTF8.GetBytes(letter.LetterData.Header + Environment.NewLine); int offset = 0; int count = 1024; int countData = array.Length; while (offset < countData) { int value = countData - offset; if (value < count) { count = value; } fileStream.Write(array, offset, count); offset += count; } idx++; } } }
public void GetListLetters(LetterInfo letterInfo) { UsersResource.MessagesResource.ListRequest listRequest = _gmailService.Users.Messages.List(_authUserMail); foreach (var msgItm in listRequest.Execute().Messages) { Letter letter = new Letter(); letter.ID = msgItm.Id; letterInfo.Add(letter); } }
static void Main(string[] args) { Console.WriteLine("Запуск."); //Ожидание авторизации AuthorizationWebAsync().Wait(); if (_userCredential != null) { // Связь с сервисом GMail ConnectServiceGMail(); _letterInfo = new LetterInfo(); // Получение писем ReceivingLetters(); // Сохранение писем SaveLetter(); } Console.WriteLine("Завершение."); }