New contacts items added don't fully create email addresses

M

mike_setter

I have a problem with some code that exports from Access97 to Outlook
97 some contact details that are then placed in a Public folder. This
folder is intended to be used as a public available address book
through Exchange 5.5.

Whilst the code does export all the data we need and can be seen in the
public folder by everyone, the problem is that the email address in
Outlook is displayed without any underlining which I assume means it
has not been saved properly. What is more the folder is available as an
Address Book but no contacts are visible within it.

Curiously when I open the created records in my OL97 the only way to
get it to enter it correctly is by amending the email address slightly
and then pressing enter. It then displays with the underline and when I
Save & Close the form it *will* display in the Address Book as well.
When I open the record in OL2K it also does not display the underline
but upon closing the form (without making any changes) it will request
changes to be saved and will update the email address and make it
visible in the address book.

Ultimately I also want to delete the whole folder contents before each
time this procedure is run. I have yet to look at how to do this. Can
someone point me in the right direction.

Am I missing something in my code or is the Outlook code itself at
fault?

My code is displayed below :

Many thanks

Public Function ExportEmailAddresses()

Dim olFldrP As Outlook.MAPIFolder
Dim olFldr As Outlook.MAPIFolder
Dim olNms As Outlook.NameSpace
Dim olOutlookApp As Outlook.Application
Dim olItms As Outlook.Items 'folder items list
Dim olItm As Outlook.ContactItem 'folder item

Dim dbs As Database, rst As Recordset
Dim strTitle As String, strFirstName As String, strLastName As String,
strSuffix As String, strCompany As String
Dim strLastNameFirst As String, strEMailAddress As String, strNickName
As String
Dim lngResult As Long, lngcount As Long, lngPosition As Long


On Error Resume Next
Set olOutlookApp = GetObject(, "Outlook.Application")
If Err <> 0 Then
Set olOutlookApp = CreateObject("Outlook.Application")
End If

Set olNms = olOutlookApp.GetNamespace("MAPI")
Set olFldrP = olNms.Folders("Public Folders")
Set olFldrP = olFldrP.Folders("All Public Folders")
Set olFldr = olFldrP.Folders("Client Email Contacts")
Set olItms = olFldr.Items

Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("qryListEmailableClients", dbOpenSnapshot)
lngcount = rst.RecordCount

For lngPosition = 1 To lngcount
With rst
strTitle = Nz(![prefix])
strFirstName = Nz(![First Name])
strLastName = Nz(![Surname])
strSuffix = Nz(![suffix])
strCompany = Nz(![Company])
strLastNameFirst = Nz(![Surname]) & ", " & Nz(![First Name])
strEMailAddress = Nz(![Email Address])
strNickName = Nz(![dear])
End With

Set olItm = olItms.Add("IPM.Contact")

With olItm
.Title = strTitle
.FirstName = strFirstName
.LastName = strLastName
.CompanyName = strCompany
.suffix = strSuffix
.NickName = strNickName
.Email1Address = strEMailAddress
.Save
.Close (olSave)
End With
rst.MoveNext
Next lngPosition

End Function
 
G

Guest

If the e-mail address doesn't get underlined when you enter a choose an
address for a new e-mail message, it could be because you don't have
'Automatic name checking' turned on under Advanced E-mail Options.
Otherwise, the address is resolved when you send the message or choose "Check
Names" from the Tools menu.

If you want to delete all the items in a folder, do something like this:

Dim intX As Integer, objItem As Object

For intX = MAPIFolder.Items.Count To 1 Step -1
Set objItem = MAPIFolder.Items.Item(intX)
objItem.Delete
Next

--
Eric Legault - B.A, MCP, MCSD, Outlook MVP
--------------------------------------------------
{Private e-mails ignored}
Job: http://www.imaginets.com
Blog: http://blogs.officezealot.com/legault/

I have a problem with some code that exports from Access97 to Outlook
97 some contact details that are then placed in a Public folder. This
folder is intended to be used as a public available address book
through Exchange 5.5.

Whilst the code does export all the data we need and can be seen in the
public folder by everyone, the problem is that the email address in
Outlook is displayed without any underlining which I assume means it
has not been saved properly. What is more the folder is available as an
Address Book but no contacts are visible within it.

