MS Office Forum / Outlook / Interop / January 2004
Outlook Contacts in Excell or Access
|
|
Thread rating:  |
John Galt - 27 Jan 2004 17:29 GMT Can any one give me samples or suggest where I may find samples of reading Outlook Contacts from Access or Excel. I want to create a merge program that sends fax's to requestors (who exist in the contact folder).
Examples I have found do not seem to work so I am hoping someone here has experience with this.
In addition to the original request:
I can link to my contacts folder just fine. I see many of the fields I need for a report but there are some that I cannot find.
I am looking to pull the report for Items flagged for follow-up or phone calls on a certain date. Also, I need to view them by Category.
I cannot find category or the reminder flag and contents of the reminder.
Any help or a custom control that might work would be great.
Thanks in Advance
Sue Mosher [MVP] - 27 Jan 2004 18:25 GMT These pages may be useful:
http://www.slipstick.com/dev/customimport.htm http://www.slipstick.com/dev/vb.htm
The linked table method has major limitations, including the inability to show even all the reasonably important fields. While articles have been written on how to expand on this method's obvious features, I've never been able to duplicate the results. See http://www.slipstick.com/dev/database.htm#linkedtables .
That page will also give you other ideas on how to work with databases and Outlook together.
 Signature Sue Mosher, Outlook MVP Author of Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx
> Can any one give me samples or suggest where I may find samples of reading > Outlook Contacts from Access or Excel. [quoted text clipped - 18 lines] > > Thanks in Advance John Galt - 27 Jan 2004 18:53 GMT Sue,
This is the code I have so far.
Private Sub cmdTEST_Click() Dim oDatabase Dim rs1 As ADODB.Recordset Dim dbe Dim wks Dim dbs Dim nms Dim fld Dim itms Dim itm
Const olFolderContacts = 10 '########################################### '# Set Objects '###########################################
Set adoconn = CreateObject("ADODB.Connection")
accessConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Exchange 4.0;MAPILEVEL=;Database=C:\Temp;"
adoconn.ConnectionString = accessConnect adoconn.Open accessConnect
' get record set
Set rs1 = adoconn.Execute("select * from Contacts")
I get an error on the execute statement that says "The MS Jet Database engine could not find the object. Make sure you spell...."
Any help you can give me here?
> These pages may be useful: > [quoted text clipped - 40 lines] > > > > Thanks in Advance Sue Mosher [MVP] - 27 Jan 2004 19:40 GMT This is pretty much a dead-end, I think. As Ken Slovak posted here recently in another thread, you just can't get to all the fields you need through database techniques. The solution is to access items directly through the Outlook object model.
FWIW, I can't get the code to work on Outlook 2003 myself.
 Signature Sue Mosher, Outlook MVP Author of Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx
> Sue, > [quoted text clipped - 82 lines] > > > > > > Thanks in Advance John Galt - 27 Jan 2004 21:09 GMT Well I did get this working to a point. I cannot seem to figure out how to change to any folder I want to thru the Outlook.Application.
Here is what I have so far.
Private Sub cmdTEST_Click()
Dim oOutlook As New Outlook.Application Dim colItems As Items Dim tblContacts As Recordset Dim upContactId As UserProperty Dim strMessage As String Dim objFolder As Outlook.MAPIFolder
'Get a reference to the Items collection of the contacts folder.
Set colItems = oOutlook.GetNamespace("MAPI"). _ GetDefaultFolder(olFolderContacts).Items
This gives me the "Default" contacts folder to walk thru. I need to change to another folder and am having trouble doing so. Any Clues???
> This is pretty much a dead-end, I think. As Ken Slovak posted here recently > in another thread, you just can't get to all the fields you need through [quoted text clipped - 100 lines] > > > > > > > > Thanks in Advance Sue Mosher [MVP] - 27 Jan 2004 21:37 GMT To get a non-default folder, you need to walk the folder hierarchy using the Folders collections or use a function that does that for you. See http://www.slipstick.com/dev/code/getfolder.htm
 Signature Sue Mosher, Outlook MVP Author of Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx
