Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Outlook behaving oddly

Status
Not open for further replies.

1DMF

Programmer
Jan 18, 2005
8,795
0
0
GB
Hi,

Can someone advise why the following code would produce the opposite effect?

Code:
        Set oItems = oApp.GetNamespace("MAPI").GetDefaultFolder(olSentItems).Items

        ' Get last item
        Set oMsg = oItems.GetLast

When oMsg is interrogated it is getting the first email ever sent not the last email sent from the user's sent items.

Why would exchange / outlook be doing this for only one particular user, all other users the code works as expected?

Thanks,

1DMF.

"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Free Electronic Dance Music
 
I refactored the code..

Code:
Set oItems = oApp.GetNamespace("MAPI").GetDefaultFolder(olSentItems).Items.Restrict("[SentOn] > '" & Format(DateAdd("n", -(iMinutes), Now()), "ddddd h:nn AMPM") & "'")

I have an attribute iMinutes, that can be set and it gets all emails from sent items within the last iMinutes (default = 30).

It has resolved the problem?


"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Free Electronic Dance Music
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top