Trouble using SaveAs

K

KenR

I have adapted code found here to try to save the selected e-mail to a
specific location external to Outlook. The code crashes on the SaveAs line,
giving an error message, "The messaging interface has returned an unknown
error. If the problem persists, restart Outlook (-278462338)" The error
number varies.

I am using Outlook 2003.

The code in question is:

On Error GoTo Err_SaveMe
Dim TheEmail As MailItem
Dim Path As String
Dim strSubj As String


Set TheEmail = Application.ActiveExplorer.Selection(1)

'remove illegal characters from subject
strSubj = Replace(TheEmail.Subject, "/", "-")
strSubj = Replace(strSubj, "\", "-")
strSubj = Replace(strSubj, ":", "--")
strSubj = Replace(strSubj, "?", sReplace)
strSubj = Replace(strSubj, Chr(34), sReplace)
strSubj = Replace(strSubj, "<", sReplace)
strSubj = Replace(strSubj, ">", sReplace)
strSubj = Replace(strSubj, "|", sReplace)


Path = "K:\"
TheEmail.SaveAs Path & strSubj, olMSG


Exit Sub
Err_SaveMe:
MsgBox Err.Description & " (" & Err.Number & ")"

End Sub

Any help would certainly be appreciated....
 
K

Ken Slovak - [MVP - Outlook]

The path actually exists and you can save there using the UI?

What happens if you do so, do you get any errors?

What if you try using another save format other than olMSG?
 
S

Sue Mosher [MVP]

Most likely, the problem is with the file name/path. Either the target
folder doesn't exist, the user doesn't have permission to create items
there, or it already has too many items. Or the file name is invalid. I
noticed that you are not adding an msg extension to the file name.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top