Accessing Outlook through vb.net

liunx

Guest
I have this error: COM object with CLSID {0006F03A-0000-0000-C000-000000000046} is either not valid or not registered

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Create Outlook application.
Dim oApp As Outlook.Application
oApp = New Outlook.Application

'Get NameSpace and Logon.
Dim oNS As Outlook.NameSpace
oNS = oApp.GetNamespace(Type:="MAPI")
oNS.Logon()

' Get the first contact from the Contacts folder.
Dim cContacts As Outlook.MAPIFolder = oNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts.olFolderContacts)
Dim oItems As Outlook.Items = cContacts.Items

Dim oCt As Outlook.ContactItem

Try

oCt = oItems.GetFirst()


' Display some common properties.

Response.Write(oCt.FullName)
Response.Write(oCt.Title)
Response.Write(oCt.Birthday)
Response.Write(oCt.CompanyName)
Response.Write(oCt.Department)
Response.Write(oCt.Body)
Response.Write(oCt.FileAs)
Response.Write(oCt.Email1Address)
Response.Write(oCt.BusinessHomePage)
Response.Write(oCt.MailingAddress)
Response.Write(oCt.BusinessAddress)
Response.Write(oCt.OfficeLocation)
Response.Write(oCt.Subject)
Response.Write(oCt.JobTitle)

Catch ex As System.Exception
Response.Write(ex)

Response.Write("-an error occurred")


Finally

' Display
'oCt.Display(True)

' Log off.
oNS.Logoff()

' Clean up.
oApp = Nothing
oNS = Nothing
oItems = Nothing
oCt = Nothing

End Try

End Sub

Please help!!!
Thanks
 
Back
Top