Curiously when I open the created records in my OL97 the only way to
get it to enter it correctly is by amending the email address slightly
and then pressing enter. It then displays with the underline and when I
Save & Close the form it *will* display in the Address Book as well.
When I open the record in OL2K it also does not display the underline
but upon closing the form (without making any changes) it will request
changes to be saved and will update the email address and make it
visible in the address book.

Ultimately I also want to delete the whole folder contents before each
time this procedure is run. I have yet to look at how to do this. Can
someone point me in the right direction.

Am I missing something in my code or is the Outlook code itself at
fault?

My code is displayed below :

Many thanks

Public Function ExportEmailAddresses()

Dim olFldrP As Outlook.MAPIFolder
Dim olFldr As Outlook.MAPIFolder
Dim olNms As Outlook.NameSpace
Dim olOutlookApp As Outlook.Application
Dim olItms As Outlook.Items 'folder items list
Dim olItm As Outlook.ContactItem 'folder item

Dim dbs As Database, rst As Recordset
Dim strTitle As String, strFirstName As String, strLastName As String,
strSuffix As String, strCompany As String
Dim strLastNameFirst As String, strEMailAddress As String, strNickName
As String
Dim lngResult As Long, lngcount As Long, lngPosition As Long


On Error Resume Next
Set olOutlookApp = GetObject(, "Outlook.Application")
If Err <> 0 Then
Set olOutlookApp = CreateObject("Outlook.Application")
End If

Set olNms = olOutlookApp.GetNamespace("MAPI")
Set olFldrP = olNms.Folders("Public Folders")
Set olFldrP = olFldrP.Folders("All Public Folders")
Set olFldr = olFldrP.Folders("Client Email Contacts")
Set olItms = olFldr.Items

Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("qryListEmailableClients", dbOpenSnapshot)
lngcount = rst.RecordCount

For lngPosition = 1 To lngcount
With rst
strTitle = Nz(![prefix])
strFirstName = Nz(![First Name])
strLastName = Nz(![Surname])
strSuffix = Nz(![suffix])
strCompany = Nz(![Company])
strLastNameFirst = Nz(![Surname]) & ", " & Nz(![First Name])
strEMailAddress = Nz(![Email Address])
strNickName = Nz(![dear])
End With

Set olItm = olItms.Add("IPM.Contact")

With olItm
.Title = strTitle
.FirstName = strFirstName
.LastName = strLastName
.CompanyName = strCompany
.suffix = strSuffix
.NickName = strNickName
.Email1Address = strEMailAddress
.Save
.Close (olSave)
End With
rst.MoveNext
Next lngPosition

End Function
 
M

Mike Setter

Thanks Eric
I already had the Automatic Name Checking enabled but it would not do it.
However it appears there is a problem with 97 and imported email addresses
not resolving so I have had to resort to getting the code to resolve each
one after it had created it. I have also now managed to get it to remove all
the existing entries in the folder.

Now all I have to do is automate it every night and all is well. Next up
will be allowing certain staff the ability to create their own lists of
email addresses from our contact database with which to merge with a
specific email.

I assume there is a way to select a particular email from someones Inbox or
Drafts folder a dialogue box?


Eric Legault said:
If the e-mail address doesn't get underlined when you enter a choose an
address for a new e-mail message, it could be because you don't have
'Automatic name checking' turned on under Advanced E-mail Options.
Otherwise, the address is resolved when you send the message or choose "Check
Names" from the Tools menu.

If you want to delete all the items in a folder, do something like this:

Dim intX As Integer, objItem As Object

For intX = MAPIFolder.Items.Count To 1 Step -1
Set objItem = MAPIFolder.Items.Item(intX)
objItem.Delete
Next

--
Eric Legault - B.A, MCP, MCSD, Outlook MVP
--------------------------------------------------
{Private e-mails ignored}
Job: http://www.imaginets.com
Blog: http://blogs.officezealot.com/legault/

I have a problem with some code that exports from Access97 to Outlook
97 some contact details that are then placed in a Public folder. This
folder is intended to be used as a public available address book
through Exchange 5.5.

Whilst the code does export all the data we need and can be seen in the
public folder by everyone, the problem is that the email address in
Outlook is displayed without any underlining which I assume means it
has not been saved properly. What is more the folder is available as an
Address Book but no contacts are visible within it.

