Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Outlook VBA mail Type

Posted on 2007-03-28
4
Medium Priority
?
634 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 2000 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Mailbox Overload?
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
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…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

610 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