Solved

Outlook VBA Recall Messages

Posted on 2007-04-11
5
1,685 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
  • 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

This article lists the top 5 free OST to PST Converter Tools. These tools save a lot of time for users when they want to convert OST to PST after their exchange server is no longer available or some other critical issue with exchange server or impor…
Read this checklist to learn more about the 15 things you should never include in an email signature.
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 …
Many of my clients call in with monstrous Gmail overloading issues with Outlook. A quick tip is to turn off the All Mail and Important folders from synching. Here is a quick video I made to show you how to turn off these and other folders in Gmail s…

770 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