Curiously when I open the created records in my OL97 the only way to
get it to enter it correctly is by amending the email address slightly
and then pressing enter. It then displays with the underline and when I
Save & Close the form it *will* display in the Address Book as well.
When I open the record in OL2K it also does not display the underline
but upon closing the form (without making any changes) it will request
changes to be saved and will update the email address and make it
visible in the address book.

Ultimately I also want to delete the whole folder contents before each
time this procedure is run. I have yet to look at how to do this. Can
someone point me in the right direction.

Am I missing something in my code or is the Outlook code itself at
fault?

My code is displayed below :

Many thanks

Public Function ExportEmailAddresses()

Dim olFldrP As Outlook.MAPIFolder
Dim olFldr As Outlook.MAPIFolder
Dim olNms As Outlook.NameSpace
Dim olOutlookApp As Outlook.Application
Dim olItms As Outlook.Items 'folder items list
Dim olItm As Outlook.ContactItem 'folder item

Dim dbs As Database, rst As Recordset
Dim strTitle As String, strFirstName As String, strLastName As String,
strSuffix As String, strCompany As String
Dim strLastNameFirst As String, strEMailAddress As String, strNickName
As String
Dim lngResult As Long, lngcount As Long, lngPosition As Long


On Error Resume Next
Set olOutlookApp = GetObject(, "Outlook.Application")
If Err <> 0 Then
Set olOutlookApp = CreateObject("Outlook.Application")
End If

Set olNms = olOutlookApp.GetNamespace("MAPI")
Set olFldrP = olNms.Folders("Public Folders")
Set olFldrP = olFldrP.Folders("All Public Folders")
Set olFldr = olFldrP.Folders("Client Email Contacts")
Set olItms = olFldr.Items

Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("qryListEmailableClients", dbOpenSnapshot)
lngcount = rst.RecordCount

For lngPosition = 1 To lngcount
With rst
strTitle = Nz(![prefix])
strFirstName = Nz(![First Name])
strLastName = Nz(![Surname])
strSuffix = Nz(![suffix])
strCompany = Nz(![Company])
strLastNameFirst = Nz(![Surname]) & ", " & Nz(![First Name])
strEMailAddress = Nz(![Email Address])
strNickName = Nz(![dear])
End With

Set olItm = olItms.Add("IPM.Contact")

With olItm
.Title = strTitle
.FirstName = strFirstName
.LastName = strLastName
.CompanyName = strCompany
.suffix = strSuffix
.NickName = strNickName
.Email1Address = strEMailAddress
.Save
.Close (olSave)
End With
rst.MoveNext
Next lngPosition

End Function
 
G

Guest

I'm missing something here - how are you resolving these e-mail addresses?
The only object in the Outlook Object Model that supports the Resolve method
is a Recipient, which is only available from the Recipients collection for
items that you send (MailItems, AppointmentItems, etc.) - not Contacts.

Contact items themselves do not support any kind of Resolve method for any
of the EmailXAddress properties. When you open a Contact and look at the
e-mail address, is it underlined? If it is not, is it in the valid
(e-mail address removed) form?

As for a dialog - no, there isn't one to choose an Item, but the
Namespace.PickFolder method provides a dialog to choose a folder. The best
method is to have the user select a message in the folder, and use the
Explorer.Selection object to return the chosen item(s).

--
Eric Legault - B.A, MCP, MCSD, Outlook MVP
--------------------------------------------------
{Private e-mails ignored}
Job: http://www.imaginets.com
Blog: http://blogs.officezealot.com/legault/

Mike Setter said:
Thanks Eric
I already had the Automatic Name Checking enabled but it would not do it.
However it appears there is a problem with 97 and imported email addresses
not resolving so I have had to resort to getting the code to resolve each
one after it had created it. I have also now managed to get it to remove all
the existing entries in the folder.

Now all I have to do is automate it every night and all is well. Next up
will be allowing certain staff the ability to create their own lists of
email addresses from our contact database with which to merge with a
specific email.

I assume there is a way to select a particular email from someones Inbox or
Drafts folder a dialogue box?


