Accessing shared outlook folder doesn't work since switch to new outlook/excel

Status
Not open for further replies.

elbrodero

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
POP3
Hello,

I have a macro that used to work like charm on office 2010. Since the switch to windows 10 and office 365 it only work occasionally. The macro extracts excel files from e-mails that are in a certain sub folder. I am using the macro out of excel.

I used the following code:

Const olFolderInbox As Integer = 6



Sub DownloadAttachmentFirstUnreadEmailSharedMail()
Dim olNamespace As Object
Dim olApp As Object
Dim olNs As Object
Dim olFolder As Object
Dim olRecip As Object
Dim oOlItm As Object
Dim oOlAtch As Object

Set olApp = GetObject(, "Outlook.application")
Set olNs = olApp.GetNamespace("MAPI")
Set olRecip = olNs.CreateRecipient("work@work.de")
Set olFolder = olNs.GetSharedDefaultFolder(olRecip, olFolderInbox).Folders("03_EUR_03")


Unfortunately, the code gets stuck now in the last line giving me the error message "not all object could be found". However, this only happens occasionally.
 
I wonder if its a GAL issue - for whatever reason, it cant get into the gal and dies. You can try resolving the olRecip before getting the folder -

Set olRecip = olNs.CreateRecipient("work@work.de")
olRecip.Resolve
Set olFolder = olNs.GetSharedDefaultFolder(olRecip, olFolderInbox).Folders("03_EUR_03")

Do you have the offline address book downloaded? Not sure if it will help resolve it faster, but it might.
 
I included the olRecip.Resolve line into my code but unfortunately it is still showing me an error message sometimes for the line:
Set olFolder = olNs.GetSharedDefaultFolder(olRecip, olFolderInbox).Folders("03_sonst_EUR")

As far as I know I do not have the offline address book downloaded. How can I do this?

But I am wondering what the GAL has to do with this?
 
But I am wondering what the GAL has to do with this?
It needs to find the mailbox for this user - olNs.CreateRecipient("work@work.de")

As far as I know I do not have the offline address book downloaded. How can I do this?
Send/Receive menu, expand Send/Receive Groups button - download address book is near the bottom.

Is the 03 subfolder on your computer? it needs to be in your profile to use the code. Are you caching shared folders? Open the account settings dialog, double click on your account then More Settings - advanced tab to check.
 
I'm having a very similar problem. When I use my macro immediately after opening outlook it works fine. Upon subsequent uses it breaks. If I close and reopen outlook it works again, once.

My macro grabs an e-mail from a shared inbox and copies it to a specific user's subfolder, and changes the category to show who it was assigned to and who assigned it to them. It also changes it to "read" in the main inbox and "unread" in the sub inbox. The issue seems to be that this all happens in a shared inbox. Here's a snippet:

Sub Assign(strBox As String, strAddress As String, Name As String, Flag As Boolean, Fwd As Boolean)
Dim objFolder As Outlook.MAPIFolder, objInbox As Outlook.MAPIFolder
Dim objNS As Outlook.NameSpace, objItem As Outlook.MailItem
Dim MAILBOX As Outlook.Recipient
Dim User As String
Dim FirstNameLen As Integer
Dim fwditem As Outlook.MailItem
Dim moveitem As Outlook.MailItem
Set objNS = Application.GetNamespace("MAPI")
User = objNS.CurrentUser
FirstNameLen = Len(User) - InStr(1, User, " ")
Set MAILBOX = objNS.CreateRecipient("ACTUAL USER MIALBOX NAME")
MAILBOX.Resolve
Set objInbox = objNS.GetSharedDefaultFolder(MAILBOX, olFolderInbox)
Set objFolder = objInbox.Folders(strBox) 'Code breaks here, but only after running successfully one time


The sub is kicked off from other subs that are unique to each user

Any help is greatly appreciated.
 
Do you know what line it dies on?
 
Yes the last line of my snippet:
Set objFolder = objInbox.Folders(strBox) 'Code breaks here, but only after running successfully one time

Thanks!
 
Sorry, I missed the comment in the code earlier. Just saw it now, OOps. :)

Can you post the entire code? I don't see how/where you are setting the value for strBox - best guess is that it is being cleared. Does it give you an error message too?
 
Here is the full code. There are more subs for other users, but I just included one. Some of the code, like the FWD Boolean might not be used anymore. I unchecked the "download shared folders" box under cached exchange mode, and that seems to have worked. I'm not sure if it will keep working. Does it make sense that that would work?

Thanks!

Sub Assign(strBox As String, strAddress As String, Name As String, Flag As Boolean, Fwd As Boolean)
Dim objFolder As Outlook.MAPIFolder, objInbox As Outlook.MAPIFolder
Dim objNS As Outlook.NameSpace, objItem As Outlook.MailItem
Dim PLIM As Outlook.Recipient
Dim User As String
Dim FirstNameLen As Integer
Dim fwditem As Outlook.MailItem
Dim moveitem As Outlook.MailItem
Set objNS = Application.GetNamespace("MAPI")
User = objNS.CurrentUser
FirstNameLen = Len(User) - InStr(1, User, " ")
Set MAILBOX = objNS.CreateRecipient("ACTUAL USER MAILBOX NAME")
MAILBOX.Resolve
Set objInbox = objNS.GetSharedDefaultFolder(MAILBOX, olFolderInbox)
Set objFolder = objInbox.Folders(strBox) 'Code breaks here, but only after running successfully one time
If objFolder Is Nothing Then
MsgBox "This folder doesn't exist!", vbOKOnly + vbExclamation, "INVALID FOLDER"
Exit Sub
End If
Set objItem = ActiveExplorer.Selection.Item(1)
If objItem.Class = olMail Then
objItem.UnRead = False
objItem.Categories = ""
objItem.Categories = "Assigned To " & Name & " by " & Right(User, FirstNameLen)
objItem.Close (olSave)
Set moveitem = objItem.Copy
If Flag = True Then
moveitem.FlagIcon = 6
End If
moveitem.Categories = ""
moveitem.Categories = "Assigned To " & Name & " by " & Right(User, FirstNameLen)
moveitem.UnRead = True
moveitem.Move objFolder
End If
Set objItem = Nothing
Set objFolder = Nothing
Set objInbox = Nothing
Set objNS = Nothing
End Sub

