Archiving Emails

  • Thread starter Thread starter Mark Ivey
  • Start date Start date
M

Mark Ivey

Is there a way to move all messages in my inbox to my personal archive
folder into a subfolder with the email name that each email is from (if it
doesn't already exist).\

I am pretty proficient with VBA in MS Excel and have dabbled with VBScript,
therefore I may need some basic instructions on how to put this final
package together as well.

TIA for any help...

Mark Ivey
 
Michael,

Thanks for your reply...

I actually got my answer in another thread:

Here is my finished product if anyone was interested:
__________________________________________________________________________________
Special thanks to: Eric Legault, Steven Harvey, and Sue Mosher for helping
derive the version posted below.
__________________________________________________________________________________
Sub ArchiveToFolder()
On Error Resume Next

Dim objFolder As Outlook.MAPIFolder, objInbox As Outlook.MAPIFolder
Dim objNS As Outlook.NameSpace, objItem As Outlook.MailItem
Dim myFolder As String

myFolder = Format(Date, "yyyy") ' My personal folder is labeled as the
current year (ie - '2007')

Set objNS = Application.GetNamespace("MAPI")
Set objInbox = objNS.GetDefaultFolder(olFolderInbox)
Set objFolder = objNS.Folders(myFolder)

If Application.ActiveExplorer.Selection.Count = 0 Then
'Require that this procedure be called only when a message is
selected
Exit Sub
End If

For Each objItem In Application.ActiveExplorer.Selection

If FolderExist(objItem.SenderName) = False Then
objFolder.Folders.Add (objItem.SenderName)
End If

Set objFolder = objNS.Folders(myFolder).Folders(objItem.SenderName)

If objFolder.DefaultItemType = olMailItem Then
If objItem.Class = olMail Then
objItem.Move objFolder
Set objFolder = objNS.Folders(myFolder)
End If
End If
Next

Set objItem = Nothing
Set objFolder = Nothing
Set objInbox = Nothing
Set objNS = Nothing

End Sub

Function FolderExist(sFileName As String) As Boolean
FolderExist = IIf(Dir(sFileName, vbDirectory) <> "", True, False)
End Function
__________________________________________________________________________________


Mark Ivey
 
Back
Top