Solved

Outlook VBA Recall Messages

Posted on 2007-04-11
5
1,823 Views
Last Modified: 2007-12-19
Hello,

I am using VBA to validate Message Types in Outllok so that it only looks at mailItems. However, I need to ensure that VBA does not fall over when a message is recalled by a user. Can the following be restructured to remove these recall messages

    Dim fdrContacts As Outlook.MAPIFolder
  Dim objContactItem As Object
 
 
  'Dim objContactItem As Object
  Set fdrContacts = Application.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox)
  Set fdrDest = fdrContacts.Folders("AutoTicket Backup")
 

      For Each objContactItem In fdrContacts.Items
        readSubject = LCase(objContactItem.Subject)
        'If InStr(readSubject, "recall:") Then
        'objContactItem.Delete
       
        If TypeName(objContactItem) <> "MailItem" Then
            objContactItem.Move (fdrDest)
       End If
       
       
   
             
       
       
  Next
0
Comment
Question by:Cyart
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 

Author Comment

by:Cyart
ID: 18889659
The error that pops up in a dialog box is

The current form cannot be opened etc.

I have used the on error resume next but the macro only completes once the ok button has been clicked on the dialog box so all other mails are only processed after the event
0
 
LVL 76

Accepted Solution

by:
David Lee earned 500 total points
ID: 18897545
Hello, Cyart.

Instead of checking the subject line for the word "recall" try testing the message's MessageClass property for IPM.Outlook.Recall.  I also recommedn testing the item's Class property rather than using TypeName.  For messages Class will equal olMail.
0
 

Author Comment

by:Cyart
ID: 18958142
Thanks for your help works a treat
0
 

Author Comment

by:Cyart
ID: 18970110
Hello,

Slight problem as I cant quite get the code to process the recall mails properly along with standard mail. Please can you supply me with a code sample based on the previously supplied
0
 
LVL 76

Expert Comment

by:David Lee
ID: 18970624
Something like this:

Dim fdrContacts As Outlook.MAPIFolder
Dim objContactItem As Object
'Dim objContactItem As Object
Set fdrContacts = Session.GetDefaultFolder(olFolderInbox)
Set fdrDest = fdrContacts.Folders("AutoTicket Backup")
For Each objContactItem In fdrContacts.Items
    If objContactItem.MessageClass = "IPM.Outlook.Recall" Then
        'objContactItem.Delete
    End If
    If objContactItem.Class = olMail Then
        objContactItem.Move (fdrDest)
    End If
Next
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This article describes how to import Lotus Notes Contacts into Outlook 2016, 2013, 2010 and 2007 etc. with a few manual steps. You can easily export and migrate Lotus Notes contacts into Microsoft Outlook without having to use any third party tools.
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …
CodeTwo Sync for iCloud (http://www.codetwo.com/sync-for-icloud?sts=6554) automatically synchronizes your Outlook 2016, 2013, 2010 or 2007 folders with iCloud folders available via iCloud Control Panel. This lets you automatically sync them with…

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question