> Well I did get this working to a point. > I cannot seem to figure out how to change to any folder I want to thru the [quoted text clipped - 19 lines] > I need to change to another folder and am having trouble doing so. > Any Clues??? John Galt - 27 Jan 2004 21:45 GMT I did that and am able to get the correct folder!!!!! Now is there anyway to expose the available field names i.e. FullName, BusineAddress etc... So I can see what is available?
Thanks for your help
> To get a non-default folder, you need to walk the folder hierarchy using the > Folders collections or use a function that does that for you. See [quoted text clipped - 30 lines] > > I need to change to another folder and am having trouble doing so. > > Any Clues??? Sue Mosher [MVP] - 27 Jan 2004 22:01 GMT When in doubt, check the object browser: Press ALt+F11 to open the VBA environment in Outlook, then press F2.
 Signature Sue Mosher, Outlook MVP Author of Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx
> Now is there anyway to expose the available field names i.e. FullName, > BusineAddress etc... So I can see what is available? John Galt - 27 Jan 2004 22:03 GMT I tried that but I Can't find anywhere that shows me the Column Names that I can use. For instance I guessed at .Fullname and .BusinessAddress but I cannot find a column name for "ItemFlag" or "FollowUpFlag.
Any other ideas?
Thanks again
> When in doubt, check the object browser: Press ALt+F11 to open the VBA > environment in Outlook, then press F2. [quoted text clipped - 8 lines] > > Now is there anyway to expose the available field names i.e. FullName, > > BusineAddress etc... So I can see what is available? John Galt - 27 Jan 2004 22:05 GMT OOOPS. Spoke to soon. I found the columns but the ones I need do not exist. Now I'm angry. All this work and the columns I need are not accessible. aaaarrrrrrrrrrrrrrrrrrrrrrrrrrggggggggggggggggggggghhhhhhhhhhhhhhhhhhhhhhhhh h!
> I tried that but I Can't find anywhere that shows me the Column Names that I > can use. [quoted text clipped - 16 lines] > > > Now is there anyway to expose the available field names i.e. FullName, > > > BusineAddress etc... So I can see what is available? Sue Mosher [MVP] - 27 Jan 2004 22:20 GMT Do you want us to try to read your mind to understand what you're looking for?
 Signature Sue Mosher, Outlook MVP Author of Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx
> OOOPS. Spoke to soon. > I found the columns but the ones I need do not exist. > Now I'm angry. All this work and the columns I need are not accessible. aaaarrrrrrrrrrrrrrrrrrrrrrrrrrggggggggggggggggggggghhhhhhhhhhhhhhhhhhhhhhhhh
> h! > [quoted text clipped - 13 lines] > > > > Now is there anyway to expose the available field names i.e. FullName, > > > > BusineAddress etc... So I can see what is available? John Galt - 27 Jan 2004 23:34 GMT I am looking for 3 specific columns that don't seem to be accessible. They are: 1. Reminder time 2. Flag Status 3. Followup Flag
These are part of contact views and I want to be able to see them from within access Just like the other columns such as FullName, BusinessAddressStreet.
If they are part of Outlook why can I not see them as part of the Outlook.Application?
> Do you want us to try to read your mind to understand what you're looking > for? [quoted text clipped - 8 lines] > > I found the columns but the ones I need do not exist. > > Now I'm angry. All this work and the columns I need are not accessible. aaaarrrrrrrrrrrrrrrrrrrrrrrrrrggggggggggggggggggggghhhhhhhhhhhhhhhhhhhhhhhhh
> > h! > > [quoted text clipped - 16 lines] > FullName, > > > > > BusineAddress etc... So I can see what is available? Sue Mosher [MVP] - 28 Jan 2004 01:43 GMT Contact flags are not exposed in the Outlook object model (along with quite a few other useful properties). You have to use CDO or Redemption to work with them. See http://www.cdolive.com/cdo10.htm for a primer.
 Signature Sue Mosher, Outlook MVP Author of Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx
