I have the following (working) VBS function that adds an existing PST file to the default Outlook profile...
I have attempted to recreate this natively in PowerBASIC using this code...
Whenever I run the PowerBASIC version it doesn't add the existing PST, it creates a new one. Can anyone see something obvious that I might be missing?
Code:
SUB AttachPST(strPSTPath) DIM objOutlookApp, objNameSpace ' Instantiate Outlook SET objOutlookApp = CreateObject("Outlook.Application") ' Get the MAPI Namespace SET objNameSpace = objOutlookApp.GetNameSpace("MAPI") ' Add the PST objNameSpace.AddStore strPSTPath ' Cleanup SET objNameSpace = NOTHING SET objOutlookApp = NOTHING END SUB
Code:
FUNCTION AttachPST( strPSTPath AS STRING ) AS LONG LOCAL objOutlookApp AS Int__Application LOCAL objNameSpace AS Int__NameSpace FUNCTION = %FALSE ' does the PST exist? IF ISFILE( strPSTPath ) THEN ' Instantiate Outlook SET objOutlookApp = NEWCOM $PROGID_Outlook_Application ' Do we have the Outlook object? IF ISOBJECT( objOutlookApp ) THEN ' Get the MAPI namespace objNameSpace = objOutlookApp.GetNamespace( UCODE$( "MAPI" )) ' Do we have a namespace? IF ISOBJECT( objNameSpace ) THEN ' Add the PST to the list of stores objNameSpace.AddStore UCODE$( strPSTPath ) 'Clean up objNameSpace = NOTHING FUNCTION = %TRUE END IF 'Clean up objOutlookApp = NOTHING END IF END IF END FUNCTION
Comment