Solved

Outlook VBA mail Type

Posted on 2007-03-28
4
622 Views
Last Modified: 2009-07-29
Hello,

I need to validate using VBA in outlook the type of mail coming in. As Mails are fine but read receipts are creating runtime error 13 type mismatch. I have tried declaring the mail item as type Outlook.Reportitem with no luck

Sub moveReceipt()

    Dim fdrContacts As Outlook.MAPIFolder
  Dim objContactItem As Outlook.ReportItem
   

  'Create an instance of the Contacts folder and destination folder
  Set fdrContacts = Application.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox)
  Set fdrDest = fdrContacts.Folders("AutoTicket Backup")
 
 
 

      For Each objContactItem In fdrContacts.Items
 
       
        If objContactItem.Class = olReport Then
            objContactItem.Move (fdrDest)
       
       End If
           
       
       
  Next
   
       
   

End Sub
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
  • 2
  • 2
4 Comments
 
LVL 35

Expert Comment

by:mvidas
ID: 18807946
Hi Cyart,

Dimension objContactItem as an Object, then when iterating through the items of a mapifolder, use TypeName to get the type of object (so you won't get the type mismatch error)

Dim objContactItem As Object
'...
      For Each objContactItem In fdrContacts.Items
        If TypeName(objContactItem) = "ReportItem" Then
            objContactItem.Move fdrDest
       End If


Matt
0
 

Author Comment

by:Cyart
ID: 18810476
Matt,

Thanks for the quick response, Much appreciated. Ill give it a whirl this evening
0
 
LVL 35

Accepted Solution

by:
mvidas earned 500 total points
ID: 18810564
Take your time, and let me know if you need anything else!
Matt
0
 

Author Comment

by:Cyart
ID: 18810590
cheers

Paul
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

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…
How to resolve IMCEAEX NDRs in Exchange or Exchange Online related to invalid X500 addresses.
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…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

732 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