A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Moving a Mix of Mail Items and Report Items



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old January 23rd 06, 10:50 PM posted to microsoft.public.outlook.program_vba
Steve Roberts
external usenet poster
 
Posts: 3
Default Moving a Mix of Mail Items and Report Items

The code below moves any mail items older than X to a specified folder. It
works fine except when it hits a read reciept or an admistrative bounce back
message. If it hits either of these it throws and error # 424 "Object
required"



Any ideas on how I might be able to move the report items?



Thanks for any suggestions you might have.



Steve



Private Sub ProcessFolder(CurrentFolder As Outlook.MAPIFolder, RestrictDate
As Date)



Dim olTempItem As Object

Dim myOlApp As New Outlook.Application

Dim myNS As Outlook.NameSpace

Dim myRestrictItems As Items

Dim fldNew As Outlook.MAPIFolder

Dim intcount As Integer

Dim I As Long



Set myOlApp = CreateObject("Outlook.Application")

Set myNS = myOlApp.GetNamespace("MAPI")

Set fldNew = myNS.Folders(CurrentFolder.Name)

Set olTempItem = CurrentFolder.Items

Set myRestrictItems = olTempItem.Restrict("[ReceivedTime] '" &
RestrictDate & "'")



If myRestrictItems.Count = 0 Then Exit Sub

intcount = myRestrictItems.Count



For I = intcount To 1 Step -1



Set olTempItem = myRestrictItems(I)



If olTempItem.FlagStatus 0 Then olTempItem.FlagStatus = 0



olTempItem.Move(fldNew)



Next



End Sub


  #2  
Old January 24th 06, 10:36 PM posted to microsoft.public.outlook.program_vba
Eric Legault [MVP - Outlook]
external usenet poster
 
Posts: 830
Default Moving a Mix of Mail Items and Report Items

The error is likely due to certain properties not being available on those
kinds of item types. Before doing anything more with olTempItem, check that
olTempItem.Class = olMail before doing anything else with it. You can also
check that olTempItem.MessageClass = "IPM.Note" as well.

--
Eric Legault (Outlook MVP, MCDBA, old school WOSA MCSD, B.A.)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


"Steve Roberts" wrote:

The code below moves any mail items older than X to a specified folder. It
works fine except when it hits a read reciept or an admistrative bounce back
message. If it hits either of these it throws and error # 424 "Object
required"



Any ideas on how I might be able to move the report items?



Thanks for any suggestions you might have.



Steve



Private Sub ProcessFolder(CurrentFolder As Outlook.MAPIFolder, RestrictDate
As Date)



Dim olTempItem As Object

Dim myOlApp As New Outlook.Application

Dim myNS As Outlook.NameSpace

Dim myRestrictItems As Items

Dim fldNew As Outlook.MAPIFolder

Dim intcount As Integer

Dim I As Long



Set myOlApp = CreateObject("Outlook.Application")

Set myNS = myOlApp.GetNamespace("MAPI")

Set fldNew = myNS.Folders(CurrentFolder.Name)

Set olTempItem = CurrentFolder.Items

Set myRestrictItems = olTempItem.Restrict("[ReceivedTime] '" &
RestrictDate & "'")



If myRestrictItems.Count = 0 Then Exit Sub

intcount = myRestrictItems.Count



For I = intcount To 1 Step -1



Set olTempItem = myRestrictItems(I)



If olTempItem.FlagStatus 0 Then olTempItem.FlagStatus = 0



olTempItem.Move(fldNew)



Next



End Sub



 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Inbox, Sent Items & Outbox in Deleted Items in Outlook 2003 & OWA with Exchange splounx Outlook - General Queries 1 February 17th 06 02:22 AM
Delete items from sent items box Selector007 Outlook - General Queries 1 February 13th 06 09:47 PM
Moving items to folders does not work SSI Outlook - General Queries 0 February 8th 06 04:11 AM
How to hide Read items? I want to see only the Unread Items in my view. [email protected] Outlook - General Queries 3 February 7th 06 02:56 PM
How do I get sent items to be shown in my sent items folder? Sue B Outlook - General Queries 8 January 28th 06 07:46 PM


All times are GMT +1. The time now is 04:56 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.