Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 MS Access
 mapi folder

Author  Topic 

notsosuper
Posting Yak Master

190 Posts

Posted - 2005-08-23 : 16:15:42
Here my code and I put -> front of the error causing part. I don't even know
if so far until there it is doing what it should too, but how can I fix this
and if anything looks not right in this code please point out. I am writing
this in vb.net windows application. Error message is :An unhandled exception
of type 'System.MissingMemberException' occurred in microsoft.visualbasic.dll

Additional information: Public member 'itms' on type 'MAPIFolder' not found.


Public Sub getit()

Dim dao
Dim db
Dim itms
Dim itm
Dim strsql As String
Dim cn As New ADODB.Connection
Dim rst As New ADODB.Recordset
Dim oApp As Outlook.Application = New Outlook.Application
Dim oNS As Outlook.NameSpace = oApp.GetNamespace("MAPI")
Dim pf As Outlook.MAPIFolder = oNS.Folders("Public
Folders").Folders("All Public Folders")
Dim cContacts As Outlook.MAPIFolder = pf.Folders("Contacts")
Dim itt As Outlook.ContactItem
Dim strdbname


cn.ConnectionString = ("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\contacts.mdb;User Id=;Password=;")
cn.Open()
rst = New ADODB.Recordset
rst.Open("select * from customers", cn)

oNS = oApp.GetNamespace("MAPI")
pf = oNS.Folders("Public Folders").Folders("All Public Folders")
-> -> -> itm = pf.itms


Do Until rst.EOF

itm = itms.Add("IPM.Contact.Access Contact")

'Built-in Outlook properties
If IsDBNull(rst.CustomerID) = False Then itm.CustomerID =
rst.CustomerID
If IsDBNull(rst.CompanyName) = False Then itm.CompanyName =
rst.CompanyName
If IsDBNull(rst.ContactName) = False Then itm.FullName =
rst.ContactName
If IsDBNull(rst.Address) = False Then itm.BusinessAddressStreet
= rst.Address
If IsDBNull(rst.City) = False Then itm.BusinessAddressCity =
rst.City
If IsDBNull(rst.Region) = False Then itm.BusinessAddressState =
rst.Region
If IsDBNull(rst.PostalCode) = False Then
itm.BusinessAddressPostalCode = rst.PostalCode
If IsDBNull(rst.Country) = False Then itm.BusinessAddressCountry
= rst.Country
If IsDBNull(rst.Phone) = False Then itm.BusinessTelephoneNumber
= rst.Phone
If IsDBNull(rst.Fax) = False Then itm.BusinessFaxNumber = rst.Fax
If IsDBNull(rst.ContactTitle) = False Then itm.JobTitle =
rst.ContactTitle

'Custom Outlook properties
itm.UserProperties("Preferred") = rst.Preferred
itm.UserProperties("Discount") = rst.Discount
itm.Close(0)
rst.MoveNext()

Loop
rst.Close()
MsgBox("All contacts imported!")

End Sub

AjarnMark
SQL Slashing Gunting Master

3246 Posts

Posted - 2005-08-23 : 16:37:21
Shouldn't that be pf.Items ? Aren't you missing the letter E?

Object model: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbaol10/html/oltocobjectmodelapplication.asp

---------------------------
EmeraldCityDomains.com
Go to Top of Page

notsosuper
Posting Yak Master

190 Posts

Posted - 2005-08-23 : 16:45:36
I don't have items declared anywhere though
Go to Top of Page

AjarnMark
SQL Slashing Gunting Master

3246 Posts

Posted - 2005-08-23 : 16:54:52
No. Items is an intrinsic Collection of the Folders collection of the NameSpace object. You don't declare it, you just use it.

---------------------------
EmeraldCityDomains.com
Go to Top of Page

notsosuper
Posting Yak Master

190 Posts

Posted - 2005-08-23 : 17:06:02
I am so sorry, I was thinking somethingelse. I did look at the link and it helped me a lot, now I put my -> again where my question is, I think this line is not correct right? What I need to put here? Right after Do Until..

Dim dao
Dim db
Dim itms
Dim itm
Dim strsql As String
Dim cn As New ADODB.Connection
Dim rst As New ADODB.Recordset
Dim oApp As Outlook.Application = New Outlook.Application
Dim mynamespace As Outlook.NameSpace = oApp.GetNamespace("MAPI")
Dim myfolder As Outlook.MAPIFolder = mynamespace.Folders("Public Folders").Folders("All Public Folders")
Dim cContacts As Outlook.MAPIFolder = myfolder.Folders("Contacts")
Dim myitems = myfolder.Items
'Dim itt As Outlook.ContactItem
Dim strdbname


cn.ConnectionString = ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\contacts.mdb;User Id=;Password=;")
cn.Open()
rst = New ADODB.Recordset
rst.Open("select * from customers", cn)

mynamespace = oApp.GetNamespace("MAPI")
myfolder = mynamespace.Folders("Public Folders").Folders("All Public Folders")
myitems = myfolder.Items


Do Until rst.EOF

-> -> -> itm = itms.Add("IPM.Contact.Access Contact")

'Built-in Outlook properties
If IsDBNull(rst.CustomerID) = False Then itm.CustomerID = rst.CustomerID
If IsDBNull(rst.CompanyName) = False Then itm.CompanyName = rst.CompanyName
If IsDBNull(rst.ContactName) = False Then itm.FullName = rst.ContactName
If IsDBNull(rst.Address) = False Then itm.BusinessAddressStreet = rst.Address
If IsDBNull(rst.City) = False Then itm.BusinessAddressCity = rst.City
If IsDBNull(rst.Region) = False Then itm.BusinessAddressState = rst.Region
If IsDBNull(rst.PostalCode) = False Then itm.BusinessAddressPostalCode = rst.PostalCode
If IsDBNull(rst.Country) = False Then itm.BusinessAddressCountry = rst.Country
If IsDBNull(rst.Phone) = False Then itm.BusinessTelephoneNumber = rst.Phone
If IsDBNull(rst.Fax) = False Then itm.BusinessFaxNumber = rst.Fax
If IsDBNull(rst.ContactTitle) = False Then itm.JobTitle = rst.ContactTitle

'Custom Outlook properties
itm.UserProperties("Preferred") = rst.Preferred
itm.UserProperties("Discount") = rst.Discount
itm.Close(0)
rst.MoveNext()

Loop
rst.Close()
MsgBox("All contacts imported!")

End Sub
Go to Top of Page

notsosuper
Posting Yak Master

190 Posts

Posted - 2005-08-23 : 18:09:48
I think I corrected this part, but now I have to somehow connect to public folder,I corrected code above has -> -> with this one itm = myitems.Add("IPM.Contact.Contacts") and I think this part does that itm = myitems.Add("IPM.Contact.Contacts") but instead of IPM.COntact I need to put my mail server address, because I cannot do that from my local machine. HOw can I do that?
Go to Top of Page
   

- Advertisement -