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.
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
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.
 

elbrodero

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
POP3
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?
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
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.
 

Qythagoras

Member
Outlook version
Outlook 2016 32 bit
Email Account
Exchange Server
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.
 

Qythagoras

Member
Outlook version
Outlook 2016 32 bit
Email Account
Exchange Server
Yes the last line of my snippet:
Set objFolder = objInbox.Folders(strBox) 'Code breaks here, but only after running successfully one time

Thanks!
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
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?
 

Qythagoras

Member
Outlook version
Outlook 2016 32 bit
Email Account
Exchange Server
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
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
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.
 

Qythagoras

Member
Outlook version
Outlook 2016 32 bit
Email Account
Exchange Server
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?
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
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
N Shared Calendar in Public folder hangs when accessing from Outlook 2010 Exchange Server Administration 2
H accessing shared calendar in outlook 2007 Using Outlook 3
X Accessing a shared email folder - How? Exchange Server Administration 1
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 Calendar Printing Assistant 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
K trying to sync my samsung galaxy to my outlook 2010 calender. it says execution privilege prevents me from accessing outlook Using Outlook 1
P time delay between accessing Outlook file folders, up 20+ second delay Using Outlook 1
S Accessing source information Using Outlook 1
J After Window update of 12/15/2010, outlook 2007 gives error (0x800CCC18) when accessing gmail using Using Outlook 6
S Outlook 2010 freezes and not responding when accessing, moving or deleting files Using Outlook 2
N Problems accessing network files via OWA Using Outlook 5
M Mails get deleted accessing a user mailbox with a different user Using Outlook 2
H Accessing a backup Using Outlook 3
J Problems accessing console of Exchange 2010 on Windows Server 2008 R2 Please help me Exchange Server Administration 4
S Accessing emails in a closed account Using Outlook 1
E Users get login prompt in Outlook 2007 when accessing Exchange Server 2007 Using Outlook 2
A BCM-Problem Accessing Database Using Outlook 1
K Outlook 2010 now freezes while accessing Gmail Using Outlook 3
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
D IIS Returns HTTP 505 Version Not Supported when accessing Microsoft-Server-ActiveSync Exchange Server Administration 47
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
Fozzie Bear Shared Public Folders Access and Use Exchange Server Administration 0

Similar threads

Top