Solved

Outlook VBA Recall Messages

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Many people use more than one email account and so it becomes difficult for them to manage them when they use separate accounts,  so, in this article, I have shared an easy way to add Other Mail Accounts in your Google Inbox. It helps to combine all…
When you have clients or friends from around the world, it becomes a challenge to arrange a meeting or effectively manage your time. This is where Outlook's capability to show 2 time zones in one calendar comes in handy.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
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…

830 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