Outlook 2013 VBA to deal with Recalled messages

Mark White

Member
Outlook version
Outlook 2013 64 bit
Email Account
Exchange Server
Hi,
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?
Cheers
Mark
 

Mark White

Member
Outlook version
Outlook 2013 64 bit
Email Account
Exchange Server
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)
With oMail
If .MessageClass = "IPM.Outlook.Recall" Then
.Move oManualInbox
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
 

Michael Bauer

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
It´s the ".Move oManualInbox" line that throws the error? Is the 0ManualInbox variable declared as Folder?

If the Copy command would work, I´d try to call Items.Remove intI
 

Mark White

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

Mark White

Member
Outlook version
Outlook 2013 64 bit
Email Account
Exchange Server
Goodness me - I just tried it your way oSharedInbox.Items.Remove intI and it worked a treat - amazing, thanks

Why does that way work and not my way?
 

Michael Bauer

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

Mark White

Member
Outlook version
Outlook 2013 64 bit
Email Account
Exchange Server
Thanks for all the help, Michael and thanks for the other ideas for moving etc.
In point of fact, though, just removing it is fine but good to know all the other ideas.
Mark
 
Top