public static Atom.Core.Collections.AtomEntryCollection geadGMailEmail(string username, string password) { // source found at https://app.box.com/shared/ka7j7n5bzm Atom.Core.Collections.AtomEntryCollection entries = null; WebRequest webRequestGetUrl; try { // Create a new web-request instance webRequestGetUrl = WebRequest.Create(_gmailServerUri); byte[] bytes = Encoding.ASCII.GetBytes(username + ":" + password); // Add the headers for basic authentication. webRequestGetUrl.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(bytes)); // Get the response feed Stream feedStream = webRequestGetUrl.GetResponse().GetResponseStream(); // Load Feed into Atom DLL Atom.Core.AtomFeed gmailFeed = Atom.Core.AtomFeed.Load(feedStream); //Atom.Core.Collections.AtomEntryCollection entries = gmailFeed.Entries; entries = gmailFeed.Entries; //if (entries.Count > 0) { //Console.WriteLine(string.Format("Found {0} email(s)", entries.Count)); //Console.WriteLine(Environment.NewLine); // Read the first email in the inbox only. // you can change this section to read all emails. //for (int i = 0; i < 1; i++) { // AtomEntry email = entries[i]; // Console.WriteLine("Brief details of the first Email in the inbox:"); // Console.WriteLine("Title: " + email.Title.Content); // Console.WriteLine("Author Name: " + email.Author.Name); // Console.WriteLine("Author Email: " + email.Author.Email); // Console.WriteLine(Environment.NewLine); // Console.WriteLine("Email Content: " + Environment.NewLine); // Console.WriteLine(email.Summary.Content); // Console.WriteLine(Environment.NewLine); // Console.WriteLine("Hit 'Enter' to exit"); // Console.ReadLine(); //} //} } catch (Exception ex) { } return(entries); }
/// <summary> /// Copies the entire <see cref="AtomEntryCollection"/> to a compatible one-dimensional <see cref="Array"/>, /// starting at the specified index of the target array. /// </summary> /// <param name="array">The one-dimensional <see cref="Array"/> that is the destination of the elements copied /// from <see cref="AtomEntryCollection"/>. The <see cref="Array"/> must have zero-based indexing. </param> /// <param name="index">The zero-based index in <i>array</i> at which copying begins.</param> public void CopyTo(AtomEntryCollection[] array, int index) { this.List.CopyTo(array, index); }