Consulting

Results 1 to 2 of 2

Thread: Accessing Emails in a public group (Outlook 2016)

  1. #1

    Accessing Emails in a public group (Outlook 2016)

    Howdy everyone,

    My company recently upgraded to Microsoft 365 (2016 edition). After the change my coworkers and I decided to create a new public group.

    This is working out swell, but I have a program that used to run through a person's inbox and open up emails based on the subject line. Trying to adapt this to work with the public group folder has led me to a stopping point.



    Sub OpenGroupEmails() 
        Dim NS As Outlook.NameSpace 
        Dim objOwner As Outlook.Recipient 
        Dim fldr As Outlook.MAPIFolder 
         
        Set NS = Application.GetNamespace("MAPI") 
        Set objOwner = NS.CreateRecipient("MI Team") 
        objOwner.Resolve 
         
        If objOwner.Resolved Then 
            MsgBox objOwner.Name 
            Set fldr = NS.GetSharedDefaultFolder(objOwner, olPublicFoldersAllPublicFolders) 
        End If 
    End Sub 
    
    
    Formatting tags added by mark007
    The group name is "MI Team", when I run this I get a message box with the words "MI Team". But the next line gives me the following error "Run-time error '-2147024809 (80070057)': Sorry, something went wrong. You may want to try again."

    I feel like I'm missing something simple that will resolve this issue.

    Thanks for taking the time to look over my problem. God bless.

  2. #2
    It looks like you have a shared mailbox. If so, the code should look like this with olFolderInbox rather than olPublicFoldersAllPublicFolders

    Sub OpenGroupEmails() 
        Dim NS As Outlook.NameSpace 
        Dim objOwner As Outlook.Recipient 
        Dim fldr As Outlook.MAPIFolder 
         
        Set NS = Application.GetNamespace("MAPI") 
        Set objOwner = NS.CreateRecipient("MI Team") 
        objOwner.Resolve 
         
        If objOwner.Resolved Then 
            MsgBox objOwner.Name 
            Set fldr = NS.GetSharedDefaultFolder(objOwner, olFolderInbox) 
        End If 
    End Sub 
    
    
    Formatting tags added by mark007
    If there is a public folder involved then there is an example in "Folders.Item Method (Outlook)"

    https://msdn.microsoft.com/en-us/lib.../ff867877.aspx

    Sub OpenPublicFolder() 
         
        Dim objFolder As Folder 
         
        Set objFolder = Session.GetDefaultFolder(olPublicFoldersAllPublicFolders).Folders.("name of folder") 
         
        Set ActiveExplorer.CurrentFolder = objFolder 
         
    End Sub 
    
    
    Formatting tags added by mark007
    To debug, mouse-click anywhere in the code. Press F8 repeatedly to step through the code. http://www.cpearson.com/excel/DebuggingVBA.aspx

    If your problem has been solved in your thread, mark the thread "Solved" by going to the "Thread Tools" dropdown at the top of the thread. You might also consider rating the thread by going to the "Rate Thread" dropdown.

Posting Permissions

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