Hi Guys,
I have following queries regarding Outlook 2007 contact management .I am trying to export excel format using the following code to outlook 2007,contacts list, but its not working ..can someone assist me in sorting this out ..i am attaching the format i need to export and here is the code i am using
Dim appOutlook As Outlook.Application
Dim objNameSpace As Outlook.Namespace
Dim objContactFolder As Outlook.MAPIFolder
Dim objContacts As Outlook.ContactItem
'Dim myDistList As Outlook.DistListItem
Sub ContList()
Set appOutlook = GetObject(, "Outlook.Application")
Set objNameSpace = appOutlook.GetNamespace("MAPI")
Set objContactFolder = objNameSpace.GetDefaultFolder(olFolderContacts)
Set myMailItem = appOutlook.CreateItem(olMailItem)
Set myRecipients = myMailItem.Recipients
'Set myDistList = appOutlook.CreateItem(olDistributionListItem)
For i = 3 To Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
Set objContacts = objContactFolder.Items.Add(olContactItem)
With objContacts
'.Secs = Range("B" & i).Value '.CompanyName = Range("B" & i).Value
.BusinessName = Range("C" & i).Value '.LastName = Range("C" & i).Value
.ContactName = Range("D" & i).Value '.FirstName = Range("D" & i).Value
.Custemail = Range("E" & i).Value '.BusinessAddress = Range("E" & i).Value
.Traderemail = Range("F" & i).Value '.BusinessAddressCity = Range("F" & i).Value
.salesemail = Range("G" & i).Value '.BusinessAddressState = Range("G" & i).Value
.BusinessAddressPostalCode = Range("H" & i).Value
.BusinessAddressCountry = Range("I" & i).Value
.JobTitle = Range("J" & i).Value
.BusinessTelephoneNumber = Range("K" & i).Value
.BusinessFaxNumber = Range("L" & i).Value
.Email1Address = Range("E:G" & i).Value '.Email1Address = Range("M" & i).Value
.Body = Range("N" & i).Value
.Save
End With
myRecipients.Add (Range("E" & i).Value)
Next
myRecipients.ResolveAll
myDistList.AddMembers myRecipients
myDistList.Display
End Sub
I have posted the same query on the following link as well: http://forums.techguy.org/business-a...ml#post7797407
Regards
Bookmarks