Rocky Smolin
rockysmolin at bchacc.com
Mon Nov 8 11:40:00 CST 2010
________________________________ From: Rocky Smolin [mailto:rockysmolin at bchacc.com] Sent: Monday, November 08, 2010 9:12 AM To: 'Access Developers discussion and problem solving' Subject: FW: Getting Outlook Folder in VBA Reply from Helen Feddema regarding my inquiry about the Outlook Object. Rocky ________________________________ From: Helen Feddema [mailto:hfeddema at hvc.rr.com] Sent: Monday, November 08, 2010 9:00 AM To: 'Rocky Smolin' Subject: RE: Getting Outlook Folder in VBA The Outlook object model is indeed obscure and difficult to understand. See my Access Archon #67 article on it (from a few Office versions back, but still useful). Access Archon #102 shows how to store Outlook mail messages in an Access table. Also, my two most recent books have examples of exporting Access data to Outlook, or importing Outlook data into Access. http://www.helenfeddema.com/Files/accarch67.zip http://www.helenfeddema.com/Files/accarch102.zip Also check out the Code Samples page on my Website for a number of code samples dealing with Outlook: http://www.helenfeddema.com/CodeSamples.htm Here is info on the books: Access 2007 book Title: AccessT 2007 VBA Bible For Data-Centric Microsoft Applications Author: Helen Feddema Publisher: Wiley Publication Year: 2007 ISBN: 047004702X Description: As long-time AW readers know, data exchange among Office applications has always been one of my main interests, and that is the topic of this book. It covers using Access 2007 for data storage, entering, editing and printing data where Access does the job best, and exporting data to other Office applications (Word, Excel and Outlook) where they are best. One of the sample databases for this book finally achieves a long-time goal of mine: two-way synchronizing of Outlook and Access contacts, where the contact information is stored in a set of properly normalized, linked tables in Access. This lets you store all the information you need (or want) to store in Access tables - say, 30 phone numbers for Microsoft, or five addresses for a wealthy friend - while using the convenient and attractive Outlook interface to work with contacts. You can add or edit contact data in Access or Outlook, and synchronize contacts as needed (for those fields that are supported in Outlook), which gives you the best of both applications. The book also covers writing add-ins of several types (Access, VB 6, and Visual Studio), with tips on how to get them to work in Vista (more info on this topic was presented in Access Archon #162, based on information I got after the book went to press). Amazon link: http://www.amazon.com/exec/obidos/ISBN=047004702X/helenfeddemaswebA Access application development book Title: Expert One-on-One Microsoft Access Application Development Author: Helen Feddema Publisher: Wiley Publication Year: 2004 ISBN: 0-7645-5904-4 Description: This book is written for experienced Access users, who know how to create tables, queries, forms and other Access objects, and have some familiarity with writing Access VBA code, but need help in making the transition from an experienced and competent Access user who can create databases for personal use, to an Access developer who can make a living developing applications for clients. The book concentrates on this book writing VBA code to connect the components of a database into a functioning, coherent application. Amazon link: http://www.amazon.com/exec/obidos/ISBN=0764559044/helenfeddemaswebA ________________________________ From: Rocky Smolin [mailto:rockysmolin at bchacc.com] Sent: Monday, November 08, 2010 11:53 AM To: 'Helen Feddema' Subject: RE: Getting Outlook Folder in VBA Dear Ms. Feddema: Thank you so much for your prompt response. It was exactly what I needed and was able to effect the solution for my client in just a couple of minutes. And I agree with your opinion about storing the path so that it can be changed when the folder moves or if the app is installed on another machine where the name and/or path might be different. I'm recommending to my client that this enhancement be implemented in his system. Even on AccessD where there are some very Access knowledgeable people, the Outlook object model seems to be obscure. Do you know of a resource that would explain the model that I could pass to the group? Thanks again. With best regards, Rocky Smolin Beach Access Software 858-259-4334 Skype: rocky.smolin www.e-z-mrp.com <http://www.e-z-mrp.com/> www.bchacc.com <http://www.bchacc.com/> ________________________________ From: Helen Feddema [mailto:hfeddema at hvc.rr.com] Sent: Sunday, November 07, 2010 9:23 AM To: 'Rocky Smolin' Subject: RE: Getting Outlook Folder in VBA I am attaching a document with the syntax for referencing Outlook folders in various locations. However, there is another method you can use in this case, since (as I am sure you are aware, even if the client isn't) that it is not a good idea to hard-code paths. You can put an Outlook path selector on the main menu, using the PickFolder method to store the selected Outlook folder in a custom database property, and then retrieve it for use in code. That way, if the path needs to be changed at some point, it can be done by just selecting another folder on the main menu. See Access Archon #185 (attached) for a description of this method. ________________________________ From: Rocky Smolin [mailto:rockysmolin at bchacc.com] Sent: Sunday, November 07, 2010 10:08 AM To: hfeddema at hvc.rr.com Subject: Getting Outlook Folder in VBA Dear Ms. Feddema: I am trying to transfer data from an Access table to an Outlook contacts folder. I visited your site and was using one of your samples as a guide was able to do this. But then the client wanted to hard code the contact folder instead of using the .PickFolder method, but I cannot seem to get the syntax right to do this. I'm using: Dim olFolder As Outlook.MAPIFolder Dim olApplication As Outlook.Application Dim olNameSpace As Outlook.NameSpace Set olApplication = CreateObject("Outlook.Application") Set olNameSpace = olApplication.GetNamespace("MAPI") Set olFolder = olNameSpace.Folders("DocketWorks") The last line generates the error "The operation failed. An object could not be found." I tried the code posted at http://msdn.microsoft.com/en-us/library/bb177014%28v=office.12%29.aspx which seemed like an overly elaborate way to get the folder object set, but it also failed with the same error when setting the folder although another member of the AccessD list is using it successfully. So there's something amiss in my app. I would be grateful for any ideas you have to resolve this. Is there a syntax to set the folder object to a specific folder? the folder named "DocketWorks" is a sub folder to Contacts, and , ,as I say, using your .PickFolder method I can set the folder object and transfer the contacts. Many thanks in advance, Rocky Smolin Beach Access Software 858-259-4334 Skype: rocky.smolin www.e-z-mrp.com <http://www.e-z-mrp.com/> www.bchacc.com <http://www.bchacc.com/>