VBA script fail after Office 365 update

Status
Not open for further replies.

D.Moore

Senior Member
Outlook version
Outlook 2016 64 bit
Email Account
Office 365 Exchange
Dear Diane,

After all update since 12730.20236 (including the latest one), this code not running anymore (though it was working perfectly in the last 2 years). I tried to debug it, and it seems, that can not resolve the shared mailbox (though nothing changed on the mailbox and if I restore a previous version of office from backup prior to 12730.20236, resolve it perfectly).

May I ask if you are aware of any change on resolving shared mailboxes since 12730.20236 ?

Maybe this has something to do with it ? :

https://support.microsoft.com/en-us...s-impacted-april-2020-office-security-updates

Many many thanks,

Moore

Code:
        Set objOwnerDELETE = objNS.CreateRecipient(email)
        objOwnerDELETE.Resolve

        If objOwnerDELETE.Resolved Then

            Set objSourceFolderMAILBOX = objNS.GetSharedDefaultFolder(objOwnerDELETE, olFolderInbox)
            Set objDeletedItems = objSourceFolderMAILBOX
            Set objDeletedItems = objDeletedItems.Parent.Folders("Deleted Items")
            Set objItems = objDeletedItems.Items

            For i = objItems.Count To 1 Step -1
               
                objItems.Item(i).Delete

            Next

            Set objFolders = objDeletedItems.Folders

            For i = objFolders.Count To 1 Step -1

                objFolders.Item(i).Delete

            Next

            Set objDeletedItems = Nothing
            Set objFolders = Nothing
            Set objItems = Nothing

        End If
 
I use this in a app start macro and it works - it's used with an itemadd macro. The only time i have problems is if there are connection problems.

Code:
  Set objOwner = objNS.CreateRecipient("accounts@slipstick.com")
    objOwner.Resolve

 If objOwner.Resolved Then
 '  MsgBox objOwner.Name
 Set accountsMailbox = objNS.GetSharedDefaultFolder(objOwner, olFolderInbox)
 End If
 Set accountsInboxItems = accountsMailbox.Items

The changes apply to object libraries (Tools > References) , not to this.
 
You right, as always! I accidentally placed the debug MsgBox to the wrong place. The problem actually is with my For cycle.

When objItems.Count = 0, so i = 0 , so nothing to delete, then its stuck int the for cycle.

Strange why, as it is always worked till now.
 
That is weird if it worked before. But the logic is messed up when its 0.
For i = 0 To 1 Step -1

For attachments, I count first and see if greater than 0
lngCount = objAttachments.Count
If lngCount > 0 Then


I have two empty deleted items macros here - Empty Multiple Deleted Items Folders using a Macro - one uses commands, one deleted older items.
 
Thank you for your reply!

I had added the deleted items macro into Application_Startup, as I would like to empty the deleted folders when outlook starts up. It works perfecty, BUT for some reason, I creates a strange effect in outlook. Whatever folder I click on, its get cleared, visually. I made a short video about it, and attached it. Could you be so kind and help me why it is, and how to correct it ? BIG thank you in advance!!

Code:
Private Sub Application_Startup()

'Empty ALL mailboxes Deleted folders - START
Dim olApp As Outlook.Application
Dim olNS As Outlook.NameSpace
Dim objExpl As Outlook.Explorer
Dim mboxCount As Long
Dim i As Long
Dim deletedItemsFolder As Outlook.Folder
 
    Set olApp = Application
    Set olNS = olApp.GetNamespace("MAPI")
    Set objExpl = olApp.ActiveExplorer
 
    mboxCount = olNS.Folders.Count
    For i = 1 To mboxCount

    On Error Resume Next
    Set deletedItemsFolder = olNS.Folders(i).Folders("Deleted Items")
    
    If Err = 0 Then
        On Error GoTo 0
        objExpl.SelectFolder deletedItemsFolder
        objExpl.CommandBars.ExecuteMso ("EmptyFolder")
    End If
    
    Next i
 
objExpl.SelectFolder olNS.GetDefaultFolder(olFolderInbox)
'Empty ALL mailboxes Deleted folders - FINISHED

End Sub
 

Attachments

  • problem.zip
    881.9 KB · Views: 320
Comment out the last line where it goes back to the inbox, see if that makes a difference.

It looks like the view is goofy as the item count in the lower left doesn't change. Try resetting the view.
 
Comment out the last line where it goes back to the inbox, see if that makes a difference.

It looks like the view is goofy as the item count in the lower left doesn't change. Try resetting the view.

I tried, but thats did not solve the problem. I also reset the view, but this problem only exist, when the code added, if not, there is no problem. Strange.
 
I found a work around, adding the script into a schedule, eliminated this strange problem. Thank you !
 
