Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
| Search | Today's Posts | Mark Forums Read
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old April 12th, 2004, 09:17 AM
Authorized User
Join Date: Oct 2003
Location: Glasgow, , United Kingdom.
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default VBA in Outlook: Problems retrieving dates

Hi everyone

Not sure if anyone can help me but have can't seem to find anywhere else for help. Ok, here's the problem.

I can't retrieve the date of the newest/oldest email in a folder. I'm only getting the subject header back in the variable. Here is the code so far:

Set ofcPersonalFolders = Application.GetNamespace("MAPI").Folders.GetLast.F olders
Set ofFolder = ofcPersonalFolders.GetLast.Folders
Set newFolder = ofFolder.GetFirst
Set ItemDate = newFolder.Items.GetFirst
FirstItem = DateValue(ItemDate)

It comes up with a type mismatch error, and when you hover over the yellow strip it shows the subject tital being displayed in FistItem

Can anyone help me out??

Thanks in advance.
  #2 (permalink)  
Old April 13th, 2004, 07:59 AM
Friend of Wrox
Points: 4,007, Level: 26
Points: 4,007, Level: 26 Points: 4,007, Level: 26 Points: 4,007, Level: 26
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jun 2003
Location: Lansing, Michigan, USA.
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG

Are you sure that you're not supposed to get one of many items (i.e. an array), not just the first? For example:

Set ItemDate = newFolder.Items(X).GetFirst

Where X is the array number (probably starting at zero)?

What I'm saying is that maybe NewFolder is not ONLY the date, but four or five items. And perhaps the date is the third item. Therefore, in that scenario:

Set ItemDate = newFolder.Items(2).GetFirst

Check to make sure what you're actually getting when you declare

Set newFolder = ofFolder.GetFirst

My guess is you're getting more than only a date and you need to specify which one of the items you want. If you don't, you get the first thing, i.e. subject header. Since subject header is a string and not a date, you get the mismatch error when you use the DateValue function.

Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division

Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA code for entering the same data for dates rohit_ghosh Access VBA 1 May 3rd, 2007 09:45 AM
problems in retrieving attribute value.... vcplearner All Other Wrox Books 0 October 17th, 2005 05:22 PM
Outlook calendar Selected Dates? avinashgavali Access 0 January 24th, 2005 01:42 AM
Having problems retrieving an array to a table! penta Access 2 September 27th, 2004 07:23 AM
retrieving a value in VBA clueless_may Access 1 May 3rd, 2004 05:39 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.