Solved

Outlook VBA Recall Messages

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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

If you don't know how to downgrade, my instructions below should be helpful.
Following basic email etiquette rules will help you write a professional email and achieve a good, lasting impression with your contacts.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

710 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