We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

I am trying Apose.Email a try - GMail contacts and Google Calendar

OK I have downloaded and working with Aspose.Email - it seems the library only exposes the Email.Tests features - how do I get it to work on all features in my VB code?

Thanks.

I have the the Import Aspose.Email declaration.


Dim client As IGmailClient = Aspose.Email.Google.GmailClient.GetInstance(user.ClientId, user.ClientSecret, user.RefreshToken)

Would only show…

Dim client As IGmailClient = Aspose.Email.Tests… xxxxxx

Hi,

Thank you for your interest in Aspose.

Aspose.Email for .NET does support working with Google Mail items that also include working with GMail Contacts and Calendars. You can try the full version of the API without evaluation limitations by getting a 30-day temporary license free of cost.

kevho:
it seems the library only exposes the Email.Tests
features - how do I get it to work on all features in my VB code?


The evaluation version includes Aspose.Email.Google namespace for working with Gmail. Please follow installation instructions mentioned here to add a reference to Aspose.Email. Also, please see attached sample project which includes the required reference for Aspose.Email and demonstrates accessing Gmail contacts in VB.NET.

Please let us know if you have any further query in this regard.
Hi Maria, with reference to your sample code,

Where do I input my API credentials (client_id, client_secrets etc) Would I need to construct an OAuth to obtain the access token before I can go further?

Hmm…I don’t see much comprehensive Gmail VB.Net sample codes in your Github (https:// github.com/aspose-email/Aspose.Email-for-.NET 2) and your programming guide seems a little short on Gmail.

Anyway, I think Apose.Email should help my work do I just purchased it and working with more sample codes…

Now I get Error Code 400 Invaild Request…at the last line of these codes - “CreateContact”. Please help. Many thanks in advance.

Dim username As String = “username” '<- some fake name, is that ok?
Dim email As String = "ccccr@gmail.com" '<- a user gmail account
Dim password As String = “Jd0ssdq3i” '<- a user’s gmail password
Dim clientId As String = “xxxxxgpuk2enokkf46hat8t3lh7us6iorcpib.apps.googleusercontent.com” '<- from my Google API manager
Dim clientSecret As String = “1XDQrrt6hZGYyuGQp4FXLnyf”
Dim refresh_token As String = “no-idea-it-is-refreshed-anyway” '<- this gets refreshed right? so just input some rubbish to start with?


’ I kind of prepared a class “GoogleTestUser” from your samples
Dim user As New GoogleTestUser(username, email, password, clientId, clientSecret, refresh_token)

’ Gmail Client
Dim client As IGmailClient = Aspose.Email.Google.GmailClient.GetInstance(user.ClientId, user.ClientSecret, user.RefreshToken, user.EMail)

’ Create a Contact
Dim contact As New Contact()
contact.Prefix = “Prefix”
contact.GivenName = “GivenName”
contact.Surname = “Surname”
contact.MiddleName = “MiddleName”
contact.DisplayName = “Test User 1”
contact.Suffix = “Suffix”
contact.JobTitle = “JobTitle”
contact.DepartmentName = “DepartmentName”
contact.CompanyName = “CompanyName”
contact.Profession = “Profession”
contact.Notes = “Notes”
Dim address As New PostalAddress()
address.Category = PostalAddressCategory.Work
address.Address = “Address”
address.Street = “Street”
address.PostOfficeBox = “PostOfficeBox”
address.City = “City”
address.StateOrProvince = “StateOrProvince”
address.PostalCode = “PostalCode”
address.Country = “Country”
contact.PhysicalAddresses.Add(address)
Dim pnWork As New PhoneNumber()
pnWork.Number = “323423423423”
pnWork.Category = PhoneNumberCategory.Work
contact.PhoneNumbers.Add(pnWork)
Dim pnHome As New PhoneNumber()
pnHome.Number = “323423423423”
pnHome.Category = PhoneNumberCategory.Home
contact.PhoneNumbers.Add(pnHome)
Dim pnMobile As New PhoneNumber()
pnMobile.Number = “323423423423”
pnMobile.Category = PhoneNumberCategory.Mobile
contact.PhoneNumbers.Add(pnMobile)
contact.Urls.Blog = “Blog.ru”
contact.Urls.BusinessHomePage = “BusinessHomePage.ru”
contact.Urls.HomePage = “HomePage.ru”
contact.Urls.Profile = “Profile.ru”
contact.Events.Birthday = DateTime.Now.AddYears(-30)
contact.Events.Anniversary = DateTime.Now.AddYears(-10)
contact.InstantMessengers.AIM = “AIM”
contact.InstantMessengers.GoogleTalk = “GoogleTalk”
contact.InstantMessengers.ICQ = “ICQ”
contact.InstantMessengers.Jabber = “Jabber”
contact.InstantMessengers.MSN = “MSN”
contact.InstantMessengers.QQ = “QQ”
contact.InstantMessengers.Skype = “Skype”
contact.InstantMessengers.Yahoo = “Yahoo”
contact.AssociatedPersons.Spouse = “Spouse”
contact.AssociatedPersons.Sister = “Sister”
contact.AssociatedPersons.Relative = “Relative”
contact.AssociatedPersons.ReferredBy = “ReferredBy”
contact.AssociatedPersons.Partner = “Partner”
contact.AssociatedPersons.Parent = “Parent”
contact.AssociatedPersons.Mother = “Mother”
contact.AssociatedPersons.Manager = “Manager”

’ Email Address
Dim eAddress As New EmailAddress()
eAddress.Address = "email@gmail.com"
contact.EmailAddresses.Add(eAddress)
Dim contactUri As String = client.CreateContact(contact)

Hi,

Thank you for your feedback.

GmailClient.GetInstance method of the API expects a valid refresh token for connecting to Gmail and the API does not generates access or refresh tokens internally. You can generate access token or a refresh token as per needed and use the relevant overload of GmailClient.GetInstance to connect to Gmail. Please see attached project that generates access and refresh tokens using the GoogleOAuthHelper class mentioned as part of our docs. The attached project also includes code sample to create a contact in Gmail.

For further code samples, please refer to our documentation and let us know if you need assistance with them.

Hi,


I do not see the GoogleOAuthHelper class in the attached project. There is an error when it runs. Please help.


Hi,

Sorry for the wrong attachment. Please see attached.

Cool, that’s OK. I see it! I am going over the codes…let me see.

Good news! I can get the “OAuth 2.0 authorization information”!!


…and all good, contacts were created (initially I did not see them as the new Google Contact Web interface is a little confusing - the ‘Other Contacts’ group did not show by default)

Thank you for your help.