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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Outlook 2010 Gmail Inbox Access

Status
Not open for further replies.

WIREMESH

Programmer
Mar 15, 2004
109
US
I wrote a program several years ago that reads the Outlook inbox and processes the emails. Using Outlook 2010, I am downloading email from a gmail account. Instead of placing the email in the main INBOX, the email is placed in an inbox under the gmail account. (I actually prefer the emails in a separate inbox.)

For instance if the gmail account is abc@gmail.com I see abc@gmail.com on the left sidebar of Outlook with it's own inbox and all of the email I want to access.

How can I programmatically get to these emails?
I tried the code below, but it only display the main "inbox" and "deleted" folders.
&& SAMPLE CODE
Local loapp, lospace

loapp = Createobject('Outlook.Application')
lospace = loapp.GetNameSpace('MAPI')
FOR i = 1 TO lospace.Folders(1).Folders.Count
WAIT WINDOW Upper(lospace.Folders(1).Folders(i).Name)
endfor

 
Try this:

Code:
loapp   = Createobject('Outlook.Application')
lospace = loapp.GetNameSpace('MAPI')
loInbox = loSpace.GetDefaultFolder(6)
loGmail = loInbox.Folders("Gmail")
  && Change Gmail in the above to the name of 
  && your Gmail folder within the Inbox folder

I haven't tested this, but I think it's broadly correct.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Thanks Mike. However, after entering the proper gmail name that did not work.

I get error "The attempted operation failed... An object could be found"

 
Wiremesh,

I was assuming that the Gmail folder is a sub-folder of the inbox. Is that the case?

If so, you could try looping through all the inbox sub-folders, looking at the names of each of them. You could do that with FOR .. EACH, or simply look at each one in turn:

Code:
....
? loInbox.Folders(1).Name
? loInbox.Folders(2).Name
&& etc.

Once you have the name of the folder, you should be able to plug it into the original code I gave you.

But I'm not sure about this. I've never done it myself. But it does seem like it should work.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Here is what I have learned,

Prior to Outlook 2010 all email was store in the same Outlook.PST file, and as a result, appeared in a single inbox.

In Outlook 2010, (possibly as a result of using IMAP) the default for all email accounts is to use a separate file. I believe the GetDefaultFolder(6) does not work because the emails are stored in another file.

Accessing this new file directly would be my first choice.

That said, there is a way using the manual settings to tell Outlook to use the default Outlook PST file for the gmail account. The problem I am having with this, is configuring Outlook 2010 to work with POP3 settings.
 
Using the settings from the page below, I was able to configure Pop3:


As a result, all of my gmail email is in the default inbox. I should be able to use my old code without change.

What an experience.

Thanks to everyone for their help. The VFP community is still 1st in my heart.
 
You'll need to iterate through the Outlook Accounts collection such as:

? lospace.Accounts.Item(1).DisplayName

and retrieve the folders for each account.

The Outlook object model is (depending on your POV) either robust or overcomplicated. You'll probably get your best answer from a newsgroup or board dedicated to Outlook automation.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top