| | |
Outlook
Please support our C# advertiser: Intel Parallel Studio Home
Thread Solved |
Does any body know how to save your contacts in outlook to the harddrive. i no how to list them. but then i tried the save as methosd.
oContact.SaveAs("C:\contacts\" + list.selectedItem + ".vcf", null);
and that doesnt work. Any ideas?
my code...
EDIT:
here is the error
yea i have permisstion i am admin and all....it gives that eroor no matter where i write
oContact.SaveAs("C:\contacts\" + list.selectedItem + ".vcf", null);
and that doesnt work. Any ideas?
my code...
C# Syntax (Toggle Plain Text)
Outlook._Application olApp = new Outlook.ApplicationClass(); Outlook._NameSpace olNs = olApp.GetNamespace("MAPI"); Outlook.MAPIFolder oContacts = olNs.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts); Outlook.Items oItems = oContacts.Items; for (int i = 1; i <= oItems.Count; i++) { Outlook._ContactItem oContact = (Outlook._ContactItem)oItems.Item(i); list.Items.Add(oContact.FullName); oContact.SaveAs("C:\\apps\\" + list.SelectedItem,null);//error here oContact = null; }
EDIT:
here is the error
•
•
•
•
Can't write to file: C:\Apps\. Right-click the folder that contains the file you want to write to, and then click Properties on the shortcut menu to check your permissions for the folder.
Firefox
Ewido
Tune up windows
Get detailed system information
My Fixes
Member - Alliance of Security Analysis Professionals - Since 2006
Ewido
Tune up windows
Get detailed system information
My Fixes
Member - Alliance of Security Analysis Professionals - Since 2006
well if you havent figured it out yet its because you are trying to use a selection in list before a selection can even be made.
in order to use the selection you need to click on it.
i fixed your code to make iit work, which adds the contact to the listbox and saves it using the current contact name, which is what the code should have done.
although. if there was a selection in the list i think it would recreate the same file during each loop, which could be a nother cause for a error, because the selection wont change just because you are adding and item
oh one more thing, dont expect to learn how things work if you just copy and paste off websites, and modifying it slightly. i googled this and found it on m$'s site lol
in order to use the selection you need to click on it.
i fixed your code to make iit work, which adds the contact to the listbox and saves it using the current contact name, which is what the code should have done.
although. if there was a selection in the list i think it would recreate the same file during each loop, which could be a nother cause for a error, because the selection wont change just because you are adding and item
oh one more thing, dont expect to learn how things work if you just copy and paste off websites, and modifying it slightly. i googled this and found it on m$'s site lol
C# Syntax (Toggle Plain Text)
Outlook._Application olApp = new Outlook.ApplicationClass(); Outlook._NameSpace olNs = olApp.GetNamespace("MAPI"); Outlook.MAPIFolder oContacts = olNs.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts); Outlook.Items oItems = oContacts.Items; for (int i = 1; i <= oItems.Count; i++) { Outlook._ContactItem oContact = (Outlook._ContactItem)oItems.Item(i); list.Items.Add(oContact.FullName); oContact.SaveAs(@"C:\" + oContact.FullName, Type.Missing); oContact = null;
•
•
•
•
Originally Posted by plazmo
are you trying to create a file that outlook can read? or is this copying the contacts for a different use?
-T
Firefox
Ewido
Tune up windows
Get detailed system information
My Fixes
Member - Alliance of Security Analysis Professionals - Since 2006
Ewido
Tune up windows
Get detailed system information
My Fixes
Member - Alliance of Security Analysis Professionals - Since 2006
i dont know why i am giving you such simple code but here
it could also use foreach but i wasnt sure what type each item was(maybe string or item something)
"SaveThis" could be either a method to append a file or and object that stores the data to be saved
C# Syntax (Toggle Plain Text)
for(int i = 0; i <= listBox1.Items.Count -1; i++) { SaveThis = listBox1.Items[i]; }
it could also use foreach but i wasnt sure what type each item was(maybe string or item something)
"SaveThis" could be either a method to append a file or and object that stores the data to be saved
•
•
•
•
Originally Posted by plazmo
well if you havent figured it out yet its because you are trying to use a selection in list before a selection can even be made.
in order to use the selection you need to click on it.
i fixed your code to make iit work, which adds the contact to the listbox and saves it using the current contact name, which is what the code should have done.
although. if there was a selection in the list i think it would recreate the same file during each loop, which could be a nother cause for a error, because the selection wont change just because you are adding and item
oh one more thing, dont expect to learn how things work if you just copy and paste off websites, and modifying it slightly. i googled this and found it on m$'s site lol
C# Syntax (Toggle Plain Text)
Outlook._Application olApp = new Outlook.ApplicationClass(); Outlook._NameSpace olNs = olApp.GetNamespace("MAPI"); Outlook.MAPIFolder oContacts = olNs.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts); Outlook.Items oItems = oContacts.Items; for (int i = 1; i <= oItems.Count; i++) { Outlook._ContactItem oContact = (Outlook._ContactItem)oItems.Item(i); list.Items.Add(oContact.FullName); oContact.SaveAs(@"C:\" + oContact.FullName, Type.Missing); oContact = null;
Thanks.
-T
Firefox
Ewido
Tune up windows
Get detailed system information
My Fixes
Member - Alliance of Security Analysis Professionals - Since 2006
Ewido
Tune up windows
Get detailed system information
My Fixes
Member - Alliance of Security Analysis Professionals - Since 2006
•
•
•
•
Originally Posted by tayspen
yea, but i didnt get if from MS. i got a a little help and modified it greatly ( i didnt post ALL of it thats just the listing part...). I had aleady tried somthing silmiliar to you SaveAs Method And it didnt work. And that didnt work either. And i do learn from it. I guess we all learn differently.![]()
Thanks.
-T
I just directly used your code
C# Syntax (Toggle Plain Text)
Outlook._Application olApp = new Outlook.ApplicationClass(); Outlook._NameSpace olNs = olApp.GetNamespace("MAPI"); Outlook.MAPIFolder oContacts = olNs.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts); Outlook.Items oItems = oContacts.Items; for (int i = 1; i <= oItems.Count; i++) { Outlook._ContactItem oContact = (Outlook._ContactItem)oItems.Item(i); list.Items.Add(oContact.FullName); oContact.SaveAs(@"C:\" + oContact.FullName, Type.Missing); oContact = null;
it it says operation failed. I use this code on load method. I wasnt aware that you could specifya format. i must have overlooked that :rolleyes:
Thanks.
T
Firefox
Ewido
Tune up windows
Get detailed system information
My Fixes
Member - Alliance of Security Analysis Professionals - Since 2006
Ewido
Tune up windows
Get detailed system information
My Fixes
Member - Alliance of Security Analysis Professionals - Since 2006
Ok, so i figured this out quite a while ago....But forgot to post solution. Well here it is.
Thats lists all of out look contacts in a listview. Then it copies them to the C Drive. Note if you dont want it to save them leave out this
Well there it is
-T
C# Syntax (Toggle Plain Text)
contactlist.Columns.Add("Name", 100, HorizontalAlignment.Left); contactlist.Columns.Add("Job Title", 100, HorizontalAlignment.Left); contactlist.Columns.Add("Company", 100, HorizontalAlignment.Left); contactlist.Columns.Add("Email", 100, HorizontalAlignment.Left); Outlook._Application olApp = new Outlook.ApplicationClass(); Outlook._NameSpace olNs = olApp.GetNamespace("MAPI"); Outlook.MAPIFolder oContacts = olNs.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts); Outlook.Items oItems = oContacts.Items; for (int i = 1; i <= oItems.Count; i++) { Outlook._ContactItem oContact = (Outlook._ContactItem)oItems.Item(i); ListViewItem itm = new ListViewItem(); itm.Text = oContact.FullName; itm.SubItems.Add(oContact.JobTitle); itm.SubItems.Add(oContact.CompanyName); itm.SubItems.Add(oContact.Email1Address); contactlist.Items.Add(itm); oContact.SaveAs("C:\\Contacts\\" + oContact.FullName + ".vcf", Outlook.OlSaveAsType.olVCard); oContact = null; } }
Thats lists all of out look contacts in a listview. Then it copies them to the C Drive. Note if you dont want it to save them leave out this
C# Syntax (Toggle Plain Text)
oContact.SaveAs("C:\\Contacts\\" + oContact.FullName + ".vcf", Outlook.OlSaveAsType.olVCard);
Well there it is

-T
Firefox
Ewido
Tune up windows
Get detailed system information
My Fixes
Member - Alliance of Security Analysis Professionals - Since 2006
Ewido
Tune up windows
Get detailed system information
My Fixes
Member - Alliance of Security Analysis Professionals - Since 2006
![]() |
Similar Threads
- Synchronize Outlook with Entourage (Mac Software)
- Minimizing Outlook 2000 to the systray in Windows 2000 Pro (Windows Software)
- Outlook Takes A Few Minutes To Open (Windows NT / 2000 / XP)
Other Threads in the C# Forum
- Previous Thread: Where is System.Text.Encoding.EBCDIC?
- Next Thread: Basic Question
| Thread Tools | Search this Thread |
.net access algorithm api array asp.net barchart bitmap box broadcast c# check checkbox client combobox control conversion csharp custom database databaseconnection datagrid datagridview dataset datetime dbconnection degrees design development draganddrop drawing encryption enum event eventhandlers excel file firefox form format forms function gdi+ httpwebrequest image index input install java label libraries list listbox loop mandelbrot math mouseclick movingimage mysql mysql.data.client operator path photoshop php picturebox pixelinversion platform post programming radians regex remote remoting resourcefile richtextbox server sleep socket sql statistics stream string study system.servicemodel table tcpclientchannel text textbox thread time timer update usercontrol validation visualstudio webbrowser windows winforms wpf xml






), and see what it contains (i think i already told you that way to proceed in another thread 