Solved

Adding a contact item to a public folder using CDO

Posted on 2002-07-17
3
295 Views
Last Modified: 2007-12-19
I am Trying to add a contact item to a public folder using CDO in a VB application. Problem i am having is populating the correct field. eg Business Address City in this case:

‘Ref CDO 1.21 Lib
Set objMessages = objFolder.Messages
Set objContact = objMessages.Add
objContact.Type = "IPM.Contact"
Set objFields = objContact.Fields

objFields.Add CdoPR_DISPLAY_NAME, "CH DISPLAY NAME!"
objFields.Add cdoPR_COMPANY_NAME, "My Company"
objFields.Add &H3A27001E, “London”    ‘ Business Address City
objContact.Update True, True


I want the Business Address City field to be populated, so that you can see the address on the General tab of the contact item - however the field that is populated is the City field on the All Fields tab - and doesn’t feature in the business address city field.

Any Thoughts
0
Comment
Question by:little2do
3 Comments
 

Author Comment

by:little2do
Comment Utility
Solved the problem, just not sure how to delete the question...

Soultion is :

Set objContact = objFolder.Messages.Add

objContact.Type = "IPM.Contact"

objContact.Subject = "Subject2"

Set objContactFields = objContact.Fields

objContactFields.Add CdoPR_COMPANY_NAME, "Company Name"
objContactFields.Add CdoPR_SURNAME, "Surname"
objContactFields.Add CdoPR_MIDDLE_NAME, "Middle Name"
objContactFields.Add CdoPR_GIVEN_NAME, "Given Name"

' Write Outlook "FileAs" field
objContactFields.Add CdoContact_FileUnder, 8, objContact.Subject, CdoPropSetID3
objContactFields.Add CdoContact_FileUnderID, 3, &HFFFFFFFF, CdoPropSetID3

' Write Outlook "Business Address" fields
 strAddress = "Line 1" & Chr(13) & "Line 2" & Chr(13) & "Line 3" & Chr(13) & "Line 4" & Chr(13) & "Line 5"

objContactFields.Add CdoContact_BusinessAddressStreet, 8, "Business Street", CdoPropSetID3
objContactFields.Add CdoContact_BusinessAddressCity, 8, "Business City", CdoPropSetID3
objContactFields.Add CdoContact_BusinessAddressState, 8, "Business State", CdoPropSetID3
objContactFields.Add CdoContact_BusinessAddressPostalCode, 8, "Business Postcode", CdoPropSetID3
objContactFields.Add CdoContact_BusinessAddressCountry, 8, "Business Country", CdoPropSetID3
objContactFields.Add CdoContact_BusinessAddress, 8, strAddress, CdoPropSetID3

' Write Outlook "Mailing Address" fields with the same values as the selected address
objContactFields.Add CdoPR_STREET_ADDRESS, "Street"
objContactFields.Add CdoPR_LOCALITY, "Locality"
objContactFields.Add CdoPR_STATE_OR_PROVINCE, "State"
objContactFields.Add CdoPR_POSTAL_CODE, "Postcode"
objContactFields.Add CdoPR_BUSINESS_ADDRESS_COUNTRY, "Country"
objContactFields.Add CdoPR_POSTAL_ADDRESS, strAddress, CdoPropSetID3

' Write Outlook "Selected Address" field
objContactFields.Add CdoContact_SelectedAddress, 3, 2, CdoPropSetID3

' Add phone and fax fields
objContactFields.Add CdoPR_BUSINESS_TELEPHONE_NUMBER, "tel bus"
objContactFields.Add CdoPR_BUSINESS_FAX_NUMBER, "Bus FAX"
objContactFields.Add CdoPR_COMPANY_MAIN_PHONE_NUMBER, "Main tel"
objContactFields.Add CdoPR_MOBILE_TELEPHONE_NUMBER, "mobile"


' Add contact categories
'objContactFields.Add CdoContact_Categories, 8200, "Category", CdoPropSetID5

' Update contact item
objContact.Update True, True

0
 
LVL 49

Expert Comment

by:DanRollins
Comment Utility
little2do, an EE Moderator will handle this for you.
Moderator, my recommended disposition is:

    Refund points and save as a 0-pt PAQ.

DanRollins -- EE database cleanup volunteer
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
Comment Utility
Question placed in PAQ

Computer101
E-E Admin
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now