Code Comments
Programming Forum and web based access to our favorite programming groups.Hello, I have a problem with a program (VB6) accessing outlook 2003. The program works on my computer, but when run on another users computer (same OS), generates error MAPI_E_INVALID_ENTRYID. I think the error is being generated when the program tries to rectreive either the inbox folder or messages within that folder. I don't know which exactly. If you can offer suggestions on any of the following possibillites (or other options) please let me know: a) Debugging code that will return the exact line that generates the error in the compiled program. b) I've been using Set fldr = <mapi_system_object>.Inbox to retreive the Inbox, do I need to use GetDefaultFolder instead? c) Do I need to access a infostore or make specific reference to Outlook's ID before opening folders? Thanks for any help, Joel
Post Follow-up to this messageWhat is different between the two computers? Did you create a Setup Package
to install the application on the other computer?
You could try using:
Set objFolder = objNamespace.GetDefaultFolder(olFolderInbox)
Where:
objFolder is your folder object (Dim objFolder As Outlook.MAPIFolder)
objNamespace is your namespace object (Dim objNamespace As
Outlook.NameSpace)
--or--
Set objFolder = GetFolder("Personal Folders\Inbox\")
'-------------------GetFolder Function Code--------------------------
Private Function GetFolder(strFolderPath As String) As MAPIFolder
' folder path needs to be something like
' "Public Folders\All Public Folders\Company\Sales"
Dim objApp As Outlook.Application
Dim objNS As Outlook.NameSpace
Dim colFolders As Outlook.Folders
Dim objFolder As Outlook.MAPIFolder
Dim arrFolders() As String
Dim i As Long
On Error Resume Next
strFolderPath = Replace(strFolderPath, "/", "\")
arrFolders() = Split(strFolderPath, "\")
Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")
Set objFolder = objNS.Folders.item(arrFolders(0))
If Not objFolder Is Nothing Then
For i = 1 To UBound(arrFolders)
Set colFolders = objFolder.Folders
Set objFolder = Nothing
Set objFolder = colFolders.item(arrFolders(i))
If objFolder Is Nothing Then Exit For
Next
End If
Set GetFolder = objFolder
Set colFolders = Nothing
Set objNS = Nothing
Set objApp = Nothing
End Function
'-----------------------End Function Code--------------------
--
Chris Hanscom
MVP (Visual Basic)
http://www.veign.com
--
"Joel Green" <joel.green095_nospam@sympatico.ca> wrote in message
news:EqW5d.1919$tT2.377606@news20.bellglobal.com...
> Hello,
>
> I have a problem with a program (VB6) accessing outlook 2003. The program
> works on my computer, but when run on another users computer (same OS),
> generates error MAPI_E_INVALID_ENTRYID. I think the error is being
> generated when the program tries to rectreive either the inbox folder or
> messages within that folder. I don't know which exactly. If you can
offer
> suggestions on any of the following possibillites (or other options)
please
> let me know:
>
> a) Debugging code that will return the exact line that generates the error
> in the compiled program.
> b) I've been using Set fldr = <mapi_system_object>.Inbox to retreive the
> Inbox, do I need to use GetDefaultFolder instead?
> c) Do I need to access a infostore or make specific reference to Outlook's
> ID before opening folders?
>
> Thanks for any help,
> Joel
>
>
Post Follow-up to this messageThanks Chris, I'll give that a try.
Both computers are running XP Pro sp2 and Office 2003. I did create a setup
package. (which caused a whole mess of other problems with sp1 before the
client updated!) The problem seems to be with the code now.
Joel
"Veign" <NOSPAMinveign@veign.com> wrote in message
news:uQvKkfLpEHA.2784@TK2MSFTNGP14.phx.gbl...
> What is different between the two computers? Did you create a Setup
> Package
> to install the application on the other computer?
>
> You could try using:
> Set objFolder = objNamespace.GetDefaultFolder(olFolderInbox)
>
> Where:
> objFolder is your folder object (Dim objFolder As Outlook.MAPIFolder)
> objNamespace is your namespace object (Dim objNamespace As
> Outlook.NameSpace)
>
> --or--
> Set objFolder = GetFolder("Personal Folders\Inbox\")
>
> '-------------------GetFolder Function Code--------------------------
> Private Function GetFolder(strFolderPath As String) As MAPIFolder
>
> ' folder path needs to be something like
>
> ' "Public Folders\All Public Folders\Company\Sales"
>
> Dim objApp As Outlook.Application
> Dim objNS As Outlook.NameSpace
> Dim colFolders As Outlook.Folders
> Dim objFolder As Outlook.MAPIFolder
> Dim arrFolders() As String
> Dim i As Long
>
> On Error Resume Next
>
> strFolderPath = Replace(strFolderPath, "/", "\")
> arrFolders() = Split(strFolderPath, "\")
>
> Set objApp = CreateObject("Outlook.Application")
> Set objNS = objApp.GetNamespace("MAPI")
> Set objFolder = objNS.Folders.item(arrFolders(0))
>
> If Not objFolder Is Nothing Then
> For i = 1 To UBound(arrFolders)
>
> Set colFolders = objFolder.Folders
> Set objFolder = Nothing
> Set objFolder = colFolders.item(arrFolders(i))
>
> If objFolder Is Nothing Then Exit For
> Next
>
> End If
>
> Set GetFolder = objFolder
> Set colFolders = Nothing
> Set objNS = Nothing
> Set objApp = Nothing
>
> End Function
> '-----------------------End Function Code--------------------
>
>
> --
> Chris Hanscom
> MVP (Visual Basic)
> http://www.veign.com
> --
>
> "Joel Green" <joel.green095_nospam@sympatico.ca> wrote in message
> news:EqW5d.1919$tT2.377606@news20.bellglobal.com...
> offer
> please
>
>
Post Follow-up to this messageThis just occured to me....
In your example you create an instance of Outlook to access the mail. I've
been accessing it by through CreateObject("MAPI.Session") Then logging on.
Some of the users of the program use outlook and others use outlook express,
so I figured it would be easier just to change the profile name during
logon. But now I'm wondering if this might be the problem...
Joel
"Veign" <NOSPAMinveign@veign.com> wrote in message
news:uQvKkfLpEHA.2784@TK2MSFTNGP14.phx.gbl...
> What is different between the two computers? Did you create a Setup
> Package
> to install the application on the other computer?
>
> You could try using:
> Set objFolder = objNamespace.GetDefaultFolder(olFolderInbox)
>
> Where:
> objFolder is your folder object (Dim objFolder As Outlook.MAPIFolder)
> objNamespace is your namespace object (Dim objNamespace As
> Outlook.NameSpace)
>
> --or--
> Set objFolder = GetFolder("Personal Folders\Inbox\")
>
> '-------------------GetFolder Function Code--------------------------
> Private Function GetFolder(strFolderPath As String) As MAPIFolder
>
> ' folder path needs to be something like
>
> ' "Public Folders\All Public Folders\Company\Sales"
>
> Dim objApp As Outlook.Application
> Dim objNS As Outlook.NameSpace
> Dim colFolders As Outlook.Folders
> Dim objFolder As Outlook.MAPIFolder
> Dim arrFolders() As String
> Dim i As Long
>
> On Error Resume Next
>
> strFolderPath = Replace(strFolderPath, "/", "\")
> arrFolders() = Split(strFolderPath, "\")
>
> Set objApp = CreateObject("Outlook.Application")
> Set objNS = objApp.GetNamespace("MAPI")
> Set objFolder = objNS.Folders.item(arrFolders(0))
>
> If Not objFolder Is Nothing Then
> For i = 1 To UBound(arrFolders)
>
> Set colFolders = objFolder.Folders
> Set objFolder = Nothing
> Set objFolder = colFolders.item(arrFolders(i))
>
> If objFolder Is Nothing Then Exit For
> Next
>
> End If
>
> Set GetFolder = objFolder
> Set colFolders = Nothing
> Set objNS = Nothing
> Set objApp = Nothing
>
> End Function
> '-----------------------End Function Code--------------------
>
>
> --
> Chris Hanscom
> MVP (Visual Basic)
> http://www.veign.com
> --
>
> "Joel Green" <joel.green095_nospam@sympatico.ca> wrote in message
> news:EqW5d.1919$tT2.377606@news20.bellglobal.com...
> offer
> please
>
>
Post Follow-up to this messageYet another discovery,
the line that triggers the error is:
For Each msgCnt In fldrObj.Messages
Thanks,
Joel
"Veign" <NOSPAMinveign@veign.com> wrote in message
news:uQvKkfLpEHA.2784@TK2MSFTNGP14.phx.gbl...
> What is different between the two computers? Did you create a Setup
> Package
> to install the application on the other computer?
>
> You could try using:
> Set objFolder = objNamespace.GetDefaultFolder(olFolderInbox)
>
> Where:
> objFolder is your folder object (Dim objFolder As Outlook.MAPIFolder)
> objNamespace is your namespace object (Dim objNamespace As
> Outlook.NameSpace)
>
> --or--
> Set objFolder = GetFolder("Personal Folders\Inbox\")
>
> '-------------------GetFolder Function Code--------------------------
> Private Function GetFolder(strFolderPath As String) As MAPIFolder
>
> ' folder path needs to be something like
>
> ' "Public Folders\All Public Folders\Company\Sales"
>
> Dim objApp As Outlook.Application
> Dim objNS As Outlook.NameSpace
> Dim colFolders As Outlook.Folders
> Dim objFolder As Outlook.MAPIFolder
> Dim arrFolders() As String
> Dim i As Long
>
> On Error Resume Next
>
> strFolderPath = Replace(strFolderPath, "/", "\")
> arrFolders() = Split(strFolderPath, "\")
>
> Set objApp = CreateObject("Outlook.Application")
> Set objNS = objApp.GetNamespace("MAPI")
> Set objFolder = objNS.Folders.item(arrFolders(0))
>
> If Not objFolder Is Nothing Then
> For i = 1 To UBound(arrFolders)
>
> Set colFolders = objFolder.Folders
> Set objFolder = Nothing
> Set objFolder = colFolders.item(arrFolders(i))
>
> If objFolder Is Nothing Then Exit For
> Next
>
> End If
>
> Set GetFolder = objFolder
> Set colFolders = Nothing
> Set objNS = Nothing
> Set objApp = Nothing
>
> End Function
> '-----------------------End Function Code--------------------
>
>
> --
> Chris Hanscom
> MVP (Visual Basic)
> http://www.veign.com
> --
>
> "Joel Green" <joel.green095_nospam@sympatico.ca> wrote in message
> news:EqW5d.1919$tT2.377606@news20.bellglobal.com...
> offer
> please
>
>
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.