Exemplo n.º 1
0
        /// <summary>Gets the mail content asynchronous.</summary>
        /// <param name="mailId">The mail identifier.</param>
        /// <returns></returns>
        public async Task <MailContent> GetMailContentAsync(string mailId)
        {
            var mailContent = new MailContent();
            var ms          = new MemoryStream(
                Encoding.UTF8.GetBytes(await GetResponseString($"/mail.api.php?mailid={mailId}")));
            var ser = new DataContractJsonSerializer(mailContent.GetType());

            mailContent = ser.ReadObject(ms) as MailContent;
            ms.Close();
            return(mailContent);
        }
Exemplo n.º 2
0
        /// <summary>Gets the emails asynchronous.</summary>
        /// <returns></returns>
        public async Task <List <MailContent> > GetEmailsAsync()
        {
            var response = await GetMailResponseAsync();

            var mails = new MailContent[response.MailList.Count];

            for (var i = 0; i < response.MailList.Count; i++)
            {
                mails[i] = await GetMailContentAsync(response.MailList[i].MailId);
            }

            return(mails.ToList());
        }