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
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
N Trouble importing calender information from iPhone into OutLook 2010 Using Outlook 1
J TROUBLE SENDING EMAIL FROM OUTLOOK, NO PROBLEM RECIEVING WHEN WORKING FROM OUT OF TOWN Using Outlook 1
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
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 5
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
J Add an Attachment Using an Array and Match first 17 Letters to Matching Template .oft to Send eMail Outlook VBA and Custom Forms 2
A Edit subject - and change conversationTopic - using VBA and redemption Outlook VBA and Custom Forms 2
A Using or not using apostrophes in search terms has this changed? Using Outlook 0
O Office 365 using POP3 on both laptop and desktop Using Outlook 0
M Using field names to capture a data element Using Outlook 0
B Vba to monitor time to respond to emails using a shared mailbox Outlook VBA and Custom Forms 5
B Looking to get the Recipient email address (or even the "friendly name") from an email I am replying to using VBA Outlook VBA and Custom Forms 4
D Using a VBA Custom Form to Send Reoccurring Email Upon Task Completion Outlook VBA and Custom Forms 4
Z Adding dropdown list using custom form Outlook VBA and Custom Forms 7
O Using .OST and .PST mail thru different providers Using Outlook 5
N Open & Save VBAProject.Otm using VBA Code Outlook VBA and Custom Forms 1

Similar threads

Top