> I am looking for 3 specific columns that don't seem to be accessible. They > are: [quoted text clipped - 8 lines] > If they are part of Outlook why can I not see them as part of the > Outlook.Application? John Galt - 28 Jan 2004 03:07 GMT OK I Looked at the primer but I do not know how to dim the variable objSession. i.e. Set objFolder = objSession.GetDefaultFolder(CdoDefaultFolderContacts)
Please advise.
> Contact flags are not exposed in the Outlook object model (along with quite > a few other useful properties). You have to use CDO or Redemption to work [quoted text clipped - 20 lines] > > If they are part of Outlook why can I not see them as part of the > > Outlook.Application? Sue Mosher [MVP] - 28 Jan 2004 03:20 GMT It's a CDO MAPI.Session object. Make sure you add the CDO 1.21 library to your project. See http://www.slipstick.com/dev/cdo.htm if you're new to CDO.
 Signature Sue Mosher, Outlook MVP Author of Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx
> OK I Looked at the primer but I do not know how to dim the variable > objSession. [quoted text clipped - 7 lines] > > a few other useful properties). You have to use CDO or Redemption to work > > with them. See http://www.cdolive.com/cdo10.htm for a primer.
> > > I am looking for 3 specific columns that don't seem to be accessible. > > They [quoted text clipped - 9 lines] > > > If they are part of Outlook why can I not see them as part of the > > > Outlook.Application? John Galt - 28 Jan 2004 03:22 GMT I Tried loading that dll and I get a message that says "Error Loading DLL". DO you know where I can get this dll and what its name is?
> It's a CDO MAPI.Session object. Make sure you add the CDO 1.21 library to > your project. See http://www.slipstick.com/dev/cdo.htm if you're new to CDO. [quoted text clipped - 31 lines] > > > > If they are part of Outlook why can I not see them as part of the > > > > Outlook.Application? Sue Mosher [MVP] - 28 Jan 2004 12:23 GMT It's cdo.dll, and as the page I suggested explains, it's part of your Outlook installation. Rerun Outlook/Office setup if necessary.
 Signature Sue Mosher, Outlook MVP Author of Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx
> I Tried loading that dll and I get a message that says "Error Loading DLL". > DO you know where I can get this dll and what its name is? > > > It's a CDO MAPI.Session object. Make sure you add the CDO 1.21 library to > > your project. See http://www.slipstick.com/dev/cdo.htm if you're new to > CDO.
> > > OK I Looked at the primer but I do not know how to dim the variable > > > objSession. [quoted text clipped - 24 lines] > > > > > If they are part of Outlook why can I not see them as part of the > > > > > Outlook.Application? John Galt - 28 Jan 2004 16:42 GMT According to Microsoft it is called CDONTS.DLL. CDO.DLL is the old old old version. I have the cdonts.dll and when I try to add the dll it says that it is NTS ver. 1.2 NOT 1.2.1.
I have all of the latest updates from MS installed for both XP and Office Professional. Any other hints that might help me?
> It's cdo.dll, and as the page I suggested explains, it's part of your > Outlook installation. Rerun Outlook/Office setup if necessary. [quoted text clipped - 44 lines] > > > > > > If they are part of Outlook why can I not see them as part of the > > > > > > Outlook.Application? Sue Mosher [MVP] - 28 Jan 2004 17:10 GMT No, no, no. Cdonts.dll is a completely different library, not related to Outlook at all. What you want is Collaboration Data Objects, CDO 1.21, which is an optional Outlook component. Did you rerun Office setup as I suggested?
 Signature Sue Mosher, Outlook MVP Author of Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx
