Trouble using SaveAs

Status
Not open for further replies.
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?

"KenR" <KenR> wrote in message

news:B0349D6C-0274-4B9C-99E8-7381437EBAAB@microsoft.com...
> 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....
>
 
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.

Sue Mosher

"KenR" <KenR> wrote in message

news:B0349D6C-0274-4B9C-99E8-7381437EBAAB@microsoft.com...
> 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

KenR

Ken -

Thanks very much. I tried changing the format to olMSGUnicode, and that

worked!
 
Status
Not open for further replies.
Top