Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Retrieve Gmail Address Book 1

Status
Not open for further replies.

dstrange

Programmer
Nov 15, 2006
87
CA
Hi I very new to C#,

I got a small app working to send emails using my Gmail account. Is there a way I can connect to my Gmail address book and populate the addresses into a combo box? Much appreciated.
 
Are you using an API to connect to google email or are you just using a browser object?

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Which API?

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
This is all the working code I have. Right now the recipiant is hardcoded within the program. I was gonna update it to have it reference a text box but figure filling a combo box with my gmail contacts is a better way. I just don't know how to go about it. Sorry for the newbieness.

Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Email_GUI
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string subject = txtSubject.Text;
            string message = txtMessage.Text;
            //bool MyBool = true;

            if (subject == "" )
            {
                subject = "From Dave";
            }

            if (message == "" )
            {
                message  = "Just saying hi";
            }

            System.Net.Mail.MailMessage MyMailMessage = new System.Net.Mail.MailMessage("my.email@gmail.com", "recipiant@gmail.com", subject , message); //sender, recipiant, subject,msg
            MyMailMessage.IsBodyHtml = false;
            System.Net.NetworkCredential mailAuthentication = new
            System.Net.NetworkCredential("my.email@gmail.com", "Gmail password");
            System.Net.Mail.SmtpClient mailClient = new System.Net.Mail.SmtpClient("smtp.gmail.com", 587);
            mailClient.EnableSsl = true;
            mailClient.UseDefaultCredentials = false;
            mailClient.Credentials = mailAuthentication;
            mailClient.Send(MyMailMessage);
            Console.ReadLine();
        }
    }
}
 
I am making an application using the google Calendar API and the C# is very well written, so far, I can get all the entries in all of the calendars, eventually i plan to make my program sync my winmo 5 phone with the cal, and eventually contacts
 
Go to code.google.com and check out the .net api's
 
I do not think that SMTP support retrieving addresses from the server. Google Mail recently started supporting IMap and I believe you would be able to see the address book via IMap.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
I did some digging last night about the gmail address book and they have yet to release the API for it, it seems as thought it is being asked for alot
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top