From: Walter Wang [MSFT] on
Hi Don,

Use 0x800300FC for example, its binary representation is "10000000 00000011
00000000 11111100", the facility code is FACILITY_STORAGE (3) (see
winerror.h for complete list). This means the error is related to storage
system. Other common facility code is FACILITY_WIN32 (7).

I'm curious why the exception code is random on your side, on my side, when
I used "?.msg" as the file name, the error code will always be 0x800300FC.
As you can see from the error constant STG_E_INVALIDNAME, the facility code
does matter for the error message interpretation.

To answer your question, I don't think "And &H800FFFFF" is the correct way
to do here. We need to first find out why the exception code is random.
Would you please post your code here so that I can test it on my side?
Thanks.


Regards,
Walter Wang (wawang(a)online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.


From: Don on
Hi Walter,

Please see below for the code you requested. Just to make sure that some
other portion of my app wasn't causing a problem, I broke out the relevant
portion and placed it in a button sub of a new project.

For some unknown reason, each click of Button1 results in a different
COMException.ErrorCode. I'm using VS 2005 and Outlook 2000 SR-1
(9.0.0.4527), but the result is the same using Outlook 2003.

Please let me know the result of your tests.

Thanks,
Don


(project needs COM Outlook as a Reference)
(Form1 needs a Button and a Label)

Option Explicit On
Option Strict On
'******************************************************
Imports System.IO
Imports System.Runtime.InteropServices

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim lstrFailureReason As String = ""

Try
Dim oa As New Outlook.Application
Dim ons As Outlook.NameSpace = oa.GetNamespace("MAPI")
Dim f As Outlook.MAPIFolder
f = ons.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox)
Dim i As Object
i = f.Items.GetFirst
If Not i Is Nothing Then
If TypeOf i Is Outlook.MailItem Then
Dim imi As Outlook.MailItem = CType(i, Outlook.MailItem)
imi.SaveAs("C:\?", Outlook.OlSaveAsType.olMSG)
End If
End If

Catch objEX As Exception
If TypeOf objEX Is COMException Then
Dim objComEX As COMException = CType(objEX, COMException)
Dim objEX2 As Exception =
Marshal.GetExceptionForHR(objComEX.ErrorCode)
lstrFailureReason = "ComEX: " & objEX2.Message
objComEX = Nothing
objEX2 = Nothing
Else
lstrFailureReason = "EX: " & objEX.Message
End If
Me.Label1.Text = lstrFailureReason
End Try

End Sub
End Class


"Walter Wang [MSFT]" <wawang(a)online.microsoft.com> wrote in message
news:F3TDZr8OHHA.2304(a)TK2MSFTNGHUB02.phx.gbl...
> I'm curious why the exception code is random on your side, on my side,
when
> I used "?.msg" as the file name, the error code will always be 0x800300FC.
> As you can see from the error constant STG_E_INVALIDNAME, the facility
code
> does matter for the error message interpretation.
>
> To answer your question, I don't think "And &H800FFFFF" is the correct way
> to do here. We need to first find out why the exception code is random.
> Would you please post your code here so that I can test it on my side?
> Thanks.


From: Walter Wang [MSFT] on
Hi Don,

Thank you for your code.

I've reproduced the issue on a system with Outlook 2003 installed. However,
it correctly returns correct result on a system with Outlook 2007 installed:

ComEX: The name is not valid. (Exception from HRESULT: 0x800300FC
(STG_E_INVALIDNAME))


That's why I didn't reproduce the issue previously. This looks like an
issue fixed in Outlook 2007. I'm currently consulting this in our internal
discussion list to see if there's any workaround for Outlook 2000/2003.
I'll get back to you as soon as possible, thank you for your feedback.

Regards,
Walter Wang (wawang(a)online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.


From: Don on
Hi Walter,

I'm certainly glad you were able to reproduce the problem using Outlook
2003. I'm hopeful that your discussion group can find a fix. My previous
suggestion of ANDing the HRESULT with 0x800FFFFF would only work for
Facility Codes less than or equal to 0xF.

Thanks,
Don

"Walter Wang [MSFT]" <wawang(a)online.microsoft.com> wrote in message
news:LQ5mC3iPHHA.2304(a)TK2MSFTNGHUB02.phx.gbl...
> I've reproduced the issue on a system with Outlook 2003 installed.


From: Walter Wang [MSFT] on
Hi Don,

After further researching and consulting, I think you could use following
workaround to get the correct HRESULT, please note this workaround is only
valid for the Outlook automation interface:

Dim e2 As System.Exception = Marshal.GetExceptionForHR(ce.ErrorCode And Not
&H7FFF0000)

It basically clears out some bits of the HRESULT which is irrelevant here.
This should work on Outlook 2000, 2003 and 2007 and above.

Let me know if you have any questions.

Regards,
Walter Wang (wawang(a)online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.