Run-time error '430' on certain emails when trying to set "Outlook.mailitem" as "ActiveExplorer.Selection.Item"

aliastral

New Member
Outlook version
Outlook 2019 32-bit
Email Account
IMAP
Hello!

With much help from code snippets I've pieced together from the internet (thanks Slipstick.com!), I've implemented a short macro that fires whenever an email is moved to a different folder in our team's shared mailbox.
I don't dare to say it's anywhere near elegant, but the code works for the most part.

However, on certain 'emails' it throws a run-time error '430' saying that the class does not support automation.
Debugging shows that the error occurs on the following line:

C-like:
Set objMailItem = Application.ActiveExplorer.Selection.Item(1) 'if both above conditions are met, sets objMailitem object as the currently selected item'
Previously, it appeared that this would happen when the user tried to move emails that were not technically emails (e.g. meeting invitations, requests for moderation approval, message read notifications). I added an additional check for the Mailitem.Sent property which seems to have reduced the number of occurrences.
As we only have six users (and some users click away the error without telling me), I've had some trouble pinpointing the exact cause of the issue.

However, I've now also encountered the problem on a regular email message, but only on this specific message.
To try and isolate the issue, I've found the following:
  1. Email was very recently replied to (I replied to it and immediately tried to move it into another folder).
  2. Email cannot be previewed in the viewing pane (Shows the message: "This item cannot be displayed in the reading pane. Open the item to read its contents.").
  3. Email cannot be opened in a new window (Shows the message: "Sorry, we're having trouble opening this item. This could be temporary, but if you see it again you might want to restart Outlook.").

This error stops all macros from running, including a secondary macro I have that sets the .SendUsingAccount and .SendOnBehalfOf for each outgoing message. If needed, I can post the entire VBA module.

Ideally, I'd like to find a way for Outlook to exclude these error causing emails.
Of course, if there are deeper issues with my code, I'd definitely appreciate insight on that as well.

Additional information that might be helpful:
  1. The macro is installed on six computers, and I'd say the error occurrence rate is "infrequent".
  2. The macro seems to work fine for 99% of all email messages.
  3. All six computers have Microsoft Outlook for Microsoft 365 MSO 32bit installed via Microsoft's installer obtained via portal.office.com.
  4. As far as I know, all six computers are on the same Office 365 update ring (my computer is currently on 16.0.12827.20200).

C-like:
Private Sub myOlExp_BeforeItemPaste(ClipboardContent As Variant, ByVal Target As MAPIFolder, Cancel As Boolean)

Dim strRemark As String 'declares string'
Dim strDate As String 'declares string'
Dim strDestination As String 'declares string'
Dim strUser As String 'declares string'

strDestination = Target 'sets strDestination string as item paste target'
strDate = Format(Now, "MM/dd") 'sets strDate string as current day'
strUser = "Justin" 'sets strUser string as current user'

strRemark = "[" & strDate & "] " & strUser & " moved to '" & strDestination & "'" 'combines above three strings into one and adds symbols/text for clarity'

If Application.ActiveExplorer.Selection.Item(1).Class = olMail Then 'checks to see if selection is of olMail class'
    If Application.ActiveExplorer.Selection.Item(1).Sent = True Then 'checks for the mailitem.sent property to ensure code only executes for mail.. (hopefully?)'
        Set objMailItem = Application.ActiveExplorer.Selection.Item(1) 'if both above conditions are met, sets objMailitem object as the currently selected item'
            objMailItem.Categories = strRemark & "," & objMailItem.Categories 'adds the strRemark string as a new category to objMailitem'
    End If
End If
End Sub
Apologies for the long post, very much appreciate you taking the time to read through some of it!
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
>>
  1. Email was very recently replied to (I replied to it and immediately tried to move it into another folder).
  2. Email cannot be previewed in the viewing pane (Shows the message: "This item cannot be displayed in the reading pane. Open the item to read its contents.").
>>
The first is an IMAP issue - Outlook is bad about registering updates from the server after you make a change to an item. The manual fix is to select another message, come back and move it. I don't have a solution for VBA.

The second usually means there is something in the message that prevents it from displaying - in an Exchange server, it could be embedded objects or custom forms. This is less likely in IMAP. Signed messages will do it too.

If you know what message triggers it, add the message class field to the view and see what message class it is.

Try adding error handling to the sub - before the Set objMailItem line:
either
On Error GoTo 0 or
On Error GoTo ErrorHandler

then at the end
ErrorHandler:
Exit Sub

When you hit an error the message won't move but the
 

aliastral