> According to Microsoft it is called CDONTS.DLL. > CDO.DLL is the old old old version. [quoted text clipped - 7 lines] > > It's cdo.dll, and as the page I suggested explains, it's part of your > > Outlook installation. Rerun Outlook/Office setup if necessary.
> > > I Tried loading that dll and I get a message that says "Error Loading > > DLL". [quoted text clipped - 39 lines] > the > > > > > > > Outlook.Application? John Galt - 28 Jan 2004 17:15 GMT I reran now and have CDO.DLL! I now Have MAPI.Session working.
The next part of the code that the sample shows is Set objFolder = objSession.GetDefaultFolder(CdoDefaultFolderContacts)
When I hit this statement in the debugger I get "Object Variable or with block not set.
Here is my code taken from the example:
Private Sub cmdTEST_CLick() Dim objSession As MAPI.Session Dim objFolder As CDO.Folder 'Set objSession = oOutlook.CdoNamespace ' Get the contacts folder of the mailbox Set objFolder = objSession.GetDefaultFolder(CdoDefaultFolderContacts) ' Get the first message of the contacts folder ' Note that it is still a message object ' So the class property will always return a value of CdoMsg 'Set objMessages = objFolder.Messages 'Set objMessage = objMessages.GetFirst()
' Get the fields collection of the contact item Set objFields = objMessage.Fields
' Get a single field using the MAPI property tag Set objField = objFields.Item(PR_DISPLAY_NAME)
' For Example: Set objField = objFields.Item(&H3001001E)
' If it is a Microsoft Outlook item you can either use Set objField = objFields.Item("<PropertyTag>", "<PropertySetID>")
' For Example: Set objField = objFields.Item("0x8535", "0820060000000000C000000000000046")
' Or the following syntax if you want to read the value directly Value = objFields.Item("{" & "<PropertySetID>" & "}" & "<PropertyTag>").Value
' For Example: Value = objFields.Item("{0820060000000000C000000000000046}0x8535").Value
' If it is a Microsoft Outlook item with a custom field use the following syntax: Set objField = objFields.Item("<NameOfUserdefinedField>")
' For Example: Set objField = objFields.Item("PersonRole")
End Sub
> No, no, no. Cdonts.dll is a completely different library, not related to > Outlook at all. What you want is Collaboration Data Objects, CDO 1.21, which [quoted text clipped - 64 lines] > > the > > > > > > > > Outlook.Application? Sue Mosher [MVP] - 28 Jan 2004 17:54 GMT Did you add a reference to CDO 1.21 to your project? You can't use CDO constants in your code until you do.
Also, I don't see that you're instantiating objSession anywhere. This is the minimum if you want it to use the same session that Outlook is already running under:
Set objSession = CreateObject("MAPI.Session") objSession.Logon "", "", False, False
 Signature Sue Mosher, Outlook MVP Author of Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx
> I reran now and have CDO.DLL! > I now Have MAPI.Session working. [quoted text clipped - 103 lines] > > > the > > > > > > > > > Outlook.Application? John Galt - 28 Jan 2004 18:10 GMT Yes I did add CDO 1.21. I am now getting a type mismatch on the same statement. It does not like cdoDefaultfolderscontacts or a numeric constant of 5 or "Contacts". I do not understand why this is failing.
> Did you add a reference to CDO 1.21 to your project? You can't use CDO > constants in your code until you do. [quoted text clipped - 124 lines] > > > > the > > > > > > > > > > Outlook.Application? John Galt - 28 Jan 2004 18:19 GMT They data stamp on my CDO.DLL is 3/17/2002 3:29PM. Is this the latest dll?
> Yes I did add CDO 1.21. > I am now getting a type mismatch on the same statement. [quoted text clipped - 65 lines] > > > ' For Example: > > > Value = objFields.Item("{0820060000000000C000000000000046}0x8535").Value
> > > ' If it is a Microsoft Outlook item with a custom field use the > following [quoted text clipped - 66 lines] > > > > > the > > > > > > > > > > > Outlook.Application? Sue Mosher [MVP] - 28 Jan 2004 18:43 GMT Comments inline.
> The data stamp on my CDO.DLL is 3/17/2002 3:29PM. > Is this the latest dll? Sounds right. What's the path?
> > Yes I did add CDO 1.21. > > I am now getting a type mismatch on the same statement. > > It does not like cdoDefaultfolderscontacts or a numeric constant of 5 or > > "Contacts". > > I do not understand why this is failing. Probably because you declared objFolder as CDO.Folder, not MAPI.Folder. Make sure you get the right declaration for each variable.
 Signature Sue Mosher, Outlook MVP Author of Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx
