/// <summary>
        /// show users message
        /// </summary>
        /// <param name="service"></param>
        /// <param name="request"></param>
        public List <Email> ShowUserMessage(GmailService service, string emailFolder, UsersResource.MessagesResource.ListRequest request, int amount)
        {
            List <Message> messages;

            if (amount == 0)
            {
                messages = ApiClient.GetListOfAllMessages(service, emailFolder);
            }
            else
            {
                var list = ApiClient.GetListOfSomeMessages(service, emailFolder, amount);
                messages = list.OfType <Message>().ToList();
            }
            List <Email> emailList = new List <Email>();

            if (messages != null && messages.Count > 0)
            {
                foreach (var sms in messages)
                {
                    var message = ApiClient.GetMessage(service, "me", sms.Id);
                    var email   = new ApiEmail(message);
                    emailList.Add(email);
                    ApiClient.GetAttachments(service, message, "me", sms.Id, true);
                }
            }
            return(emailList);
        }
        public void SaveAsType(FolderType emailFolder, int[] ids, string folderPath, string type)
        {
            var             emailFolderStr = emailFolder.ToString("f").ToUpper();
            IList <Message> messages       = ApiClient.GetListOfSomeMessages(service, emailFolderStr, ids[ids.Length - 1] + 1);

            if (messages != null && messages.Count > 0)
            {
                int j = 0;
                for (int i = 0; i < messages.Count; ++i)
                {
                    if (i == ids[j])
                    {
                        ++j;
                        var message = ApiClient.GetMessage(service, "me", messages[i].Id);
                        var email   = new ApiEmail(message);
                        var attac   = ApiClient.GetAttachments(service, message, "me", messages[i].Id, false);
                        switch (type)
                        {
                        case ".eml":
                            ApiClient.ConverteToEml(email, attac, folderPath);
                            break;

                        case ".msg":
                            ApiClient.ConverteToMsg(email, attac, folderPath);
                            break;
                        }
                    }
                }
            }
        }
        public void SaveAsType(FolderType emailFolder, int amount, string folderPath, string type)
        {
            var            emailFolderStr = emailFolder.ToString("f").ToUpper();
            List <Message> messages;

            if (amount == 0)
            {
                messages = ApiClient.GetListOfAllMessages(service, emailFolderStr);
            }
            else
            {
                var list = ApiClient.GetListOfSomeMessages(service, emailFolderStr, amount);
                messages = list.OfType <Message>().ToList();
            }
            if (messages != null && messages.Count > 0)
            {
                Parallel.ForEach(messages, (sms) =>
                {
                    var message = ApiClient.GetMessage(service, "me", sms.Id);
                    var email   = new ApiEmail(message);
                    var attac   = ApiClient.GetAttachments(service, message, "me", sms.Id, false);
                    switch (type)
                    {
                    case ".eml":
                        ApiClient.ConverteToEml(email, attac, folderPath);
                        break;

                    case ".msg":
                        ApiClient.ConverteToMsg(email, attac, folderPath);
                        break;
                    }
                });
            }
        }