Eric Legault said:
If the e-mail address doesn't get underlined when you enter a choose an
address for a new e-mail message, it could be because you don't have
'Automatic name checking' turned on under Advanced E-mail Options.
Otherwise, the address is resolved when you send the message or choose "Check
Names" from the Tools menu.

If you want to delete all the items in a folder, do something like this:

Dim intX As Integer, objItem As Object

For intX = MAPIFolder.Items.Count To 1 Step -1
Set objItem = MAPIFolder.Items.Item(intX)
objItem.Delete
Next

--
Eric Legault - B.A, MCP, MCSD, Outlook MVP
--------------------------------------------------
{Private e-mails ignored}
Job: http://www.imaginets.com
Blog: http://blogs.officezealot.com/legault/

I have a problem with some code that exports from Access97 to Outlook
97 some contact details that are then placed in a Public folder. This
folder is intended to be used as a public available address book
through Exchange 5.5.

Whilst the code does export all the data we need and can be seen in the
public folder by everyone, the problem is that the email address in
Outlook is displayed without any underlining which I assume means it
has not been saved properly. What is more the folder is available as an
Address Book but no contacts are visible within it.

Curiously when I open the created records in my OL97 the only way to
get it to enter it correctly is by amending the email address slightly
and then pressing enter. It then displays with the underline and when I
Save & Close the form it *will* display in the Address Book as well.
When I open the record in OL2K it also does not display the underline
but upon closing the form (without making any changes) it will request
changes to be saved and will update the email address and make it
visible in the address book.

Ultimately I also want to delete the whole folder contents before each
time this procedure is run. I have yet to look at how to do this. Can
someone point me in the right direction.

Am I missing something in my code or is the Outlook code itself at
fault?

My code is displayed below :

Many thanks

Public Function ExportEmailAddresses()

Dim olFldrP As Outlook.MAPIFolder
Dim olFldr As Outlook.MAPIFolder
Dim olNms As Outlook.NameSpace
Dim olOutlookApp As Outlook.Application
Dim olItms As Outlook.Items 'folder items list
Dim olItm As Outlook.ContactItem 'folder item

Dim dbs As Database, rst As Recordset
Dim strTitle As String, strFirstName As String, strLastName As String,
strSuffix As String, strCompany As String
Dim strLastNameFirst As String, strEMailAddress As String, strNickName
As String
Dim lngResult As Long, lngcount As Long, lngPosition As Long


On Error Resume Next
Set olOutlookApp = GetObject(, "Outlook.Application")
If Err <> 0 Then
Set olOutlookApp = CreateObject("Outlook.Application")
End If

Set olNms = olOutlookApp.GetNamespace("MAPI")
Set olFldrP = olNms.Folders("Public Folders")
Set olFldrP = olFldrP.Folders("All Public Folders")
Set olFldr = olFldrP.Folders("Client Email Contacts")
Set olItms = olFldr.Items

Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("qryListEmailableClients", dbOpenSnapshot)
lngcount = rst.RecordCount

For lngPosition = 1 To lngcount
With rst
strTitle = Nz(![prefix])
strFirstName = Nz(![First Name])
strLastName = Nz(![Surname])
strSuffix = Nz(![suffix])
strCompany = Nz(![Company])
strLastNameFirst = Nz(![Surname]) & ", " & Nz(![First Name])
strEMailAddress = Nz(![Email Address])
strNickName = Nz(![dear])
End With

Set olItm = olItms.Add("IPM.Contact")

With olItm
.Title = strTitle
.FirstName = strFirstName
.LastName = strLastName
.CompanyName = strCompany
.suffix = strSuffix
.NickName = strNickName
.Email1Address = strEMailAddress
.Save
.Close (olSave)
End With
rst.MoveNext
Next lngPosition

End Function
 
M

Mike Setter

Eric, I was put on to http://www.slipstick.com/outlook/oltrble.htm#import
and thus have had to resort to displaying the item once created and then
calling the Tools menu's Check Names function as below before proceeding on
to create the next contact.

As for the pickfolder method, thanks but unfortunately that I think is only
available in OL2000 +, not in OL97 which currently is our prevalent version.
I will eventually be writing for OL2003 so will no doubt use it then.

Set olItm = olItms.Add("IPM.Contact")

