示例#1
0
 public Account(AccountInfo info)
 {
     Info        = info;
     ActiveLabel = null;
     GmailImap   = new GmailImapClient(Info.Address, Info.Password);
     MailStorage = new MailStorage(Info.Address);
 }
示例#2
0
        public async Task LogoutAsync()
        {
            await GmailImap.Client.LogoutAsync();

            GmailImap.Dispose();
            GmailImap   = new GmailImapClient(Info.Address, Info.Password);
            ActiveLabel = null;
        }
示例#3
0
        static void Main(string[] args)
        {
            string username = "******";
            string password = "";

            try
            {
                using (var imap = new GmailImapClient(username, password))
                {
                    IList <GmailMessageInfo> messageInfos = imap.GetCurrentMessageIdsAsync(DateTime.Now - TimeSpan.FromDays(60)).Result;
                    foreach (var messageInfo in messageInfos)
                    {
                        imap.Client.GetBodyPartAsync(messageInfos.Select(ids => ids.Uid), true,
                                                     new[] { GConstants.MessageIdHeader, GConstants.ThreadIdHeader }, "1",
                                                     async(stream, size) =>
                        {
                            Console.WriteLine();
                        },
                                                     CancellationToken.None).Wait();

                        Console.WriteLine(messageInfo.ThreadId + " " + messageInfo.MessageId + " " + messageInfo.Flags + " " + messageInfo.Labels);
                    }
                }

                /*
                 * using (var smtp = new GmailSmtpClient(username, password))
                 * {
                 *  MailMessage message = new MailMessage();
                 *  message.From = new MailAddress(username);
                 *  message.To.Add(new MailAddress(username));
                 *  message.Cc.Add(new MailAddress(username));
                 *  message.Bcc.Add(new MailAddress(username));
                 *  message.Subject = "Test Message " + DateTime.Now;
                 *  message.ContentType = "text/plain";
                 *  message.Body = "This is a plain text message. It has a few new lines\r\nin it. It should also be long enough to go over the normal 72 character limit. Maybe.\r\nI should really add some special characters in here.";
                 *
                 *  smtp.SendAsync(message).Wait();
                 * }
                 */
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }