Solved

Outlook VBA Recall Messages

Posted on 2007-04-11
5
1,644 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
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks for your help works a treat
0
 

Author Comment

by:Cyart
Comment Utility
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
Comment Utility
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
Outlook Free & Paid Tools
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…
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

743 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now