That's weird... but as long as it works.
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
J Outlook Rules VBA Run a Script - Multiple Rules Outlook VBA and Custom Forms 0
FryW Need help modifying a VBA script for in coming emails to auto set custom reminder time Outlook VBA and Custom Forms 0
A VBA Script - Print Date between first email in Category X and last email in Category Y Outlook VBA and Custom Forms 3
L Modifying VBA script to delay running macro Outlook VBA and Custom Forms 3
L Need help modifying a VBA script for emails stuck in Outbox Outlook VBA and Custom Forms 6
S Change VBA script to send HTML email instead of text Outlook VBA and Custom Forms 3
dweller Outlook 2010 Rule Ignores VBA Script Outlook VBA and Custom Forms 2
N VBA Script to Open highlighted e-mail and Edit Message Outlook VBA and Custom Forms 5
K Outlook Archive to PST Files by Date Range VBA Script? Outlook VBA and Custom Forms 1
Peter H Williams Enable script containing VBA Outlook VBA and Custom Forms 12
R VBA Script Quick Parts Using Outlook 1
Q VBA Script to move item in secondary mailbox Outlook VBA and Custom Forms 2
N VBA Script to Send Automatic Emails from Outlook 2010 Outlook VBA and Custom Forms 1
O modify vba to run it as script rule Outlook VBA and Custom Forms 8
P How many subs can run in one outlook VBA script Using Outlook 5
J Email Parsing VBA Script for Outlook - NEEDED Outlook VBA and Custom Forms 7
P Vba script including macro appears in rules but wont run Outlook VBA and Custom Forms 6
R Adding vba to script list Outlook VBA and Custom Forms 4
F VBA script to highlight specific words Outlook VBA and Custom Forms 1
D VBA Script to extract text matching specific criteria Outlook VBA and Custom Forms 1
D VBA Script (Ask to where to save send mail) Outlook VBA and Custom Forms 1
M VBA script to allow mail merges of distribution groups? Using Outlook 7
D VBA script to auto download attachments and rename file according to subject line Outlook VBA and Custom Forms 23
Hudas Outlook VBA script reverting back to previous changes Outlook VBA and Custom Forms 2
J Outlook 2007 Rules & VBA: How to run a script on a report message (ReportItem) Using Outlook 14
V "Accept + Send the Response now", VBA script? Using Outlook 1
R Addins4Outlook TagIt! addin script or VBA module? Using Outlook 2
S Outlook VBA rule script to process both MailItem and MeetingItem Using Outlook 0
A VBA Script to Forward Spam to AntiSpam Provider Using "Blank" Form Outlook VBA and Custom Forms 2
L Limit VBA Script to one Outlook account Using Outlook 1
H using VBA to edit subject line Outlook VBA and Custom Forms 0
G Get current open draft message body from VBA Outlook VBA and Custom Forms 1
Geldner Problem submitting SPAM using Outlook VBA Form Outlook VBA and Custom Forms 2
P VBA to add email address to Outlook 365 rule Outlook VBA and Custom Forms 0
M Outlook 2016 outlook vba to look into shared mailbox Outlook VBA and Custom Forms 0
V VBA Categories unrelated to visible calendar and Visual appointment Categories Outlook VBA and Custom Forms 2
D Outlook VBA forward the selected email to the original sender’s email ID (including the email used in TO, CC Field) from the email chain Outlook VBA and Custom Forms 2
R Outlook 365 VBA AUTO SEND WITH DELAY FOR EACH EMAIL Outlook VBA and Custom Forms 0
R Outlook 2019 VBA to List Meetings in Rooms Outlook VBA and Custom Forms 0
geoffnoakes Counting and/or listing fired reminders via VBA Using Outlook 1
O VBA - Regex - remove double line spacing Outlook VBA and Custom Forms 1
D.Moore Strange VBA error Outlook VBA and Custom Forms 4
B Modify VBA to create a RULE to block multiple messages Outlook VBA and Custom Forms 0
D Outlook 2021 Using vba code to delete all my spamfolders not only the default one. Outlook VBA and Custom Forms 0
K vba code to auto download email into a specific folder in local hard disk as and when any new email arrives in Inbox/subfolder Outlook VBA and Custom Forms 0
D VBA - unable to set rule condition 'on this computer only' Outlook VBA and Custom Forms 5
L Fetch, edit and forward an email with VBA outlook Outlook VBA and Custom Forms 2
BartH VBA no longer working in Outlook Outlook VBA and Custom Forms 1
W Can vba(for outlook) do these 2 things or not? Outlook VBA and Custom Forms 2
MattC Changing the font of an email with VBA Outlook VBA and Custom Forms 1

Similar threads

Back
Top