John Galt - 28 Jan 2004 20:39 GMT I actually have this working (Well almost). The original problem was to expose 3 particular fields in the contacts folder: 1. Reminder time 2. Flag Status 3. Followup Flag
I use the CDO representations for these 3 fields:
1. CdoPR_FLAG_DUE_BY 2. CdoPR_FLAG_STATUS 3. CdoPR_ACTION_DATE
I still cannot get these variables. I get Run-time error '-2147221233 (8004010f'): [Collaboration Data Objects - [MAPI_E_NOT_FOUND(8004010F)]]
Any pointers ???
Thanks
> They data stamp on my CDO.DLL is 3/17/2002 3:29PM. > Is this the latest dll? [quoted text clipped - 147 lines] > > > > > > the > > > > > > > > > > > > Outlook.Application? Sue Mosher [MVP] - 28 Jan 2004 20:57 GMT Code snippet?
> I actually have this working (Well almost). > The original problem was to expose 3 particular fields in the contacts [quoted text clipped - 178 lines] > > > > > > > the > > > > > > > > > > > > > Outlook.Application? John Galt - 28 Jan 2004 21:23 GMT Here is the code so far.
Private Sub cmdTEST_CLick() Dim objSession As MAPI.Session Dim objFolder As MAPI.Folder Dim objmessages As MAPI.Messages Dim objFields As MAPI.Fields Dim objmessage As MAPI.Message
Set objSession = CreateObject("MAPI.Session") If Not objSession Is Nothing Then strProfileName = "MS Exchange Settings" objSession.Logon strProfileName, , False End If
Set objFolder = objSession.GetDefaultFolder(CdoDefaultFolderContacts) Set objFolder = objSession.GetFolder("00000000515BA5871FC8D5119923000475762650C2960000") 'GetFolder("My Local E-Mail\Morang Cove Trading Company\MCTC Contacts") ' Get the first message of the contacts folder ' Note that it is still a message object ' So the class property will always return a value of CdoMsg Set objmessages = objFolder.Messages Set objmessage = objmessages.GetFirst()
' Get the fields collection of the contact item 'Set objFields = objmessage.Fields
' Get a single field using the MAPI property tag Set ObjField = objFields.Item(1)
' For Example: Set ObjField = objFields.Item(&H3001001E) x = 0 On Error Resume Next
For I = 1 To objmessages.Count Set objmessage = objmessages.GetNext() Set objFields = objmessage.Fields For x = 1 To 1000 If InStr(objmessage.Field("Categories"), "Buyer") > 0 Then Debug.Print "x = " & x & " " & objFields(x) End If Next x Next I
'*** Code to review ************* ' If it is a Microsoft Outlook item you can either use Set ObjField = objFields.Item("<PropertyTag>", "<PropertySetID>")
' For Example: Set ObjField = objFields.Item("0x8013", "0820060000000000C000000000000046")
' Or the following syntax if you want to read the value directly Value = objFields.Item("{" & "<PropertySetID>" & "}" & "<PropertyTag>").Value
' For Example: Value = objFields.Item("{0820060000000000C000000000000046}0x8535").Value
' If it is a Microsoft Outlook item with a custom field use the following syntax: Set ObjField = objFields.Item("<NameOfUserdefinedField>")
' For Example: Set ObjField = objFields.Item("PersonRole")
End Sub
> Code snippet? > [quoted text clipped - 196 lines] > > > > > > > > the > > > > > > > > > > > > > > Outlook.Application? Sue Mosher [MVP] - 28 Jan 2004 22:51 GMT But which statement is giving you the runtime error?
Don't forget that you have to check for the existence of the field first, before accessing its value, since CDO only stores fields in the Fields collection if they have values.
> Here is the code so far. > [quoted text clipped - 274 lines] > > > > > > > > > the > > > > > > > > > > > > > > > Outlook.Application? John Galt - 29 Jan 2004 00:30 GMT In the following statement when I use any of the 3 cdoVariables or the Property Tag
i.e. Set ObjField = objFields.Item(&H10820040) Set ObjField = objFields.Item(CdoPR_ACTION_DATE)
> But which statement is giving you the runtime error? > [quoted text clipped - 292 lines] > > > > > > > > > > the > > > > > > > > > > > > > > > > Outlook.Application? Sue Mosher [MVP] - 29 Jan 2004 01:45 GMT Does your code actually instantiate objFields? In the sample you posted, the statement instantiating objFields is remarked out.
> In the following statement when I use any of the 3 cdoVariables or the > Property Tag [quoted text clipped - 25 lines] > > > Set objFolder = objSession.GetDefaultFolder(CdoDefaultFolderContacts) > > > Set objFolder = objSession.GetFolder("00000000515BA5871FC8D5119923000475762650C2960000")
> > > 'GetFolder("My Local E-Mail\Morang Cove Trading Company\MCTC Contacts") > > > ' Get the first message of the contacts folder [quoted text clipped - 38 lines] > > > ' For Example: > > > Value = objFields.Item("{0820060000000000C000000000000046}0x8535").Value
> > > ' If it is a Microsoft Outlook item with a custom field use the > following [quoted text clipped - 208 lines] > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > "John Galt" <jsys@yahoo.com> wrote in message news:VzCRb.10782$Bv6.3209406@news1.epix.net...
> > > > > > > > > > > > > > > > > I am looking for 3 specific columns that > don't [quoted text clipped - 30 lines] > > > > > > > > > > > the > > > > > > > > > > > > > > > > > Outlook.Application? John Galt - 29 Jan 2004 04:16 GMT Again, many of the cdoPR... variables do not work, nor do the other methods for viewing the values i.e. debug.print objFields.Item("{0006200800000000C000000000000046}0x802c") or debug.print objFields.Item(&H10900003)
Also the origianl Outlook object I used allowed me to get Categories. CDO does NOT.
Here is the working sub routine statements without any COMMENTED OUT. This works except for my statements above.
Private Sub cmdTEST_CLick() Dim objSession As MAPI.Session Dim objFolder As MAPI.Folder Dim objmessages As MAPI.Messages Dim objFields As MAPI.Fields Dim objmessage As MAPI.Message
Set objSession = CreateObject("MAPI.Session") If Not objSession Is Nothing Then strProfileName = "MS Exchange Settings" objSession.Logon strProfileName, , False End If
Set objFolder = objSession.GetDefaultFolder(CdoDefaultFolderContacts) Set objFolder = objSession.GetFolder("00000000515BA5871FC8D5119923000475762650C2960000") ' Get the first message of the contacts folder ' Note that it is still a message object ' So the class property will always return a value of CdoMsg Set objmessages = objFolder.Messages
Set objmessage = objmessages.GetFirst()
On Error Resume Next a = 2
For I = 2 To objmessages.Count Set objmessage = objmessages.GetNext() Set objFields = objmessage.Fields
If a = 1 Then 'InStr(objmessage.Field("Categories"), "Buyer") > 0 Then Debug.Print "*********** Record # " & I & " ***********" Debug.Print objFields(9) Debug.Print objFields(53) Debug.Print objFields(52) Debug.Print objFields(72) Debug.Print objFields(73) Debug.Print objFields(76) Debug.Print "***********************************" Else For x = 1 To 20000 If I = 29 Then Debug.Print "x = " & x & " " & objFields(x) End If Next x
End If Next I End Sub
> Does your code actually instantiate objFields? In the sample you posted, the > statement instantiating objFields is remarked out. [quoted text clipped - 206 lines] > > > > > > > > > > ' For Example: > > > > > > > > > > Value = objFields.Item("{0820060000000000C000000000000046}0x8535").Value
> > > > > > > > > > ' If it is a Microsoft Outlook item with a custom field > use > > > the > > > > > > > > following > > > > > > > > > > syntax: > > > > > > > > > > Set objField = objFields.Item("<NameOfUserdefinedField>")
> > > > > > > > > > ' For Example: > > > > > > > > > > Set objField = objFields.Item("PersonRole") [quoted text clipped - 48 lines] > > > > > > > > > > > > > > > > i.e. > > > > > > > > > > > > > > > > Set objFolder = objSession.GetDefaultFolder(CdoDefaultFolderContacts)
> > > > > > > > > > > > > > > > Please advise. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > "Sue Mosher [MVP]" <suemvp@outlookcode.com> > > wrote > > > in > > > > > > > message news:OM6fz7T5DHA.2404@TK2MSFTNGP11.phx.gbl...
> > > > > > > > > > > > > > > > > Contact flags are not exposed in the Outlook > > > > object [quoted text clipped - 53 lines] > > > > > > > > > > > > the > > > > > > > > > > > > > > > > > > Outlook.Application? Sue Mosher [MVP] - 29 Jan 2004 13:59 GMT As I said, when using CDO, you should not assume that a MAPI property is present on the item. If it does not contain data, it will not be present. One approach is to set an object variable to the field in question, test If Not objField Is Nothing and only then attempt to get the value of the field. The other way to deal with this is to access the value directly, but handle the error that results if the property is not present. The page at http://www.cdolive.com/cdo10.htm explains this. If you want to set the value, then you add the field, then set its value. Does that make sense? I know it's different from Outlook objects, but there is a certain logic to it. CDO *always* requires good error handling; the errors are expected and do not necessarily mean there's something wrong with your code.
So in your case, if you get an error when trying to get objFields.Item((&H10900003).Value, that just means there is no flag on the contact.
The CDO Message object directly supports a Categories field -- i.e. Message.Categories (check the object browser!) -- but it's a Variant Array, not a string.
Also note that you should *never* assume that an item in a contacts folder is a contact, because it could be a distribution list.
 Signature Sue Mosher, Outlook MVP Author of Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx
> Again, many of the cdoPR... variables do not work, nor do the other methods > for viewing the values i.e. [quoted text clipped - 333 lines] > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > "John Galt" <jsys@yahoo.com> wrote in message news:xHFRb.10793$Bv6.3211340@news1.epix.net...
> > > > > > > > > > > > > > > > > OK I Looked at the primer but I do not know > > how [quoted text clipped - 78 lines] > > > > > > > > > > > > > the > > > > > > > > > > > > > > > > > > > Outlook.Application? John Galt - 29 Jan 2004 15:39 GMT Hi Sue
OK. I understand that CDO does not create a an object that does not have a value. I am looking for values in fields that I know ABOSOLUTELY have a value. Fields that do not get handled by "On error resume next".
In this particular case I am using a contacts folder that is purely contacts. I created it and no records get in it that have not filled in the necessary fields.
The CDO Message object does "appear" to handle .categories. I used the object browser to find it. Every time I try to use it I get an error i.e. debug print objmessage.Categories RUN TIME ERROR 13 Type mismatch. How do I use the Variant array????
Are you getting tired of me yet?
> As I said, when using CDO, you should not assume that a MAPI property is > present on the item. If it does not contain data, it will not be present. [quoted text clipped - 126 lines] > > objSession.GetDefaultFolder(CdoDefaultFolderContacts) > > > > > > Set objFolder = objSession.GetFolder("00000000515BA5871FC8D5119923000475762650C2960000")
> > > > > > 'GetFolder("My Local E-Mail\Morang Cove Trading Company\MCTC > > > Contacts") [quoted text clipped - 222 lines] > > > in > > > > > > > message news:ukACZ1U5DHA.2404@TK2MSFTNGP11.phx.gbl...
> > > > > > > > > > > > > > > > > It's a CDO MAPI.Session object. Make sure > you [quoted text clipped - 101 lines] > > > > > > > > > > > > > > the > > > > > > > > > > > > > > > > > > > > Outlook.Application? John Galt - 29 Jan 2004 16:28 GMT Well I set a variable = to the object.message.categories and was able to manipulate the array. Thank you for all your help on this. It was a great exercise. I am now going to attempt to create a fax from the contacts with the correct category.
Should be fun!
> Hi Sue > [quoted text clipped - 79 lines] > > > Set objFolder = objSession.GetDefaultFolder(CdoDefaultFolderContacts) > > > Set objFolder = objSession.GetFolder("00000000515BA5871FC8D5119923000475762650C2960000")
> ' > > > Get the first message of the contacts folder [quoted text clipped - 296 lines] > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > "John Galt" <jsys@yahoo.com> wrote in message news:7WFRb.10794$Bv6.3211660@news1.epix.net...
> > > > > > > > > > > > > > > > > I Tried loading that dll and I get a message > > > that [quoted text clipped - 122 lines] > > > > > > > > > > > > > > > the > > > > > > > > > > > > > > > > > > > > > Outlook.Application?
|
|
|