I have a Shared mailbox that is programmatically worked on to move messages to other folders depending on the senders as well as send out emails in reply.
Occasionally, a recipient of an email from the shared mailbox will email back and then Recall that message which then blocks up the email queue in the Shared mailbox.
I know that I can iterate over the message by using code like this: If oSharedInbox.Items(intI).MessageClass <> "IPM.Outlook.Recall" Then...
But I can't get rid of the email as if I try deleting or moving I get a 430 error -Class does not support Automation or does not support expected interface.
Does anyone have any ideas how I can programmatically deal with them as I iterate through the list of emails?
Something like this..
For intI = oSharedInbox.Items.count To 1 Step -1
If TypeOf oSharedInbox.Items(intI) Is MailItem Then
Set oMail = oSharedInbox.Items(intI)
If .MessageClass = "IPM.Outlook.Recall" Then
ElseIf IsNumeric(.SentOnBehalfOfName) Or Left(.SentOnBehalfOfName, 1) = "+" Or .SentOnBehalfOfName = "Anonymous Caller" Then
.Move oManualInbox '*** A phone message!!!
'*** check if this is a cc'd email from the robot of from one of the team
ElseIf .SenderEmailType = "EX" Then
If CheckIfInTeam(.Sender.GetExchangeUser.PrimarySmtpAddress) = True Then...etc
You're right, the .Move or .Delete does raise an error - I should've made that clearer.
I just tried your idea of .Remove which gave this error: "Object doesn't support this property or method"... although I wrote the code as oSharedInbox.Items(intI).Remove but I don't see any difference in writing it this way.
Your way called the Remove method of the MailItem object, my calls it for the Items object. I´ve no clue why the MailItem doesn`t support it for this type of MessageClass.
If you need the item in "ManualInbox" and if Copy works, you could first copy the item to the target folder, then delete the original one. That´s actually the same what a Move does. If Copy doesn´t work either, I`d play with the MessageClass: Change it to "IPM.Note", which is the value for a MailItem, then try to move it. When done, you could restore the original value of "IPM.Outlook.Recall".