private IList <IMailAttachment> GetAttachmentsFromMessage() { var attachments = new List <IMailAttachment>(); if (Message?.Payload.Parts == null) { return(attachments); } var attachmentParts = Message.Payload.Parts.Where(x => !string.IsNullOrEmpty(x.Filename)); attachments.AddRange(attachmentParts.Select(part => new MailAttachment { Data = _client.GetAttachmentBytes(Message.Id, part.Body.AttachmentId), ContentType = part.MimeType, FileName = part.Filename })); return(attachments); }