L
lukor
Hi,
I am using simple macro to move completed Mails to specific folder (to
be able to run it from toolbar button) - in Outlook 2003. It works
great with a little annoynace. Everytime I move an item, it's
ReceivedTime changes to the current date and time, so I completely
loose track when the mail was originaly recieved! How can I avoid this?
Thanks a lot,
Lukas.
Sub MoveSelectedMessagesToFolder(destfolder As String)
On Error Resume Next
Dim objFolder As Outlook.MAPIFolder, objInbox As Outlook.MAPIFolder
Dim objNS As Outlook.NameSpace, objItem As Outlook.MailItem
Set objNS = Application.GetNamespace("MAPI")
Set objInbox = objNS.GetDefaultFolder(olFolderInbox)
Set objFolder = objInbox.Folders(destfolder)
For Each objItem In Application.ActiveExplorer.Selection
If objFolder.DefaultItemType = olMailItem Then
If objItem.Class = olMail Then
rcvtime = objItem.ReceivedTime
' here I move the MailItem
objItem.Move objFolder
End If
End If
Next
Set objItem = Nothing
Set objFolder = Nothing
Set objInbox = Nothing
Set objNS = Nothing
End Sub
I am using simple macro to move completed Mails to specific folder (to
be able to run it from toolbar button) - in Outlook 2003. It works
great with a little annoynace. Everytime I move an item, it's
ReceivedTime changes to the current date and time, so I completely
loose track when the mail was originaly recieved! How can I avoid this?
Thanks a lot,
Lukas.
Sub MoveSelectedMessagesToFolder(destfolder As String)
On Error Resume Next
Dim objFolder As Outlook.MAPIFolder, objInbox As Outlook.MAPIFolder
Dim objNS As Outlook.NameSpace, objItem As Outlook.MailItem
Set objNS = Application.GetNamespace("MAPI")
Set objInbox = objNS.GetDefaultFolder(olFolderInbox)
Set objFolder = objInbox.Folders(destfolder)
For Each objItem In Application.ActiveExplorer.Selection
If objFolder.DefaultItemType = olMailItem Then
If objItem.Class = olMail Then
rcvtime = objItem.ReceivedTime
' here I move the MailItem
objItem.Move objFolder
End If
End If
Next
Set objItem = Nothing
Set objFolder = Nothing
Set objInbox = Nothing
Set objNS = Nothing
End Sub