Display Records Like Address Cards In Contacts In MS Outlook
I would like to display my data like MS Outlook Contacts the "Address Cards". I am very new at VB and can not figure out where to start. Can some tell me which controls would be best to try. i want to display records in a vertical column format top to bottom with the next column starting at the top again. Thanks in advance.
Dan Badgley
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Adding Contacts From Outlook Address Book To List
I have a list on my form. How do I add contacts from a outlook address book to that list? I have searched high-and-low on this forum and a other websites and have not really found anything. I did find this however here on VBCity:
Code:
Dim myOlApp As New Outlook.Application
Dim myNameSpace As Outlook.NameSpace
Dim myFolder As Outlook.MAPIFolder
Set myNameSpace = myOlApp.GetNamespace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(olFolderContacts)
For x = 1 To myFolder.Items.Count
Debug.Print myFolder.Items(x).FirstName
Debug.Print myFolder.Items(x).LastName
Debug.Print myFolder.Items(x).HomeTelephoneNumber
Next x
I tried modifying the code by putting "Debug.Print myFolder.Items(x).Address", but this did not work. Nor did many other possible variations for "email address". O, and of course I added the reference to Microsoft Outlook. Any help????
Populate A List Box With Display Names From Outlook Address Book
I am relatively new at VB programming and self-taught. There is no-one else at my company who is proficient at VB programming, so I am looking for some assistance.
I would like to use a listbox to allow a user to select an employee name, and I think that populating the list box with the display names from our outlook address book would be the best method to use to keep the list current. This is a small company so there are probably less then 100 addresses to contend with.
I know how to use active messaging to open an outlook session, and I have used the Session_AddressBook() method to select recipients for other e-mails. But I think that using the Session_AddressBook method will be confusing for some of our users, and a drop-down list would be easier.
Is it possible to do this?
Edited by - Tenslvr3 on 3/11/2002 2:17:33 PM
Adding Contacts In Outlook Express And Outlook 97
I am trying to write a program in VB6.0 to retrieve all the contacts from address book added on the mail server and add them into the local system Outlook Address Book. I was able to do it on Outlook 2002 using Outlook.Application MAPI object. But I am not able to do that on Outlook Express and Outlook 97, Can someone help me, also if someone has any sample code, please help me sending it to me.
Thanks in advance
Inserting An Address Into Word From Public Contacts
In MS Word, there is a simple function you can use to insert an address from your default address book (Application.GetAddress), but I cannot figure out how to use this function (or any other built-in ones) to allow you to search for and insert an address from a specific public contact list.
For example: Assume the Exhange server has a Public Folder which contains a public contact list of "Sales Clients"
If a user in our company needs to type a formal letter to a client (inserting the address at the top of the page), they would like to be able to insert the address from this centrally maintained contact list using just keystrokes or with VERY few clicks of the mouse. If you use the function mentioned above, there is a very simple interface that you can use to search the current contact list, but no option to force the function to refer to a different contact list (yes, you can change which contact list they reference with a drop-down list in the top right corner once the InsertAddress function is running). Our users just will NOT like having to go thorugh all these steps to reselect the correct contact list each time. (our users type letter to clients MANY times a day) These few additional steps may seem paltry, but to users typing dictation speed and ease of use is everything! (They do EVERYTHING possible with keystrokes and try not to use the mouse unless they HAVE to)
Simply put, is there a function I can use or create to prompt the user to search for a specific client in this pubilc contacts list without having to change their default mail profile? (if that was changed, they would have the same troubles with having to change contact lists when they wanted to send inter-office email)
Thanks for any advice you can give... I'm stumped
Exchange Contacts/Global Address List
Okay, found some information about this topic earlier on this forum. But i need al little bit more information or instructions. My goal is to write an app with which my collegue's can manage contacts, with automatic updates to the Exchange Contacts.
At this moment i have managed to extract the contacts from the Active Directory (and put them in to an offline database). But i'm getting stuck with the following three actions (and maybe more later :confused:
1. Modifying and updating Exchange contacts;
2. Adding new Exchange contacts;
3. Deleting contacts (safely);
Can one of you help me on this project?
BTW: I use Visual Basic 6.0 and the required CDO libraries
Display Messenger Contacts
Hi,
I have the Messenger API Type Library which allows me to access the MSN Messenger functions. However, I cannot find how to include the list of contacts you have in a label or similar. Please could someone help?
Outlook Contacts
Hello Everyone,
I have an Excel document with a Userform that has two ComboBoxes on it.
1) When I load the form I would like a list of the Company Names that are in my Outlook Contacts to be displayed in the first ComboBox (Unique names only, as some companies have more than one contact)
2) When I select a company in the first ComboBox, I would like the second ComboBox to display all the Contacts (Last Name, First Name).
Thanks in advance for any help.
Outlook Contacts
Hi,can some one show me an example of extracting the outlook contacts to a listbox?,would be good just with pure api so no dlls etc thanks
OutLook Contacts
Hi!
Need Access to OutlookContacts from VB?
In Public folders??
Any ideas?
How To Use Outlook Contacts?
I currently use an access database for a program to view contacts . How could I change this to read the information from Outlook 2000 contacts?
Here is some of the code I use now.
Code:
Option Explicit
Dim cnn As ADODB.Connection
Dim cnn1 As ADODB.Connection
Dim rs As ADODB.Recordset
Dim rs1 As ADODB.Recordset
Private Sub cmbCity_Change()
cmbCustomer.Clear
Set cnn1 = New ADODB.Connection
Set rs1 = New ADODB.Recordset
' Open the database connection and recordset
cnn1.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:Documents and SettingsPaulMy DocumentsCustomerdb.mdb;" & _
"Persist Security Info=False"
rs1.Open "Select Distinct Employer from Customerlist WHERE (State LIKE """ & cmbState & """AND City LIKE """ & cmbCity & """)", cnn1, adOpenDynamic
' Place values in the comboBox control
Do While rs1.EOF = False
cmbCustomer.AddItem rs1!Employer
rs1.MoveNext
Loop
End Sub
Outlook VBA To Get Contacts
Does anyone know how to get the contacts from an address book in Outlook using VBA, and in particular the groups.
I have seen lots of postings on how to create groups/contacts but none on reading them in.
Outlook Contacts
Hello,
I am looking for a way to automate the creation of a user defined field in the Outlook Contacts Folder. The problem is, I can't find any information on how this could work. I just need a routine which runs through all contacts, adds the field and puts a specific ID in it, which it gets from another programm. Does anybody have any idea, how this could be made possible?
Thx in advance.
Alex
VB And Outlook Contacts
I have a need to call Outlook 2000 from my VB 6 application to access contact information. Can someone help me understand how this can be accomplished or point me to a site that has this information. The examples I have located all discuss how to email through outlook.
Thanks
Rick
Outlook Contacts And SQL
Hi,
I will be needing to connect to the Contact Manager in Outlook and SQL 7 to
share data back and forth.
Could someone point me to some good reference sources or perhaps some
sample code?
Thanks!
Add Outlook Contacts Via VB6
Hey guys, i've gotta problem here and was wondering if theres any other VB Gurus here.
What I am trying to do is, have a VB app read contacts from a .csv file, and import them into Outlook 2000. I can get this to happen...but what i'm having trouble on is having them add to a specific contact folder (address list) in outlook. When the below code is executed, it simply adds it to the root 'Contact' folder....Below is the code I have so far:
Dim ol As Outlook.Application
Dim ns As Outlook.NameSpace
Dim fl As Outlook.Folders
Dim itmContact As Outlook.ContactItem
' grab Outlook
Set ol = New Outlook.Application
' get MAPI reference
Set ns = ol.GetNamespace("MAPI")
' Create new Contact item
Set itmContact = ol.CreateItem(olContactItem)
' Setup Contact information...
With itmContact
.FullName = "James Smith"
.Anniversary = "09/15/1997"
' saving b-day info creates info in the calendar
.Birthday = "9/15/1975"
.CompanyName = "Microsoft"
.HomeTelephoneNumber = "704-555-8888"
.Email1Address = "someone@microsoft.com"
.JobTitle = "Developer"
.HomeAddress = "111 Main St." & vbCr & "Charlotte, NC 28226"
End With
' Save Contact...
itmContact.Save
Set ol = Nothing
Set ns = Nothing
Set itmContact = Nothing
MsgBox "Done."
Outlook Contacts Help
OK, I have the following code that reads through all of the contacts in my "Personal" folder, and then makes a distribution list for all of the entries it finds. Got this with no problem. The problem is that when I create a new distribution list, it always goes into the default contacts folder and I can't figure out how to get it into a contacts subfolder. Any ideas? I'm using Outlook 2000.
Code:
Private Sub CreateDistList()
Dim oAddList As AddressList, oEntries As AddressEntries, oContact As AddressEntry, oDist As DistListItem
Dim oRecips As Recipients, oEmailAddr As Recipient, oTemp As MailItem
Set oAddList = Application.Session.AddressLists("Personal") 'Get the personal addresslist.
Set oEntries = oAddList.AddressEntries 'Dump it's entries collections.
Set oTemp = Application.CreateItem(olMailItem) 'Create a temporary email to add recipients to.
For Each oContact In oEntries 'Loop through all the contacts in the list.
If oContact.DisplayType <> olDistList Then 'Exclude other distribution lists.
Set oEmailAddr = oTemp.Recipients.Add(oContact.Address) 'Add the contact to the email.
oEmailAddr.Resolve 'Resolve the address.
End If
Next oContact
Set oRecips = oTemp.Recipients 'Grab the recipient list from the email.
'PROBLEM HERE: I need to create this in a subfolder, not in
'the default Contacts root folder.
Set oDist = Application.CreateItem(olDistributionListItem) 'Create a new distribution list.
Call oDist.AddMembers(oRecips) 'Pass it all of the accumulated contacts.
oDist.DLName = "All Personal" 'Name it.
oDist.Save 'Save it.
Call oTemp.Close(olDiscard) 'Done with the email, discard it.
Set oRecips = Nothing 'Release all the objects
Set oTemp = Nothing
Set oDist = Nothing
Set oEntries = Nothing
Set oAddList = Nothing
End Sub
Search Through Contacts Gets Error After 75 Records (all The Time)
I am searching through an Outlook Contacts folder and it gets a type mismatch after 75 record out of 110. I can not tell which record it is on for the search does not seem to be in any order that i know of but it is the same each time I run it. The code is correct so how can you get a type mismatch after reading 75 records???? The code is as follows: What can be the problem
The error is generated on the following line:
If olContact.Categories <> "" Then
at this point olContacts turns to equal Nothing
What happened???????
How do I correct it?
Dim i As Long
Dim j As Long
Dim olApp As Outlook.Application
Dim olNS As Outlook.NameSpace
Dim olFolder As MAPIFolder
Dim olContact As ContactItem
Dim Cat() As String
Dim Addit As Boolean
Dim Name As String
Combo2.Clear
Set olApp = New Outlook.Application
Set olNS = olApp.GetNamespace("MAPI")
Set olFolder = olNS.GetDefaultFolder(olFolderContacts) 'The Contacts Folder
For Each olContact In olFolder.Items
If olContact.Categories <> "" Then
Addit = True
Cat = Split(olContact.Categories, ",")
For i = 0 To UBound(Cat)
For j = 0 To Combo2.ListCount - 1
If Cat(i) = Combo2.List(j) Then
Addit = False
Exit For
End If
Next j
If Addit Then Combo2.AddItem Cat(i)
Addit = True
Next i
End If
Next
Deleting Contacts In Outlook
How can I delete a contact in Outlook? For example, I would like to delete a contact from my contacts folder if it contains the email address blah@blah.com. Thanks in advance.
Outlook Contacts Search
First, the problem:
I'm building a web application (intranet) and in one small part of it, users can create a meeting and choose the invitees for the meeting. The invitees will be a list of people in their directory server. The problem is, it's a pain to make users type a name, click search, hit the server for the search, and then come back with results just to allow them to pick ONE name. Then they have to do it all over again for the next name.
What they'd like to see is something similar to the way Outlook does it. You simply start typing someone's name and then a type-ahead guesses who you are talking about.
My idea:
I'd like to just build an ActiveX control that sits on the web page. It would connect to Outlook for the directory information and provide the type-ahead functionality for them. Once they are done choosing people, the ActiveX control would populate a hidden field on the HTML page and post the page to the web server.
What's wrong?
I don't exactly know how to do that. I'm a bit of a newbie to ActiveX. How do I populate a hidden field on the webpage that the ActiveX control is on? Also, I'm not sure if there is an easy way to provide the type-ahead. From what I've seen in the Outlook API, there is a way to get a handle on your contacts list, but then you simply have to spin thru all of them to find a name using some kinda of string comparison. Isn't there a way to just search the contacts list using some Outlook search function?
Help please! Thanks for your time,
Joe Warmelink
p.s. I am also very willing to hear other solutions to the problem!
Update Outlook Contacts
I am trying to export excel files into Microsoft Outlook. They are
spreadsheets with names, addresses etc that I want to put into contacts in outlook.
I have tried several times to import when I am in Outlook, but it
tells me I must go to excel and name a range. Then I have tried to copy the range to the clipboard, simply highlight it, and copy and paste, but no sucess.
Macro?
Your help would be
greatly appreciated....thanks
Outlook Contacts/Excel VBA
I have a code in Excel that adds contact information into Outlook. However, when I save the contact, and move on to the next, it does not "resolve" the email address. Therefor, when I try to add these contacts to a distribution list, they do not appear. Does anyone know of a way to force Outlook to "resolve" the email address before saving the contact?
Exporting Contacts From Outlook
I need assistance in exporting contacts from Outlook 2000 into Excel 2000 as Vbscript to automate the process to migrate the contacts list into Lotus Notes.
Or assistance on methods available for the Outlook Application and Excel Application Objects.
Connect To MS Outlook Contacts
Hello everyone,
I have been searching around on this site for some time now trying to find out if there were any posts on connecting to my contacts in MS Outlook 2000. Maybe there were some and I just overlooked them but I will post my question and hopefully you can help me out.
I would like to connect to my MS Outlook 2000 program and look up all the company names and display them into a combo box. Can anyone guide me as to what the connection code to Outlook 2000 would look like.
Thanks In Advance
Add Contacts To Folder In Outlook
Hi, I would like to add contacts to a specific folder in my contacts folder in outlook 2000 named "123". I have the following code that adds contacts, but it adds it directly to the root contact folder, not the Contact > 123 folder. How can I add it to the 123?
Code:
Dim ol As Outlook.Application
Dim ns As Outlook.NameSpace
Dim fl As Outlook.Folders
Dim itmContact As Outlook.ContactItem
' grab Outlook
Set ol = New Outlook.Application
' get MAPI reference
Set ns = ol.GetNamespace("MAPI")
' Create new Contact item
Set itmContact = ol.CreateItem(olContactItem)
' Setup Contact information...
With itmContact
.FullName = "James Smith"
.Anniversary = "09/15/1997"
' saving b-day info creates info in the calendar
.Birthday = "9/15/1975"
.CompanyName = "Microsoft"
.HomeTelephoneNumber = "704-555-8888"
.Email1Address = "someone@microsoft.com"
.JobTitle = "Developer"
.HomeAddress = "111 Main St." & vbCr & "Charlotte, NC 28226"
End With
' Save Contact...
itmContact.Save
Set ol = Nothing
Set ns = Nothing
Set itmContact = Nothing
MsgBox "Done."
Another VB > Outlook Contacts Question...sorry
This is probably directed at RobDog888 but anyone feel free to jump it.
I know how to connect to Outlook via MAPI and search for items in the mailbox. Is there a way (with the appropriate administrative permissions) to poll all of the mailboxes on the exchange server to update contacts? Is it possible through the Outlook object. I looked into directly modifying the database (priv1.edb) on the server but I didn't get very far. Anyone have any ideas and/or code samples?
Thanks a lot for any help you can give.
Scripting With Outlook Contacts
Hi.
I'm working on a script that will recursively go through some public contact folders in outlook, and copy the contacts to one central folder. Fetching the contacts is fine, but I'm having trouble saving them to the folder I need to.
For Each contact In folder.Items
Set new_contact = contact.Copy
new_contact.OfficeLocation = folder.Name
new_contact.SaveAs ??????????????
Next
The saveas method calls for a path of a folder, but I'm not sure what format that needs to be in.
Thanks for the help!
Max Number Of Outlook Contacts
I am working on interfacing my Access 2000 contact database to Outlook's Contacts using VB6 and I have several questions.
1) Is there a practical limit to the number of contacts allowed in Outlook?
2) How can I create a subfolder from VB6 in the Outlook Contacts that can hold the contacts brought in from Access so as not to over right or otherwise mess with the main Contacts folder in Outlook?
3) How can I copy the contacts from Access to Outlook and have the contact overwritten (If that is the option I have selected) if it already exists. (I have been able to write a record to Outlook's contacts but if I try to write the same record three times I end up with three records in Outlook that are identicle.) How can I have it prompt me if the record exists (Only if selected as an option) to see if I want to overwrite it or not?
Any help here would be most appreciated.
Rev. Michael L. Burns
Import Outlook's Contacts!
Hi,
I am looking for a way to be able to IMPORT outlook's address book contacts to the Email Client that I am creating. I don't want to include dll's and such, is there a way to be able to go through the contact list of outlook and/or other Email client's like Eudora so the program adds them automatically instead of having the use manually enter them in the new email client.
This is sort of how the new ICQ does. It goes through outlook's contact list and so on to add people that it finds.
please let me know if you have any solution to this.
Outlook Express Contacts
Hello all,
I know this question is probably often asked but I need to get all of the names and phone/mobile numbers of the contacts from all versions of Outlook Express. I can do this in Outlook but not Express. I need this for an SMS messaging project.
Does anyone know if this can be done? And can it be done without using the latest Object libraries CDO 1.21 which I don't have, or is there another way?
Thanks,
Dave.
Creating Outlook Contacts
I have a project which requires creating and possibly modifying a large number of contacts. I'm planning on taking the name and e-mail address for each contact from a text file. Does anyone know how to use either VB or VBscript to create a contact? How about modifying a contact?
Thanks
Retrieve Outlook Contacts...
I was wondering if there is a way you can retrieve all the contactinformation from Outlook or Outlook Express though VB.
Any suggestions would be greatly appreciated.
Thanks,
Tom
Import Contacts From Outlook
Hello,
can somebody tell me how can i import contacts from outlook express
to an external file format or database? txt, mdb... and is very important
to use that on various version of outlook express. Is that possible?
Thank you in advance
Alex
Outlook Contacts Part II
Outlook contacts have like millions of diffrent kinds of telephonenumber types, Home phonenumber, businesstelephone number, etc,etc. If one of these numbers are filled in i want the contact to show.
I havent been able to make a structured and nice code for this, as it is now, i have a very ugly IF code todo this... Check out the "mnuContacts_Click" sub for the code i use today..
Code:
Private Function LoadOutLookContacts()
On Error GoTo ErrHandler
Dim myOlApp As New Outlook.Application
Dim myNameSpace As Outlook.NameSpace
Dim myFolder As Outlook.MAPIFolder
Set myNameSpace = myOlApp.GetNamespace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(olFolderContacts)
'show the contacts menu item in the menu if Ooutlook is installed
If myFolder.Items.Count > 0 Then ListMeny(4).Visible = True
For i = 1 To myFolder.Items.Count
If i > 1 Then Load mnuContacts(i)
mnuContacts(i).Enabled = True
mnuContacts(i).Caption = myFolder.Items(i).FullName
Next i
ErrHandler:
'outlook not present on system
End Function
Private Sub mnuContacts_Click(Index As Integer)
Dim myOlApp As New Outlook.Application
Dim myNameSpace As Outlook.NameSpace
Dim myFolder As Outlook.MAPIFolder
Dim FoundNumbers As Boolean
Set myNameSpace = myOlApp.GetNamespace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(olFolderContacts)
NameList.Clear
NumberList.Clear
FoundNumbers = False
Me.Caption = "MS Outlook Kontakter - " & myFolder.Items(Index).FullName
If Len(myFolder.Items(Index).HomeTelephoneNumber) >= 6 Then
NameList.AddItem "Hem"
NumberList.AddItem myFolder.Items(Index).HomeTelephoneNumber
FoundNumbers = True
End If
If Len(myFolder.Items(Index).Home2TelephoneNumber) >= 6 Then
NameList.AddItem "Hem 2"
NumberList.AddItem myFolder.Items(Index).Home2TelephoneNumber
FoundNumbers = True
End If
If Len(myFolder.Items(Index).BusinessTelephoneNumber) >= 6 Then
NameList.AddItem "Arbete"
NumberList.AddItem myFolder.Items(Index).BusinessTelephoneNumber
FoundNumbers = True
End If
If Len(myFolder.Items(Index).MobileTelephoneNumber) >= 6 Then
NameList.AddItem "Mobil"
NumberList.AddItem myFolder.Items(Index).MobileTelephoneNumber
FoundNumbers = True
End If
If Len(myFolder.Items(Index).BusinessFaxNumber) >= 6 Then
NameList.AddItem "Fax, Arbete"
NumberList.AddItem myFolder.Items(Index).BusinessFaxNumber
FoundNumbers = True
End If
If FoundNumbers = True Then
ListMeny(0).Enabled = False
ListMeny(1).Enabled = False
ListMeny(2).Enabled = True
ListMeny(3).Enabled = False
Else 'no numbers found in contact
MsgBox "Inga nummer sparade till denna kontakt", vbCritical
LoadNumbers
End If
End Sub
its really ugly, there must be a better way to test this..
Anyone?
/Anders
Adding Outlook Contacts Using ADO
Can someone please help me I am using the code posted on 7/11/2002 titled: Get Outlook contacts using ADO, which I modified and not am trying to add contacts to the list but when calling the .addNew function I get the error message ..."Run time error '-2147217911 (80040e09)' You do not have the necessary permissions to use the " object. Have your system administrator or the person who created this object establish the appropriate permissions for you."...
Please help.
Importing Into Contacts In Outlook
I used CreateTextFile to create a text file with a .txt extension.
Then I am using Writeline to write data to the file on record at a time.
I am trying to seperate fields with a tab character.
I am doing this by using Chr(9) and assigning it to a string variable.
When I try to import the records into my contacts in Outlook, it doesn't recognize the tabs. I choose "Tab seperated values (Windows)", but it appears that it is using the commas in the file, not the tabs, to seperated the fields.
Any ideas what is going on, or is there a better way to create a tab delimited text file?
thanks,
Ryan Uhl
Outlook Contacts In Combo Box
Hi
Ive looked around trying to find help on this. I want to put contact info in combo boxes for a program im writing. Here is the code I use to get the information from a access database I created by exporting the information. My main goal is that If I use the Outlook 2000 contacts the information will be up to date and I would only have to update Outlook. Any help would be appreciated.
Tutorials , sample code , sample projects any help is better than none.
Private Sub cmbCity_Click()
cmbCustomer.Clear
Set cnn1 = New ADODB.Connection
Set rs1 = New ADODB.Recordset
' Open the database connection and recordset
cnn1.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:Documents and SettingsPaulMy DocumentsCustomerdb.mdb;" & _
"Persist Security Info=False"
rs1.Open "Select Distinct Employer from Customerlist WHERE (State LIKE """ & cmbState & """AND City LIKE """ & cmbCity & """)", cnn1, adOpenDynamic
' Place values in the comboBox control
Do While rs1.EOF = False
cmbCustomer.AddItem rs1!Employer
rs1.MoveNext
Loop
End Sub
*Resolved* Use MAPI To Retrieve SMTP Address From Outlook Address Book
I want to load a user table with the names and e-mail addresses from our Outlook address book so that remote users who are not connected to our intranet can use the addresses.
I am using MAPI to retrieve information from the outlook address book using the MS Exchange settings. When I try to retrieve the objAddressEntry.Address, I do not get the SMTP address which is what I want to retrieve. The address that is retrieved using the objaddressentry looks like this "/o=value/ou=COMPANY/cn=Recipients/cn=entry name".
We exported the address book to a .csv file and imported it into excel. This spreadsheet had two columns of data related to the e-mail address... the first is named "E-mail Address"... the second is named "E-mail Addresses". The first column only contains information for entries that have addresses outside the company. these are the actual e-mail addresses that we want to load into our table and are equal to the value of the SMTP address in the second column
The second column consists of multiple e-mail addresses (SMTP,MS,X400, and CCMAIL):
example1 - entry with address inside company:
SMTP:MBaker@companyname.com%MSOMAIN/COMPANY/MBAKER%X400:c=US;a= ;p=DOMAIN;o=COMPANY;s=Baker;g=Marilyn;%CCMAIL:Baker, Marilyn at COMPANY
example2 - entry with address outside company:
SMTP:name@provider.com.br%X400:c=US;a= ;p=DOMAIN;o=COMPANY;s=Barbosa;g=Anderson;%CCMAIL:Barbosa, Anderson at COMPANY%MSOMAIN/COMPANY/ABARBOSA
What we need to store in our user table is the SMTP value in this second field... but that is not what is retrieved in the .address property of the addressentry object.
Is there a way to retrieve this info using VB?
Thanks
Edited by - Tenslvr3 on 7/28/2005 8:04:09 AM
Exporting Outlook Contacts To Excel
Hi
I need to export the contents of a multiline, wordwrapped textbox from Outlook to Excel.
The text is exporting using my current code however it exports as a single line of text in a single cell. The line feeds are displayed as non-recognisable characters, which I cannot auto replace in Excel.
I would like to export each line of the text box into separate cells in Excel.
Any ideas/help would be fantastic.
Thanks!
Exporting Outlook Contacts To Access
Currently, I have code which exports contacts as an XML file - but I'm wanting to spit Outlook's contacts into an Access database.
The code is at the end of this post.
I have looked around and downloaded from http://www.helenfeddema.com/CodeSamples.htm#Code16 as this holds the most promising answer.
But the only problem with Helen's VBA code is that it always exports the database to a set directory which you can't change otherwise it'll screw up.
I have posted the contacts as XML post below - I hope that someone can help me build a way of spitting all contacts into an access database.
Thanks.
Code:
' ------------------------
' EXPORTS CONTACTS AS XML
' ------------------------
Sub ContactsToXML()
Dim xmlHeader As String
Dim olApp As Outlook.Application
Dim objName As NameSpace
Dim Folder As MAPIFolder
Dim objContact As Variant
'Dim objContact As Outlook.ContactItem
Dim objMailItem As Outlook.MailItem
Dim objAppointment As Outlook.AppointmentItem
Dim i As Integer
Set olApp = Outlook.Application
Set objName = olApp.GetNamespace("MAPI")
Set Folder = objName.GetDefaultFolder(olFolderContacts)
'Set Folder = Folder.Folders.Item(2)
Open "c:outlookdatacontacts.xml" For Output As #1
Print #1, "<?xml version=""1.0""?>"
'Print #1, "<?xml-stylesheet type=""text/xsl"" href=""contacts.xsl""?>"
Print #1, "<dataroot xmlnsd=""urn:schemas-microsoft-comfficedata"">"
On Error Resume Next
For Each Item In Folder.Items
Set objAppointment = Item
Print #1, "<contacts>"
Call PrintXMLElement("FullName", Item.FullName)
Call PrintXMLElement("FirstName", Item.FirstName)
Call PrintXMLElement("LastName", Item.LastName)
Call PrintXMLElement("MiddleName", Item.MiddleName)
Call PrintXMLElement("Title", Item.Title)
Call PrintXMLElement("Suffix", Item.Suffix)
Call PrintXMLElement("NickName", Item.NickName)
Call PrintXMLElement("CompanyName", Item.CompanyName)
Call PrintXMLElement("Department", Item.Department)
Call PrintXMLElement("JobTitle", Item.JobTitle)
Call PrintXMLElement("BusinessAddress", Item.BusinessAddress)
Call PrintXMLElement("Categories", Item.Categories)
Call PrintXMLElement("EmailAddress", Item.Email1Address)
Call PrintXMLElement("BusinessAddressStreet", Item.BusinessAddressStreet)
Call PrintXMLElement("BusinessAddressPostOfficeBox", Item.BusinessAddressPostOfficeBox)
Call PrintXMLElement("BusinessAddressCity", Item.BusinessAddressCity)
Call PrintXMLElement("BusinessAddressState", Item.BusinessAddressState)
Call PrintXMLElement("BusinessAddressPostalCode", Item.BusinessAddressPostalCode)
Call PrintXMLElement("BusinessAddressCountry", Item.BusinessAddressCountry)
Call PrintXMLElement("BusinessHomePage", Item.BusinessHomePage)
Call PrintXMLElement("ComputerNetworkName", Item.ComputerNetworkName)
Call PrintXMLElement("FTPSite", Item.FTPSite)
Call PrintXMLElement("HomeAddress", Item.HomeAddress)
Call PrintXMLElement("HomeAddressStreet", Item.HomeAddressStreet)
Call PrintXMLElement("HomeAddressPostOfficeBox", Item.HomeAddressPostOfficeBox)
Call PrintXMLElement("HomeAddressCity", Item.HomeAddressCity)
Call PrintXMLElement("HomeAddressState", Item.HomeAddressState)
Call PrintXMLElement("HomeAddressPostalCode", Item.HomeAddressPostalCode)
Call PrintXMLElement("HomeAddressCountry", Item.HomeAddressCountry)
Call PrintXMLElement("OtherAddress", Item.OtherAddress)
Call PrintXMLElement("OtherAddressStreet", Item.OtherAddressStreet)
Call PrintXMLElement("OtherAddressPostOfficeBox", Item.OtherAddressPostOfficeBox)
Call PrintXMLElement("OtherAddressCity", Item.OtherAddressCity)
Call PrintXMLElement("OtherAddressState", Item.OtherAddressState)
Call PrintXMLElement("OtherAddressPostalCode", Item.OtherAddressPostalCode)
Call PrintXMLElement("OtherAddressCountry", Item.OtherAddressCountry)
Call PrintXMLElement("MailingAddress", Item.MailingAddress)
Call PrintXMLElement("AssistantTelephoneNumber", Item.AssistantTelephoneNumber)
Call PrintXMLElement("BusinessFaxNumber", Item.BusinessFaxNumber)
Call PrintXMLElement("BusinessTelephoneNumber", Item.BusinessTelephoneNumber)
Call PrintXMLElement("Business2TelephoneNumber", Item.Business2TelephoneNumber)
Call PrintXMLElement("CallbackTelephoneNumber", Item.CallbackTelephoneNumber)
Call PrintXMLElement("CarTelephoneNumber", Item.CarTelephoneNumber)
Call PrintXMLElement("CompanyMainTelephoneNumber", Item.CompanyMainTelephoneNumber)
Call PrintXMLElement("HomeFaxNumber", Item.HomeFaxNumber)
Call PrintXMLElement("HomeTelephoneNumber", Item.HomeTelephoneNumber)
Call PrintXMLElement("Home2TelephoneNumber", Item.Home2TelephoneNumber)
Call PrintXMLElement("ISDNNumber", Item.ISDNNumber)
Call PrintXMLElement("MobileTelephoneNumber", Item.MobileTelephoneNumber)
Call PrintXMLElement("OtherFaxNumber", Item.OtherFaxNumber)
Call PrintXMLElement("OtherTelephoneNumber", Item.OtherTelephoneNumber)
Call PrintXMLElement("PagerNumber", Item.PagerNumber)
Call PrintXMLElement("PrimaryTelephoneNumber", Item.PrimaryTelephoneNumber)
Call PrintXMLElement("RadioTelephoneNumber", Item.RadioTelephoneNumber)
Call PrintXMLElement("TTYTDDTelephoneNumber", Item.TTYTDDTelephoneNumber)
Call PrintXMLElement("TelexNumber", Item.TelexNumber)
Call PrintXMLElement("Account", Item.Account)
If Item.Anniversary <> "1/1/4501" Then Call PrintXMLElement("Anniversary", Item.Anniversary)
Call PrintXMLElement("AssistantName", Item.AssistantName)
Call PrintXMLElement("BillingInformation", Item.BillingInformation)
If Item.Birthday <> "1/1/4501" Then Call PrintXMLElement("Birthday", Item.Birthday)
Call PrintXMLElement("Categories", Item.Categories)
Call PrintXMLElement("Children", Item.Children)
Call PrintXMLElement("PersonalHomePage", Item.PersonalHomePage)
Call PrintXMLElement("Email1Address", Item.Email1Address)
Call PrintXMLElement("Email1DisplayName", Item.Email1DisplayName)
Call PrintXMLElement("Email2Address", Item.Email2Address)
Call PrintXMLElement("Email2DisplayName", Item.Email2DisplayName)
Call PrintXMLElement("Email3Address", Item.Email3Address)
Call PrintXMLElement("Email3DisplayName", Item.Email3DisplayName)
Item.Gender = Switch(Item.Gender = 1, "Female", _
Item.Gender = 2, "Male", Item.Gender = 0, "Unspecified")
Call PrintXMLElement("Gender", Gender)
Call PrintXMLElement("GovernmentIDNumber", Item.GovernmentIDNumber)
Call PrintXMLElement("Hobby", Item.Hobby)
Call PrintXMLElement("Initials", Item.Initials)
Call PrintXMLElement("Language", Item.Language)
Call PrintXMLElement("ManagerName", Item.ManagerName)
Call PrintXMLElement("Body", Item.Body)
Call PrintXMLElement("OfficeLocation", Item.OfficeLocation)
Call PrintXMLElement("OrganizationalIDNumber", Item.OrganizationalIDNumber)
Call PrintXMLElement("Profession", Item.Profession)
Call PrintXMLElement("ReferredBy", Item.ReferredBy)
Item.Sensitivity = Switch(Item.Sensitivity = 3, "Confidential", _
Item.Sensitivity = 0, "Normal", Item.Sensitivity = 1, _
"Personal", Item.Sensitivity = 2, "Private")
Call PrintXMLElement("Sensitivity", Item.Sensitivity)
Call PrintXMLElement("Spouse", Item.Spouse)
Call PrintXMLElement("User1", Item.User1)
Call PrintXMLElement("User2", Item.User2)
Call PrintXMLElement("User3", Item.User3)
Call PrintXMLElement("User4", Item.User4)
Call PrintXMLElement("WebPage", Item.WebPage)
If Len(Item.Body) > 0 Then
Print #1, " <Notes><![CDATA[" & Item.Body & "]]></Notes>"
End If
Print #1, "</contacts>"
Next Item
Print #1, "</dataroot>"
Close #1
End Sub
Sub PrintXMLElement(Name, Value)
If Len(Value) > 0 Then
Print #1, " <" & Name & ">" & Value & "</" & Name & ">"
End If
End Sub
|