+ Reply to Thread
Results 1 to 16 of 16

Retrieving Outlook folder using GetNamespace causing Runtime error

  1. #1
    Registered User
    Join Date
    12-19-2020
    Location
    San Francisco
    MS-Off Ver
    16
    Posts
    7

    Retrieving Outlook folder using GetNamespace causing Runtime error

    I have a macro that moves the currently selected email to a folder based on a keyword in the subject line matching a folder name. The macro extracts the keyword and then recursively descends the Outlook folder tree beginning with a "startFolder" which I manually define. The macro has been running just fine for months. Then the other day it stopped working.

    Please Login or Register  to view this content.
    ....

    Now the Set statement results in a runtime error:
    Runtime error ' -2147221233 (8004010f)':
    The attempted operation failed. An object could not be found.

    Again, this was working just fine, no changes. I exported the module and reimported just in case it was corrupted (that's solved other problems), but that did not work.
    Last edited by davesexcel; 12-20-2020 at 07:02 AM.

  2. #2
    Banned User!
    Join Date
    02-06-2020
    Location
    Iowa City, IA, USA
    MS-Off Ver
    2016 - 365 / 2007
    Posts
    2,014

    Re: Retrieving Outlook folder using GetNamespace causing Runtime error

    WHAT module? the entire PST? or the coding module? if you changed nothing, literally, and no ancillary stuff changed, like ANYTHING else that affects your outlook operations, syncing efforts, or anything else possibly related, then corruption makes perfect sense. office programs are notorious for causing it. but there *are* things wrong with ur code, that are completely redundant. why this?
    Please Login or Register  to view this content.
    why not just this?
    Please Login or Register  to view this content.
    you've post this in the outlook forum.

    if it's not corrupted, the error desc makes perfect sense:
    The attempted operation failed. An object could not be found.
    something in here can't be found:
    Please Login or Register  to view this content.
    what are all the ''x''s for? are you really searching for a subfolder 4 nestings deep?

    I've had numerous corrupted PST files over the years. I've used tools to fix them, if I remember right. when I found out how bad outlook really was, I started exporting them regularly because they were so unpredictable. check here:

    https://www.systoolsgroup.com/update...outlook-error/

    I couldn't find your error in MS's list either:

    https://docs.microsoft.com/en-us/off...error-messages

  3. #3
    Registered User
    Join Date
    12-19-2020
    Location
    San Francisco
    MS-Off Ver
    16
    Posts
    7

    Re: Retrieving Outlook folder using GetNamespace causing Runtime error

    Thanks for the prompt response.
    As you might have inferred, I'm not that skilled as a programmer--I more or less cobble together stuff that works based on what I can learn on the fly. Hence the redundancy.

    The code runs in Module1.

    The "xxx" are simply there to suppress the details of my email and business. Yes, I'm starting 4 levels down at "Projects" because that's where all of the emails are going to be stored. Within Projects there are 4 or 5 levels further down, with hundreds of folders. That's simply the nature of my business operations.

    Everything else in Outlook works. The other macros in this module work fine as well. Just this one.

  4. #4
    Registered User
    Join Date
    12-19-2020
    Location
    San Francisco
    MS-Off Ver
    16
    Posts
    7

    Re: Retrieving Outlook folder using GetNamespace causing Runtime error

    I've cleaned up the code per your comments. Here is main sub

    Please Login or Register  to view this content.
    One thing that I just discovered is this: When Set Namespace executes, the properties returned include:

    : AutoDiscoverConnectionMode : The attempted operation failed. An object could not be found. : OlAutoDiscoverConnectionMode

    As best as I understand it, this suggests a problem connecting with Microsoft Exchange Server?

    Also, the properties show

    : ExchangeStoreType : olNotExchange : OlExchangeStoreType

    and

    - : MAPIOBJECT : : Unsupported object type
    Last edited by davesexcel; 12-20-2020 at 07:02 AM.

  5. #5
    Banned User!
    Join Date
    02-06-2020
    Location
    Iowa City, IA, USA
    MS-Off Ver
    2016 - 365 / 2007
    Posts
    2,014

    Re: Retrieving Outlook folder using GetNamespace causing Runtime error

    the only way I can help you further is for you to upload the PST in a zip folder or something. you have only pointed out one issue. and I gave everything I could think of on that issue. sorry. one thing I would say is that, if you have millions of folders nested like you say, in a small program in outlook, you really need to find another warehousing space for your content. outlook is not designed as a large enterprise program, although MS says the word ""enterprise"" in all their offerings. that means nothing, to me anyway. outlook CAN do it, but given the unreliable nature of office products, my suggestion is a change.

  6. #6
    Registered User
    Join Date
    12-19-2020
    Location
    San Francisco
    MS-Off Ver
    16
    Posts
    7

    Re: Retrieving Outlook folder using GetNamespace causing Runtime error

    What precisely would you need in the PST? All folders?
    Again, thanks for your help here, much appreciated.

  7. #7
    Banned User!
    Join Date
    02-06-2020
    Location
    Iowa City, IA, USA
    MS-Off Ver
    2016 - 365 / 2007
    Posts
    2,014

    Re: Retrieving Outlook folder using GetNamespace causing Runtime error

    pretty much. give me the exact replica of what you're working with now. you don't have to include any of the email messages in them, as those are all exported out with the archive when you bundle everything together into a PST export. do you know how to write a short routine to strip all of that out of there? you don't really need to I suppose. really what I need more than anything is the architecture you are working with. by default, when you link OL to a server-based client of anything, like gmail, OL automatically creates 2 nestings of folders underneath 2 parent folders. one if apparently inherent to OL, and on is labeled as the client you are pulling email from. at least that's what I have always seen happen. as an example, I am showing you what I see in my OL. I have gmail linked to it. as you can see on the right side, it shows exactly what I have described.
    Attached Images Attached Images

  8. #8
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent SAC
    Posts
    8,885

    Re: Retrieving Outlook folder using GetNamespace causing Runtime error

    Quote Originally Posted by rrs711 View Post
    Now the Set statement results in a runtime error:
    There are two Set statements in the code you posted - which one causes the error?
    Rory

  9. #9
    Banned User!
    Join Date
    02-06-2020
    Location
    Iowa City, IA, USA
    MS-Off Ver
    2016 - 365 / 2007
    Posts
    2,014

    Re: Retrieving Outlook folder using GetNamespace causing Runtime error

    I couldn't possibly think it was this one:
    Please Login or Register  to view this content.
    Set startFolder = Namespace.Folders("G Suite - xxxxx.com").Folders("Mail Folders").Folders("XXXXX").Folders("Projects")
    [/CODE]
    personally I've never seen. we will see though.

  10. #10
    Registered User
    Join Date
    12-19-2020
    Location
    San Francisco
    MS-Off Ver
    16
    Posts
    7

    Re: Retrieving Outlook folder using GetNamespace causing Runtime error

    Rorya: set startFolder is what causes the error.

    If I knew how to strip emails from the PST files, I would probably be smart enough to figure out the problem I'm having. Given the nature of my work (I'm an attorney) I can't send you a file that has client confidential information in it, such as emails.

  11. #11
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent SAC
    Posts
    8,885

    Re: Retrieving Outlook folder using GetNamespace causing Runtime error

    Ok, that would suggest that one of the folders can’t be found. I’d try each in turn, building up the hierarchy until it fails - i.e.:

    Please Login or Register  to view this content.
    Then
    Please Login or Register  to view this content.
    Then
    Please Login or Register  to view this content.
    Then
    Please Login or Register  to view this content.

  12. #12
    Banned User!
    Join Date
    02-06-2020
    Location
    Iowa City, IA, USA
    MS-Off Ver
    2016 - 365 / 2007
    Posts
    2,014

    Re: Retrieving Outlook folder using GetNamespace causing Runtime error

    that would pretty much be the only way to try and find out the error.

  13. #13
    Registered User
    Join Date
    12-19-2020
    Location
    San Francisco
    MS-Off Ver
    16
    Posts
    7

    Re: Retrieving Outlook folder using GetNamespace causing Runtime error

    Rorya--As Mace Windu would say: That the was clue to the mystery of the Set! (sorry, but we've been binge watching Star Wars)

    I did what you suggested (I did them all at once) and it failed on the top level "Gsuite - xxxxx.com".

    I'm so lame. Google changed the name from "G Suite" to "Google Workspace" and I did not notice that. G Suite was still coming up in the underlying properties, but had changed in the actual folder name.

    Once I corrected that, everything worked.
    Thanks all.

  14. #14
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    79,333

    Re: Retrieving Outlook folder using GetNamespace causing Runtime error

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

    Also, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  15. #15
    Registered User
    Join Date
    12-19-2020
    Location
    San Francisco
    MS-Off Ver
    16
    Posts
    7

    Re: Retrieving Outlook folder using GetNamespace causing Runtime error

    Thread annotated and reputations updated. Thanks for the guidance.

  16. #16
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent SAC
    Posts
    8,885

    Re: Retrieving Outlook folder using GetNamespace causing Runtime error

    Glad to help, and thanks for the rep.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. DatePicker (Eyre) selectdate causing Runtime error 13 if text box empty
    By K_L_C in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-04-2020, 05:13 AM
  2. [SOLVED] Worksheet Change Event Causing Runtime Error 9
    By phelbin in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-13-2017, 03:59 PM
  3. excel/outlook runtime error 440
    By Spotniq in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-28-2015, 02:57 AM
  4. PasteSpecial causing RunTime error 1004 & autofill doesn't stop at last line
    By Sc0tt1e in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-24-2014, 09:18 AM
  5. [SOLVED] Application.Calculate or F9 causing runtime / Visual Basic error
    By baldmosher in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-20-2013, 05:26 AM
  6. Application.Calculate causing Runtime Error
    By quekbc in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 05-20-2013, 05:14 AM
  7. [SOLVED] Why does Outlook.Application.GetNamespace("MAPI") Fail?
    By Lee in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-27-2005, 10:05 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1