A Microsoft Outlook email forum. Outlook Banter

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.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook - Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Importing Contatct



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old August 2nd 07, 10:12 AM posted to microsoft.public.outlook.program_forms
alici0
external usenet poster
 
Posts: 1
Default Importing Contatct

hi all,
how can I modify my vba script to import contacts not in the default one
folder but in a contact folder contained in "Public folders\All Public
Folders\One\Contatti" Folder?
thx.

this is my script for importing from a text file to excel and from excel to
outlook

'this import the txt file to excel
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True

objExcel.Workbooks.OpenText
"E:\dgs\MEF\scriptoli\contacts\Importacontatti\inp ut.txt"

'this import the excel in outook
Const olContactItem = 2

Set objOutlook = CreateObject("Outlook.Application")

Set objExcel = CreateObject("Excel.Application")

Set objWorkbook =
objExcel.Workbooks.Open("E:\dgs\MEF\scriptoli\cont acts\importacontatti\input.txt")

x = 1

Do Until objExcel.Cells(x,1).Value = ""

Set objContact = objOutlook.CreateItem(olContactItem)
objContact.FullName = objExcel.Cells(x,1).Value
objContact.Email1Address = objExcel.Cells(x,2).Value
objContact.Save

x = x + 1
Loop

objExcel.Quit

Thx
James.
  #2  
Old August 2nd 07, 01:15 PM posted to microsoft.public.outlook.program_forms
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Importing Contatct

To create a new item in a non-default folder programmatically, instead of CreateItem, you'd use the Add method on the target folder's Items collection:

Set newItem = targetFolder.Items.Add("IPM.Post.YourFormName")

The message class parameter is optional.

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.outlookcode.com/d/code/getfolder.htm and, especially for public folders, http://www.outlookcode.com/codedetail.aspx?id=1164



--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"alici0" wrote in message ...
hi all,
how can I modify my vba script to import contacts not in the default one
folder but in a contact folder contained in "Public folders\All Public
Folders\One\Contatti" Folder?
thx.

this is my script for importing from a text file to excel and from excel to
outlook

'this import the txt file to excel
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True

objExcel.Workbooks.OpenText
"E:\dgs\MEF\scriptoli\contacts\Importacontatti\inp ut.txt"

'this import the excel in outook
Const olContactItem = 2

Set objOutlook = CreateObject("Outlook.Application")

Set objExcel = CreateObject("Excel.Application")

Set objWorkbook =
objExcel.Workbooks.Open("E:\dgs\MEF\scriptoli\cont acts\importacontatti\input.txt")

x = 1

Do Until objExcel.Cells(x,1).Value = ""

Set objContact = objOutlook.CreateItem(olContactItem)
objContact.FullName = objExcel.Cells(x,1).Value
objContact.Email1Address = objExcel.Cells(x,2).Value
objContact.Save

x = x + 1
Loop

objExcel.Quit

Thx
James.

 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Importing forceten32 Outlook Express 2 February 5th 07 03:44 PM
Importing Brian O'Rourke Outlook Express 5 January 24th 07 06:10 PM
Importing attachments when importing messages from Express to Outl kmham Outlook - Installation 1 July 24th 06 11:37 PM
importing bobtracey Outlook Express 3 June 12th 06 11:16 PM
Importing Gibgo Outlook - Using Contacts 3 January 17th 06 03:05 PM


All times are GMT +1. The time now is 11:31 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.