'Write values from variables to fields in the new Contact item
With olItm
.Title = strTitle
.FirstName = strFirstName
.LastName = strLastName
.CompanyName = strCompany
.suffix = strSuffix
.NickName = strNickName
.Email1Address = strEMailAddress
.Display
End With

'Now resolve the email address as Outlook 97 does not do this properly
' Set the Tools menu on the item's menu bar
Set Menu = olOutlookApp.ActiveInspector.CommandBars("Tools")
' Sets the command on the menu
Set Command = Menu.Controls("Check Names")
' Actually executes the Check Names command
Command.Execute

With olItm
'Close and save new contact item
.Close (olSave)
End With

Eric Legault said:
I'm missing something here - how are you resolving these e-mail addresses?
The only object in the Outlook Object Model that supports the Resolve method
is a Recipient, which is only available from the Recipients collection for
items that you send (MailItems, AppointmentItems, etc.) - not Contacts.

Contact items themselves do not support any kind of Resolve method for any
of the EmailXAddress properties. When you open a Contact and look at the
e-mail address, is it underlined? If it is not, is it in the valid
(e-mail address removed) form?

As for a dialog - no, there isn't one to choose an Item, but the
Namespace.PickFolder method provides a dialog to choose a folder. The best
method is to have the user select a message in the folder, and use the
Explorer.Selection object to return the chosen item(s).

--
Eric Legault - B.A, MCP, MCSD, Outlook MVP
--------------------------------------------------
{Private e-mails ignored}
Job: http://www.imaginets.com
Blog: http://blogs.officezealot.com/legault/

Mike Setter said:
Thanks Eric
I already had the Automatic Name Checking enabled but it would not do it.
However it appears there is a problem with 97 and imported email addresses
not resolving so I have had to resort to getting the code to resolve each
one after it had created it. I have also now managed to get it to remove all
the existing entries in the folder.

Now all I have to do is automate it every night and all is well. Next up
will be allowing certain staff the ability to create their own lists of
email addresses from our contact database with which to merge with a
specific email.

I assume there is a way to select a particular email from someones Inbox or
Drafts folder a dialogue box?


Eric Legault said:
If the e-mail address doesn't get underlined when you enter a choose an
address for a new e-mail message, it could be because you don't have
'Automatic name checking' turned on under Advanced E-mail Options.
Otherwise, the address is resolved when you send the message or choose "Check
Names" from the Tools menu.

If you want to delete all the items in a folder, do something like this:

Dim intX As Integer, objItem As Object

For intX = MAPIFolder.Items.Count To 1 Step -1
Set objItem = MAPIFolder.Items.Item(intX)
objItem.Delete
Next

--
Eric Legault - B.A, MCP, MCSD, Outlook MVP
--------------------------------------------------
{Private e-mails ignored}
Job: http://www.imaginets.com
Blog: http://blogs.officezealot.com/legault/

:

I have a problem with some code that exports from Access97 to Outlook
97 some contact details that are then placed in a Public folder. This
folder is intended to be used as a public available address book
through Exchange 5.5.

Whilst the code does export all the data we need and can be seen in the
public folder by everyone, the problem is that the email address in
Outlook is displayed without any underlining which I assume means it
has not been saved properly. What is more the folder is available as an
Address Book but no contacts are visible within it.

Curiously when I open the created records in my OL97 the only way to
get it to enter it correctly is by amending the email address slightly
and then pressing enter. It then displays with the underline and when I
Save & Close the form it *will* display in the Address Book as well.
When I open the record in OL2K it also does not display the underline
but upon closing the form (without making any changes) it will request
changes to be saved and will update the email address and make it
visible in the address book.

Ultimately I also want to delete the whole folder contents before each
time this procedure is run. I have yet to look at how to do this. Can
someone point me in the right direction.

Am I missing something in my code or is the Outlook code itself at
fault?

My code is displayed below :

Many thanks

Public Function ExportEmailAddresses()

Dim olFldrP As Outlook.MAPIFolder
Dim olFldr As Outlook.MAPIFolder
Dim olNms As Outlook.NameSpace
Dim olOutlookApp As Outlook.Application
Dim olItms As Outlook.Items 'folder items list
Dim olItm As Outlook.ContactItem 'folder item

