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....
 
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....
>
 
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....
>
 
Ken -

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

worked!
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
M Trouble using keyboard shortcut for color categories in Outlook 2016 Using Outlook 3
N Trouble with server names Using Outlook 1
E Having some trouble with a run-a-script rule (moving mail based on file type) Outlook VBA and Custom Forms 5
G Trouble with Office 365/2016 Using Outlook 3
M Trouble downloading Outlook on an Android phone Using Outlook 4
B Trouble Starting Outlook 2010 after Crash Using Outlook 3
U Trouble migrating Contacts (2002) to People (2013) Using Outlook 3
K New to BCM - trouble importing contacts & accounts BCM (Business Contact Manager) 3
makinmyway Trouble Installing BCM Outlook 2013; Endless Install Loop Happens Using Outlook 0
B Trying to get old emails from a not working computer but having trouble. Using Outlook 6
M Trouble Importing folders from Outlook 2007 to Outlook 2013 Using Outlook 12
S trouble with Outlook 2010 saving sent emails Using Outlook 2
B Trouble Locating Tools Menu since There's No Standard Toolbar in Office 2010 Using Outlook 1
T Outlook 2007 - trouble with alphabetizing when titles are used (ie - Mr.) Using Outlook 0
M Outlook 2010 stuck in Work Offline mode; trouble sending email Using Outlook 1
A Trouble importing data to radio buttons Business Contact Manager 2010 (BCM) Using Outlook 2
B Trouble Adding @Outlook.com Email Accounts Using Outlook 3
A emails disappearing from inbox outlook 2010 exchange server 2010 major trouble Exchange Server Administration 6
K Trouble converting the ANSI PST to a Unicode PST Using Outlook 4
V Trouble Running Outlook 2007 and 2010 Using Outlook 4
U Trouble for sharing Calendar Using Outlook 3
S Trouble setting up Outlook Connector to sync with windows live Using Outlook.com accounts in Outlook 3
T Trouble with creating database BCM (Business Contact Manager) 1
M having trouble importing excel data into outlook contacts BCM (Business Contact Manager) 1
M trouble connection to remote database BCM (Business Contact Manager) 1
H using VBA to edit subject line Outlook VBA and Custom Forms 0
e_a_g_l_e_p_i Need clarification on 2-Step Verification for Gmail using Outlook 2021 Using Outlook 10
e_a_g_l_e_p_i Outlook 2021 not letting me setup my Gmail using pop Using Outlook 1
Geldner Problem submitting SPAM using Outlook VBA Form Outlook VBA and Custom Forms 2
O How to find out the domain and server settings that my Outlook is using? Using Outlook 2
S Outlook 2019 Custom outlook Add-in using Visual Studio Outlook VBA and Custom Forms 0
D Outlook 2021 Using vba code to delete all my spamfolders not only the default one. Outlook VBA and Custom Forms 0
M using excel to sort outlook appointment items Outlook VBA and Custom Forms 4
R Advise on using multiple instances of network files based on customers Outlook VBA and Custom Forms 8
HarvMan Using Emojis in Outlook 365 Using Outlook 3
T Outlook 2019 Not Using Auto Compete After Deletion of 365 Using Outlook 1
M USING INITIALS AS RECIPIENTS Using Outlook 1
T Outlook 2019 Using Gmail aliases in Outlook Using Outlook 6
M Saving emails using Visual Basic - Selecting folder with msoFileDialogFolderPicker Outlook VBA and Custom Forms 6
Z Import Tasks from Access Using VBA including User Defined Fields Outlook VBA and Custom Forms 0
justicefriends How to set a flag to follow up using VBA - for addressee in TO field Outlook VBA and Custom Forms 11
M Extract "Date sent" from emails (saved to folder using drag and drop) Outlook VBA and Custom Forms 1
I Outlook for Mac 2019 using on desktop and laptop IMAP on both need help with folders Using Outlook 1
David McKay VBA to manually forward using odd options Outlook VBA and Custom Forms 1
H Stationery using between OL 2019 and OL 2010 Using Outlook 0
P Prevent Outlook 2016 from using DASL filter Using Outlook 4
O Calendar - Location: what happens when using my own way of entering locations Using Outlook 1
M Disable Contact Card Results when using "Search People" in Outlook Ribbon Using Outlook 7
K can't get custom form to update multiple contacts using VBA Outlook VBA and Custom Forms 3
S Outlook VBA How to adapt this code for using in a different Mail Inbox Outlook VBA and Custom Forms 0

Similar threads

Back
Top