J
jon morgan
Hi All
Can anyone see what's wrong with the following code snippet:
Private Function GetOutlookFolder(ByVal foldername As String) As
Outlook.MAPIFolder
Try
oApp = CreateObject("Outlook.Application")
oNS = oApp.GetNamespace("mapi")
oNS.Logon("Outlook", "", False, False)
Catch doh As System.Exception
MessageBox.Show(doh.Message)
Return Nothing
End Try
Return oNS.GetDefaultFolder
(Outlook.OlDefaultFolders.olFolderContacts).Folders.Item(foldername)
End Function
The error is thrown at oNS.Logon - "Outlook server unavailable".
If I use oApp=GetObject("",OutlookApplication") the code works fine as long
as Outlook is already booted, but I want to boot it programmatically.
Thanks for your help.
Jon
Can anyone see what's wrong with the following code snippet:
Private Function GetOutlookFolder(ByVal foldername As String) As
Outlook.MAPIFolder
Try
oApp = CreateObject("Outlook.Application")
oNS = oApp.GetNamespace("mapi")
oNS.Logon("Outlook", "", False, False)
Catch doh As System.Exception
MessageBox.Show(doh.Message)
Return Nothing
End Try
Return oNS.GetDefaultFolder
(Outlook.OlDefaultFolders.olFolderContacts).Folders.Item(foldername)
End Function
The error is thrown at oNS.Logon - "Outlook server unavailable".
If I use oApp=GetObject("",OutlookApplication") the code works fine as long
as Outlook is already booted, but I want to boot it programmatically.
Thanks for your help.
Jon