New Member
Outlook version
Outlook 2019 32-bit
Email Account
IMAP
Thanks for the feedback Diane!
I'll try adding the error handler, hopefully it'll catch the remaining outliers.
 
Thread starter Similar threads Forum Replies Date
A Run time error 424. object required in outlook 2013 Outlook VBA and Custom Forms 10
S VBA Macro - Run-time error '424': object required - Help Please Outlook VBA and Custom Forms 3
P Run Time Error 91 when linking contact to task in VBA Outlook VBA and Custom Forms 1
Vijay Error in rule- Run a script Using Outlook 1
J Run time error when using unbound fields in form Using Outlook 1
G OUTLOOK 2007 UNABLE TO RECEIVE EMAILS CAN'T RUN INBOX REPAIR TOOL AND ERROR (OX8E0CCC18) Using Outlook 2
F OLAddin run-time error '75": path/file access error Using Outlook 1
S outlook error 0x80070021 a prosses has outlook files open and backup cannot run Using Outlook 2
H Office OUtlook 2007 gives error message that says to run scanpst.exe and this is not found on my com Using Outlook 3
A "An OLE registration error Occurred. The Program is not correctly installed. Run Setup again for the Using Outlook 3
D Outlook report the error - "Cannot display the folder. There is not enough free memory to run this p Using Outlook 34
A vb6 run time error 5 when Outlook 2007 Explorer object displayed Outlook VBA and Custom Forms 1
L An OLE registration error occurred. The program is not correctly installed. Run Setup again for the Using Outlook 15
S Outlook Custom Form Scripting only working when clicking on "Run this form" Outlook VBA and Custom Forms 2
Y Outlook 2013 Run A Script Outlook VBA and Custom Forms 4
O Outlook 2016 This rule will only run when you check your email in Outlook.... Using Outlook 4
B run scripts Using Outlook 1
Dave A Run macro on existing appointment when it changes Outlook VBA and Custom Forms 1
O Run macro automatically at sending an email Using Outlook 11
P errors appear every time I run SCANPST Using Outlook 3
B Outlook rule run a Script doesn't work Outlook VBA and Custom Forms 1
B Wanting to run a script that will filter any body that has a russian link in it. Outlook VBA and Custom Forms 5
O Having rules run on old mails noved to inbox Outlook VBA and Custom Forms 8
Bri the Tech Guy Registry Tweak to make "Run a Script" Action Available Outlook VBA and Custom Forms 2
Bri the Tech Guy Run Script rule not running for newly arriving messages Outlook VBA and Custom Forms 25
J Custom form code doesn't run Outlook VBA and Custom Forms 2
J VBA Run When Reply Outlook VBA and Custom Forms 4
Vijay Run script doesn't work in outlook Using Outlook 1
O VBA to Run Font Change on Outlook Startup Outlook VBA and Custom Forms 4
D Creating an outlook session from Access vba but run silently. With A specific profile Outlook VBA and Custom Forms 1
Diane Poremsky Run a Script Rule: Send a New Message when a Message Arrives New Slipstick.com Articles 2
Diane Poremsky Using Scanpst in Outlook Click to Run New Slipstick.com Articles 0
oliv- How to Run a Script IN AN ADDIN with Outlook's Rules and Alerts Outlook VBA and Custom Forms 2
L Run a Script Rule doesn't work Using Outlook 5
B Can't run macro from QAT when emailing from Acrobat Outlook VBA and Custom Forms 0
J Outlook 2010 VBScript editor does not run code at all Outlook VBA and Custom Forms 0
X Outlook script to run excel data Outlook VBA and Custom Forms 1
D How to Run a Report Based on Age of Inbox Items Outlook VBA and Custom Forms 0
D RUN SCRIPT WHEN OUTLOOK IS CLOSE Outlook VBA and Custom Forms 1
L Cannot run script from rule Outlook VBA and Custom Forms 7
M Office 365 Click to run BCM (Business Contact Manager) 0
O modify vba to run it as script rule Outlook VBA and Custom Forms 8
D Must now "View on Facebook" for Mentions/Comments-Outlook 2013 click-to-run Using Outlook 2
P How many subs can run in one outlook VBA script Using Outlook 5
R Outlook won't run except in Safe mode problem Using Outlook 5
K Revert AutoArchive settings via GPO (Run Autoarchive every...) Using Outlook 4
Xueying run a script in rules, first time succeed, failed afterwards Outlook VBA and Custom Forms 3
G Outlook 2003 VBA Won't Run In Outlook 2010 Outlook VBA and Custom Forms 4
J Run Rules Now Using Outlook 1
Gary Brown Outlook 2013 VBA to run a rule Outlook VBA and Custom Forms 13
Similar threads


















































Top