Dim dbs As Database, rst As Recordset
Dim strTitle As String, strFirstName As String, strLastName As String,
strSuffix As String, strCompany As String
Dim strLastNameFirst As String, strEMailAddress As String, strNickName
As String
Dim lngResult As Long, lngcount As Long, lngPosition As Long


On Error Resume Next
Set olOutlookApp = GetObject(, "Outlook.Application")
If Err <> 0 Then
Set olOutlookApp = CreateObject("Outlook.Application")
End If

Set olNms = olOutlookApp.GetNamespace("MAPI")
Set olFldrP = olNms.Folders("Public Folders")
Set olFldrP = olFldrP.Folders("All Public Folders")
Set olFldr = olFldrP.Folders("Client Email Contacts")
Set olItms = olFldr.Items

Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("qryListEmailableClients", dbOpenSnapshot)
lngcount = rst.RecordCount

For lngPosition = 1 To lngcount
With rst
strTitle = Nz(![prefix])
strFirstName = Nz(![First Name])
strLastName = Nz(![Surname])
strSuffix = Nz(![suffix])
strCompany = Nz(![Company])
strLastNameFirst = Nz(![Surname]) & ", " & Nz(![First Name])
strEMailAddress = Nz(![Email Address])
strNickName = Nz(![dear])
End With

Set olItm = olItms.Add("IPM.Contact")

With olItm
.Title = strTitle
.FirstName = strFirstName
.LastName = strLastName
.CompanyName = strCompany
.suffix = strSuffix
.NickName = strNickName
.Email1Address = strEMailAddress
.Save
.Close (olSave)
End With
rst.MoveNext
Next lngPosition

End Function
 
G

Guest

Whoops, I forgot about the Check Names option from the tools menu! The good
thing about Outlook is that if you can't do something with the object model,
you can usually fudge it by executing a commandbar button that does something
special that you can't do programmatically.

I also didn't realize you were using OL97. Yikes! My sympathies.

--
Eric Legault - B.A, MCP, MCSD, Outlook MVP
--------------------------------------------------
{Private e-mails ignored}
Job: http://www.imaginets.com
Blog: http://blogs.officezealot.com/legault/

Mike Setter said:
Eric, I was put on to http://www.slipstick.com/outlook/oltrble.htm#import
and thus have had to resort to displaying the item once created and then
calling the Tools menu's Check Names function as below before proceeding on
to create the next contact.

As for the pickfolder method, thanks but unfortunately that I think is only
available in OL2000 +, not in OL97 which currently is our prevalent version.
I will eventually be writing for OL2003 so will no doubt use it then.

Set olItm = olItms.Add("IPM.Contact")

'Write values from variables to fields in the new Contact item
With olItm
.Title = strTitle
.FirstName = strFirstName
.LastName = strLastName
.CompanyName = strCompany
.suffix = strSuffix
.NickName = strNickName
.Email1Address = strEMailAddress
.Display
End With

'Now resolve the email address as Outlook 97 does not do this properly
' Set the Tools menu on the item's menu bar
Set Menu = olOutlookApp.ActiveInspector.CommandBars("Tools")
' Sets the command on the menu
Set Command = Menu.Controls("Check Names")
' Actually executes the Check Names command
Command.Execute

With olItm
'Close and save new contact item
.Close (olSave)
End With

Eric Legault said:
I'm missing something here - how are you resolving these e-mail addresses?
The only object in the Outlook Object Model that supports the Resolve method
is a Recipient, which is only available from the Recipients collection for
items that you send (MailItems, AppointmentItems, etc.) - not Contacts.

Contact items themselves do not support any kind of Resolve method for any
of the EmailXAddress properties. When you open a Contact and look at the
e-mail address, is it underlined? If it is not, is it in the valid
(e-mail address removed) form?

As for a dialog - no, there isn't one to choose an Item, but the
Namespace.PickFolder method provides a dialog to choose a folder. The best
method is to have the user select a message in the folder, and use the
Explorer.Selection object to return the chosen item(s).

--
Eric Legault - B.A, MCP, MCSD, Outlook MVP
--------------------------------------------------
{Private e-mails ignored}
Job: http://www.imaginets.com
Blog: http://blogs.officezealot.com/legault/