Sub John()
Assign "JSmith", "john.smith", "John", False, True
End Sub
 
I thought maybe you were setting strBox then discarding it. But that's not the cause.

Since it works in classic online, I wonder if there was a problem resolving the name in the offline gal.
 
I thought maybe you were setting strBox then discarding it. But that's not the cause.

Since it works in classic online, I wonder if there was a problem resolving the name in the offline gal.

It seems to have worked when I unchecked the download shared folders box (for one user, but not every user). What is a gal?
 
gal = "Global Address List" - its the address book with all of the internal users in it.
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
S Problem Accessing .MSG Property 'ImageNaturalHeight' Tag '0x80010003' Outlook VBA and Custom Forms 1
M Accessing ALL Outlook contact fields Outlook VBA and Custom Forms 3
RBLampert Accessing Outlook accounts from multiple computers Using Outlook 8
J Accessing calendar items for Resource Mailboxes Outlook VBA and Custom Forms 2
S Outlook [Online - Office365] perfomance is getting affected when accessing the mails using Redemptio Using Outlook 1
J Accessing Hotmail accounts with Outlook 2016 Using Outlook 3
n2b Accessing Plain Text Draft Without Outlook Using Outlook 3
G Issues with accessing Outlook Contact Picture with VBA Outlook VBA and Custom Forms 4
M Accessing ExpiryTime property Outlook VBA and Custom Forms 1
M Accessing BCM with Excel / Running Reports BCM (Business Contact Manager) 1
C Problem accessing events for folder "username" Server Threw Exception Using Outlook 1
P accessing custom task pane with Outlook ActiveInspector Using Outlook 1
mikecox Accessing Outlook on my Win7 desktop from Win8 laptop Using Outlook 1
A "Unable to display the folder" error when accessing Group mailbox Using Outlook 0
Commodore Accessing mail from multiple devices Using Outlook 1
S Programmatically accessing Outlook Calendar data Using Outlook 1
E Accessing User Defined Fields in BCM Database part 2 BCM (Business Contact Manager) 0
E [SOLVED] Accessing User Defined Fields in BCM Database part 1 BCM (Business Contact Manager) 9
R Accessing folder 'Other Contacts' Outlook VBA and Custom Forms 1
E Accessing a Form Region from an Inspector Outlook VBA and Custom Forms 3
E Accessing a Form Region from an Inspector Outlook VBA and Custom Forms 3
D Accessing Global Address List details with VBA Outlook VBA and Custom Forms 1
H Accessing a control on a frame in Outlook with VBScript Outlook VBA and Custom Forms 1
K Programmatically accessing Outlook properties Outlook VBA and Custom Forms 3
K assistant accessing from her home computer BCM (Business Contact Manager) 2
A Accessing .pst folder in outlook using VBA Code Outlook VBA and Custom Forms 4
J Outlook closes when accessing History in BCM BCM (Business Contact Manager) 4
B Accessing Outlook 2003 Signature Programmatically using C# Outlook VBA and Custom Forms 6
L Outlook Forms-Accessing Outlook VBA and Custom Forms 1
C Accessing _RecipientControl1 (Assigned To) Outlook VBA and Custom Forms 2
K Accessing contact's custom properties in a Outlook 2007 form region Outlook VBA and Custom Forms 1
V Outlook custom form - installing and accessing Outlook VBA and Custom Forms 1
A Daily hours of recurring/ multi-day appts, & accessing mult calend Outlook VBA and Custom Forms 2
R New users creating get page cannot be displayed when accessing OWA Exchange Server Administration 16
U When opening shared Calendar "The set of folders cannot be opened" Using Outlook 0
M Outlook 2016 outlook vba to look into shared mailbox Outlook VBA and Custom Forms 0
V Unchecking my calendar and leaving shared one visible Outlook VBA and Custom Forms 1
S Email Macros to go to a SHARED Outlook mailbox Draft folder...NOT my personal Outlook Draft folder Using Outlook 2
C Outlook 365 Multiple different Signatures on Shared Mailbox Using Outlook 0
Fozzie Bear Shared Calendar For Scheduled Tasks Using Outlook.com accounts in Outlook 3
Z Outlook 365 Automatically assign categories to incoming mail in a shared folder Round Robin Outlook VBA and Custom Forms 1
J Outlook 365 Forward Email Subject to my inbox when new email arrive in shared inbox Using Outlook 0
J Hide/disable "Groups", "Shared Calendars" Using Outlook 2
T Never-ending Reminders in Shared Calendars Using Outlook 3
S Outlook 365 Shared mailbox contact group member numbers not matching Using Outlook 0
P Emails assigned with a certain category (within a shared inbox) to be copied to a specific folder. Outlook VBA and Custom Forms 2
S Copy Tasks/Reminders from Shared Mailbox to Personal Tasks/Reminders Outlook VBA and Custom Forms 0
peterbata Shared Tasks Outlook for Mac Using Outlook 5
Fozzie Bear Shared Public Folders Access and Use Exchange Server Administration 0
S Excel VBA and shared calendar issue Outlook VBA and Custom Forms 3

Similar threads

Back
Top