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.
Similar threads
Thread starter Title Forum Replies Date
M Trouble using keyboard shortcut for color categories in Outlook 2016 Using Outlook 3
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
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 8
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
pcunite Outlook 2019/O365 Build 13127.20408 errors when using MAPI calls Using Outlook 1
B Change Font and Font size using VBA Outlook VBA and Custom Forms 9
M Outlook 2013 reminder email by using Outlook vba Outlook VBA and Custom Forms 2
X Using Outlook 2013 and Outlook 365 Using Outlook 1
A Going to folder using shortcuts Using Outlook 3
A Outlook replies not using "delivered to" address in From Using Outlook 1
Terry Sullivan E-Mails Sent Using a Group Box Result in 70 Kickbacks Using Outlook 4
O Email not leaving Outbox when using Excel VBA to sync Outlook account Outlook VBA and Custom Forms 4
K Using Outlook 2016 to draw Using Outlook 1
O Outlook 365 - suddenly unable to send using Gmail POP3 Using Outlook 10
N Disable Auto Read Receipts sent after using Advanced Find Using Outlook 4
G Outlook 2016 sync contacts directly between phone and computer using outlook 2016 Using Outlook 0
L Moving emails with similar subject and find the timings between the emails using outlook VBA macro Outlook VBA and Custom Forms 1
O Save attachments using hotkey without changing attributes Outlook VBA and Custom Forms 1

Similar threads

Top