Mike Setter said:
Thanks Eric
I already had the Automatic Name Checking enabled but it would not do it.
However it appears there is a problem with 97 and imported email addresses
not resolving so I have had to resort to getting the code to resolve each
one after it had created it. I have also now managed to get it to remove all
the existing entries in the folder.

Now all I have to do is automate it every night and all is well. Next up
will be allowing certain staff the ability to create their own lists of
email addresses from our contact database with which to merge with a
specific email.

I assume there is a way to select a particular email from someones Inbox or
Drafts folder a dialogue box?


message If the e-mail address doesn't get underlined when you enter a choose an
address for a new e-mail message, it could be because you don't have
'Automatic name checking' turned on under Advanced E-mail Options.
Otherwise, the address is resolved when you send the message or choose
"Check
Names" from the Tools menu.

If you want to delete all the items in a folder, do something like this:

Dim intX As Integer, objItem As Object

For intX = MAPIFolder.Items.Count To 1 Step -1
Set objItem = MAPIFolder.Items.Item(intX)
objItem.Delete
Next

--
Eric Legault - B.A, MCP, MCSD, Outlook MVP
--------------------------------------------------
{Private e-mails ignored}
Job: http://www.imaginets.com
Blog: http://blogs.officezealot.com/legault/

:

I have a problem with some code that exports from Access97 to Outlook
97 some contact details that are then placed in a Public folder. This
folder is intended to be used as a public available address book
through Exchange 5.5.

Whilst the code does export all the data we need and can be seen in the
public folder by everyone, the problem is that the email address in
Outlook is displayed without any underlining which I assume means it
has not been saved properly. What is more the folder is available as an
Address Book but no contacts are visible within it.

Curiously when I open the created records in my OL97 the only way to
get it to enter it correctly is by amending the email address slightly
and then pressing enter. It then displays with the underline and when I
Save & Close the form it *will* display in the Address Book as well.
When I open the record in OL2K it also does not display the underline
but upon closing the form (without making any changes) it will request
changes to be saved and will update the email address and make it
visible in the address book.

Ultimately I also want to delete the whole folder contents before each
time this procedure is run. I have yet to look at how to do this. Can
someone point me in the right direction.

Am I missing something in my code or is the Outlook code itself at
fault?

My code is displayed below :

Many thanks

Public Function ExportEmailAddresses()

Dim olFldrP As Outlook.MAPIFolder
Dim olFldr As Outlook.MAPIFolder
Dim olNms As Outlook.NameSpace
Dim olOutlookApp As Outlook.Application
Dim olItms As Outlook.Items 'folder items list
Dim olItm As Outlook.ContactItem 'folder item

Dim dbs As Database, rst As Recordset
Dim strTitle As String, strFirstName As String, strLastName As String,
strSuffix As String, strCompany As String
Dim strLastNameFirst As String, strEMailAddress As String, strNickName
As String
Dim lngResult As Long, lngcount As Long, lngPosition As Long


On Error Resume Next
Set olOutlookApp = GetObject(, "Outlook.Application")
If Err <> 0 Then
Set olOutlookApp = CreateObject("Outlook.Application")
End If

Set olNms = olOutlookApp.GetNamespace("MAPI")
Set olFldrP = olNms.Folders("Public Folders")
Set olFldrP = olFldrP.Folders("All Public Folders")
Set olFldr = olFldrP.Folders("Client Email Contacts")
Set olItms = olFldr.Items

Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("qryListEmailableClients", dbOpenSnapshot)
lngcount = rst.RecordCount

For lngPosition = 1 To lngcount
With rst
strTitle = Nz(![prefix])
strFirstName = Nz(![First Name])
strLastName = Nz(![Surname])
strSuffix = Nz(![suffix])
strCompany = Nz(![Company])
strLastNameFirst = Nz(![Surname]) & ", " & Nz(![First Name])
strEMailAddress = Nz(![Email Address])
strNickName = Nz(![dear])
End With

Set olItm = olItms.Add("IPM.Contact")

With olItm
.Title = strTitle
.FirstName = strFirstName
.LastName = strLastName
.CompanyName = strCompany
.suffix = strSuffix
.NickName = strNickName
.Email1Address = strEMailAddress
.Save
.Close (olSave)
End With
rst.MoveNext
Next lngPosition

End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top