![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
Dim WithEvents colCTSItems As Items
Private Sub Application_Startup() Dim NS As Outlook.NameSpace Set NS = Application.GetNamespace("MAPI") Set colCTSItems = NS.GetDefaultFolder(olFolderContacts).Items Hi, I need to specify a contacts folder other than that by default. I do not know how to make. thanks seb |
Ads |
#2
|
|||
|
|||
![]()
How you do that depends on the location of the folder you need. For a
subfolder of Contacts: Dim oContacts As Outlook.MAPIFolder Set oContacts = NS.GetDefaultFolder(olFolderContacts) Dim oSubfolder = oContacts.Folders("Name of folder") Set colCTSItems = oSubfolder.Items If the folder is at the top level equal in level to Contacts you'd use NameSpace.Folders("My folder name") Otherwise you'd have to iterate the NameSpace.Folders collection, perhaps recursively if the location could be anywhere until you find the folder with the name you're looking for. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007. Reminder Manager, Extended Reminders, Attachment Options. http://www.slovaktech.com/products.htm "news.free.fr" wrote in message ... Dim WithEvents colCTSItems As Items Private Sub Application_Startup() Dim NS As Outlook.NameSpace Set NS = Application.GetNamespace("MAPI") Set colCTSItems = NS.GetDefaultFolder(olFolderContacts).Items Hi, I need to specify a contacts folder other than that by default. I do not know how to make. thanks seb |
#4
|
|||
|
|||
![]()
Set colCTSItems = NS.folders ("NF_contacts"). Items
Should work if the folder is named "NF_contacts" and is located directly at the same level as the default Contacts folder. What error are you getting? You might help yourself by splitting that into 2 lines so you can see exactly where the error occurs: Dim oFolder As Outlook.MAPIFolder Set oFolder = NS.folders ("NF_contacts") Set colCTSItems = oFolder. Items -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007. Reminder Manager, Extended Reminders, Attachment Options. http://www.slovaktech.com/products.htm "seb...." wrote in message ... Thank you for your reply and sorry for my bad english. I need to adapt the code below to reach a record of contacts appointed NF_contacts. This folder is located directly under the root folder personnal folder. Code:
DimWithEvents colCTSItems As Items Private Sub Application_Startup () Dim NS As Outlook.NameSpace Set NS = Application.GetNamespace ( "MAPI") Set colCTSItems = NS.GetDefaultFolder (olFolderContacts). Items I tried: Code:
Set colCTSItems = NS.folders ("NF_contacts"). Items But that does not work, I get an error. |
#5
|
|||
|
|||
![]()
I have this error :
Operation cannot carry out. Am not possible carry one out to find an object. Error of execution '-2147221233 (8004010f) when i use : Dim oFolder As Outlook.MAPIFolder Set oFolder = NS.folders ("NF_contacts") Set colCTSItems = oFolder. Items I have error at line Set oFolder = NS.folders ("NF_contacts") I assume that it does not find the file while this one exists. "Ken Slovak - [MVP - Outlook]" a écrit dans le message de news: ... Set colCTSItems = NS.folders ("NF_contacts"). Items Should work if the folder is named "NF_contacts" and is located directly at the same level as the default Contacts folder. What error are you getting? You might help yourself by splitting that into 2 lines so you can see exactly where the error occurs: Dim oFolder As Outlook.MAPIFolder Set oFolder = NS.folders ("NF_contacts") Set colCTSItems = oFolder. Items -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007. Reminder Manager, Extended Reminders, Attachment Options. http://www.slovaktech.com/products.htm "seb...." wrote in message ... Thank you for your reply and sorry for my bad english. I need to adapt the code below to reach a record of contacts appointed NF_contacts. This folder is located directly under the root folder personnal folder. Code:
DimWithEvents colCTSItems As Items Private Sub Application_Startup () Dim NS As Outlook.NameSpace Set NS = Application.GetNamespace ( "MAPI") Set colCTSItems = NS.GetDefaultFolder (olFolderContacts). Items I tried: Code:
Set colCTSItems = NS.folders ("NF_contacts"). Items But that does not work, I get an error. |
#6
|
|||
|
|||
![]()
OK, that error is MAPI_E_NOT_FOUND.
So the question is if that folder is in your default PST file, and if you have more than one PST file open. Where is this code running, in Outlook VBA or somewhere else? Let's try a round-about method of trying to get at that folder. Assuming it's in the default PST, let's try getting a default folder then the parent of that default folder and then the target folder. So try this, assuming this is Outlook VBA code: Dim NS As Outlook.NameSpace Dim oInbox As Outlook.MAPIFolder Dim oFolder As Outlook.MAPIFolder Dim oParent As Outlook.MAPIFolder ' next line only works in Outlook VBA where Application is Outlook Set NS = Application.GetNameSpace("MAPI") Set oInbox = NS.GetDefaultFolder(olFolderInbox) Set oParent = oInbox.Parent Set oFolder = oParent.Folders ("NF_contacts") Set colCTSItems = oFolder. Items See if that works or where you get an error. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007. Reminder Manager, Extended Reminders, Attachment Options. http://www.slovaktech.com/products.htm "news.free.fr" wrote in message ... I have this error : Operation cannot carry out. Am not possible carry one out to find an object. Error of execution '-2147221233 (8004010f) when i use : Dim oFolder As Outlook.MAPIFolder Set oFolder = NS.folders ("NF_contacts") Set colCTSItems = oFolder. Items I have error at line Set oFolder = NS.folders ("NF_contacts") I assume that it does not find the file while this one exists. |
#7
|
|||
|
|||
![]()
Hi,
I found the solution Set NS = Application.GetNamespace("MAPI") Set oFolder = NS.Folders("LastName Firstname").Folders("NF_contacts") Set colCTSItems = oFolder.Items "news.free.fr" a écrit dans le message de news: ... I have this error : Operation cannot carry out. Am not possible carry one out to find an object. Error of execution '-2147221233 (8004010f) when i use : Dim oFolder As Outlook.MAPIFolder Set oFolder = NS.folders ("NF_contacts") Set colCTSItems = oFolder. Items I have error at line Set oFolder = NS.folders ("NF_contacts") I assume that it does not find the file while this one exists. "Ken Slovak - [MVP - Outlook]" a écrit dans le message de news: ... Set colCTSItems = NS.folders ("NF_contacts"). Items Should work if the folder is named "NF_contacts" and is located directly at the same level as the default Contacts folder. What error are you getting? You might help yourself by splitting that into 2 lines so you can see exactly where the error occurs: Dim oFolder As Outlook.MAPIFolder Set oFolder = NS.folders ("NF_contacts") Set colCTSItems = oFolder. Items -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007. Reminder Manager, Extended Reminders, Attachment Options. http://www.slovaktech.com/products.htm "seb...." wrote in message ... Thank you for your reply and sorry for my bad english. I need to adapt the code below to reach a record of contacts appointed NF_contacts. This folder is located directly under the root folder personnal folder. Code:
DimWithEvents colCTSItems As Items Private Sub Application_Startup () Dim NS As Outlook.NameSpace Set NS = Application.GetNamespace ( "MAPI") Set colCTSItems = NS.GetDefaultFolder (olFolderContacts). Items I tried: Code:
Set colCTSItems = NS.folders ("NF_contacts"). Items But that does not work, I get an error. |
#8
|
|||
|
|||
![]()
OK, so the folder wasn't actually at the same level as the default Contacts
folder, it's a subfolder of your "LastName Firstname" folder. That explains your problems. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007. Reminder Manager, Extended Reminders, Attachment Options. http://www.slovaktech.com/products.htm "news.free.fr" wrote in message ... Hi, I found the solution Set NS = Application.GetNamespace("MAPI") Set oFolder = NS.Folders("LastName Firstname").Folders("NF_contacts") Set colCTSItems = oFolder.Items |
#9
|
|||
|
|||
![]()
Yes, the case is not a subfolder of contact folder by default.
Now, I try to test if the file exists and create it if it does not exist. "Ken Slovak - [MVP - Outlook]" a écrit dans le message de groupe de discussion : ... OK, so the folder wasn't actually at the same level as the default Contacts folder, it's a subfolder of your "LastName Firstname" folder. That explains your problems. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007. Reminder Manager, Extended Reminders, Attachment Options. http://www.slovaktech.com/products.htm "news.free.fr" wrote in message ... Hi, I found the solution Set NS = Application.GetNamespace("MAPI") Set oFolder = NS.Folders("LastName Firstname").Folders("NF_contacts") Set colCTSItems = oFolder.Items |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Move email from specific folder (under the inbox) to a specific fo | Emil | Outlook and VBA | 3 | June 15th 08 07:23 PM |
Outlook2k3 not autosending or downloading | jmillerWV | Outlook - Installation | 1 | June 19th 07 03:23 PM |
How Can I change the Default Calendar in Outlook2k3? | Joecool | Outlook - Calandaring | 2 | July 21st 06 11:15 PM |
Please help me to add my contacts from emails to specific contact folder | [email protected] | Outlook - Using Contacts | 1 | June 28th 06 03:09 PM |
Please help me to add my contacts from emails to specific contact folder | [email protected] | Outlook - Using Contacts | 0 | June 28th 06 02:47 PM |