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 sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Save email msg to hard drive or network folder

Status
Not open for further replies.

lks47

Technical User
Feb 14, 2003
2
US
Does anyone have a solution to save email messages from your Outlook inbox and save a copy to your hard drive or network folder and then move the email message to a different folder in Outlook.

This is the code I have so far, but I get errors on the SaveAs line.


Sub CopyEmailMsg()

Set myApp = New Outlook.Application
Set myNS = myApp.GetNamespace("MAPI")
Set myFolder = myNS.GetDefaultFolder(olFolderInbox)
Set myDestFolder = myFolder.Folders("test")

For Count = 1 To myFolder.Items.Count
Set myMail = myFolder.Items(Count)

myMail.SaveAs "C:\My Documents\email\" & myMail.Subject & ".msg", olMSG

myMail.Move myDestFolder
myMail.Delete

Next Count

MsgBox "The email has been copied"

End Sub


Thanks for the feedback
 
What error are you getting? Does mymail.subject contain any "illegal" characters? (Such as ,*?;)
Rob
[flowerface]
 
It breaks at
myMail.SaveAs "C:\My Documents\email\" & myMail.Subject & ".msg", olMSG

I can't see anything wrong with this line of code or the objects.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top