Thanks. This was very helpful. I followed the link and ended up downloading the library and sample app from DotNetOpenAuth, and got that working on my machine. But I don't see how to get from their sample to my requirements.
The sample app uses a googleConsumerKey and googleConsumerSecret to retrieve the first 5 contacts from my address book. However, in my app, I need to change the From address to one of the addresses in the address book. Simply retrieving the name and e-mail address is not sufficient.
You mentioned that I need to get a 3-legged OAuth token for the From address and use it to authenticate to
smtp.gmail.com. Here is the code in the sample app for getting the token:
protected void Page_Load(object sender, EventArgs e) {
if (this.TokenManager != null) {
this.MultiView1.ActiveViewIndex = 1;
if (!IsPostBack) {
var google = new WebConsumer(GoogleConsumer.ServiceDescription, this.TokenManager);
// Is Google calling back with authorization?
var accessTokenResponse = google.ProcessUserAuthorization();
if (accessTokenResponse != null) {
this.AccessToken = accessTokenResponse.AccessToken;
} else if (this.AccessToken == null) {
// If we don't yet have access, immediately request it.
GoogleConsumer.RequestAuthorization(google, GoogleConsumer.Applications.Contacts);
}
}
}
}
Is this a 3-legged token? If so, how do I integrate this with the SMTP client in my previous code listing?
Thanks.
--dan