S
Shiv
I have a macro to process some mails in a mailbox, it worked fine all these
days(Though exceptionally slow).now it returns a Runtime error while setting
the mailitem to an object. Folder propeties return Operation failed. only
Inbox folder is accesible any folders within it return runtime errors.
Ex code:
Public Sub tester()
Dim objNS As Outlook.NameSpace
Dim objSubfolder As Outlook.MAPIFolder
Dim objItem As Outlook.MailItem
Set objNS = Application.GetNamespace("MAPI")
Set objRcpnt = objNS.CreateRecipient("(e-mail address removed)")
Set objSubfolder = objNS.GetSharedDefaultFolder(objRcpnt, olFolderInbox)
Set objSubfolder = objSubfolder.Folders.Item(11) '<== this is folder
called test which im uanable to acees only now...
Set objItem = objSubfolder.Items(11) '<== Runtime error Here <==
End Sub
Today, 2:41 AM
Sue Mosher - Outlook MVP
Re: Outllok macro return Runtime error : operation failed for mailbox folder
GetSharedDefaultFolder does not give you access to subfolders. To work with
subfolders in another mailbox, you must have the mailbox visible in the
Folder List as a secondary mailbox and then will need to walk down the folder
hierarchy starting with the mailbox root.
Also, do not assume that everything in a mail folder is a MailItem. Declare
objItem as Object and check the value of its Class property to find out what
kind of item it is.
@sue:
I have the mailbox shared in my OL 2007,the macro worked fine all these
days,now all my team has this problem.Also im new to VBA
Our Monthly reports depend on making it work.
Thanks
days(Though exceptionally slow).now it returns a Runtime error while setting
the mailitem to an object. Folder propeties return Operation failed. only
Inbox folder is accesible any folders within it return runtime errors.
Ex code:
Public Sub tester()
Dim objNS As Outlook.NameSpace
Dim objSubfolder As Outlook.MAPIFolder
Dim objItem As Outlook.MailItem
Set objNS = Application.GetNamespace("MAPI")
Set objRcpnt = objNS.CreateRecipient("(e-mail address removed)")
Set objSubfolder = objNS.GetSharedDefaultFolder(objRcpnt, olFolderInbox)
Set objSubfolder = objSubfolder.Folders.Item(11) '<== this is folder
called test which im uanable to acees only now...
Set objItem = objSubfolder.Items(11) '<== Runtime error Here <==
End Sub
Today, 2:41 AM
Sue Mosher - Outlook MVP
Re: Outllok macro return Runtime error : operation failed for mailbox folder
GetSharedDefaultFolder does not give you access to subfolders. To work with
subfolders in another mailbox, you must have the mailbox visible in the
Folder List as a secondary mailbox and then will need to walk down the folder
hierarchy starting with the mailbox root.
Also, do not assume that everything in a mail folder is a MailItem. Declare
objItem as Object and check the value of its Class property to find out what
kind of item it is.
@sue:
I have the mailbox shared in my OL 2007,the macro worked fine all these
days,now all my team has this problem.Also im new to VBA
Our Monthly reports depend on making it work.
Thanks