• Subject: Re: Date functions in Outlook are the same as in Excel.
  • Author: Michael Bednarek
  • Date: 14 Feb 2011
  • References: 1 2
On Sun, 13 Feb 2011 16:11:24 GMT, John Curtis wrote in microsoft.public.outlook.program_vba:

>I would like to know if you ever figured out the Date problem. I have a very basic code
>that has incorporated portions of this but I cannot get the most recent email from a
>Specific Sender to pull up. The Macro always pulls up the oldest email.
>
>Here is the line I am struggling with:
>
>Set myItem = myItems.Find("[SenderName] = 'REPORT WRITER' AND [SentOn] = 'Date' AND [Subject] = 'GENERIC'")

As Michael Bauer wrote earlier: have a look at the help pages how to use a date with the .Find method.

Your code, as written, cannot work as intended. At minimum, it should look this:
Set myItem = myItems.Find("[SenderName] = 'REPORT WRITER' AND [SentOn] = " & strDate & " AND [Subject] = 'GENERIC'")
where strDate is a string representation of the date you're interested in. For the needed format of such a string,
you should inspect the .SentOn property of any mail item.

Michael Bednarek http://mbednarek.com/ "POST NO BILLS"
16 Feb 2010move read email based on date and sender.vbaNEWBIE
17 Feb 2010\ Re: move read email based on date and sender.Michael Bauer [MVP - ...
17 Feb 2010   \ Re: move read email based on date and sender.vbaNEWBIE
17 Feb 2010      \ Re: move read email based on date and sender.Michael Bauer [MVP - ...
17 Feb 2010         \ Re: move read email based on date and sender.vbaNEWBIE
18 Feb 2010            \ Re: move read email based on date and sender.Michael Bauer [MVP - ...
13 Feb 2011               \ Re: Date functions in Outlook are the same as in Excel..John Curtis
14 Feb 2011                  \ Re: Date functions in Outlook are the same as in Excel..Michael Bednarek
Contact Us
All times are in (US) Eastern Daylight Time (GMT -4:00)