Thread
:
Checking Outlook Email Address
View Single Post
#
5
Posted to microsoft.public.excel.programming
Trefor
external usenet poster
Posts: 201
Checking Outlook Email Address
JP,
Yes I understand if I construct the full email address I won't need to
resolve them. Problem is I don't have the full email address and for some
reason our names are full names including the middle name and to make it
worse shortened name so:
"Jones, Rodney John"
Might be:
"Jones, Rod" as a resolved name
or
I have tried taking the left part of the name up to and including the first
3 characters of the first name and this fixes the middle name issue and most
short name. Problem is we are a big company and chances are there is more
than one entry that now matches my choice.
All I want to do at this stage is check if it resolves, if it does I will
..Send the message and if it doesn't I will just .Display it and someone can
manually check the few that do not go through.
Below is my code can you suggest what I can do to check the names?
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)
With OutMail
.To = ETo
.CC = Ecc
.BCC = EBcc
.Subject = ESubject
.Body = Emsg
If EDisplayorSend = "Display" Then .Display
If EDisplayorSend = "Send" Then
If names.ResolveAll then <<< something here would work for me????
.Send
Else
.Display
End if
End With
--
Trefor
"JP" wrote:
I guess I should have mentioned that if you are only having trouble
with specific email addresses, just convert them to
instead of trying to use the Addressbook name. This happens to me when
someone in my Addressbook has a fax number and email address, Outlook
doesn't know which one to use, so the email cannot be sent.
If the display name is "John Smith" and the email address is
", just replace the name with the email address
and it should resolve every time.
If that's not possible, there is some sample code in the Outlook VBIDE
if you type "ResolveAll" and press F1. I modified it slightly to work
in Excel. Keep in mind that those code will trigger the Outlook
security prompt, since you are accessing the Recipients collection.
Sub CheckRecipients()
Dim myOlApp As Object
Dim MyItem As Object
Dim myRecipients As Object
Dim myRecipient As Object
Dim ThisRecip As Object
Dim i As Long
Set myOlApp = CreateObject("Outlook.Application")
Set MyItem = myOlApp.CreateItem(0)
'MyItem.Display
Set myRecipients = MyItem.Recipients
myRecipients.Add ("Aaron Con")
myRecipients.Add ("Nate Sun")
myRecipients.Add ("Dan Wilson")
If Not myRecipients.ResolveAll Then
For i = myRecipients.Count To 1 Step -1
If Not myRecipients.Item(i).Resolved Then
myRecipients.Remove (i)
End If
Next i
End If
End Sub
This code checks if all the names are resolved, and if not, it steps
through the Recipients collection and removes the ones that aren't
resolved. If you wanted to do something else with the names (i.e.
build a string of names of people who weren't resolved), write back
and we can work on that.
--JP
On Sep 16, 1:18 pm, Trefor wrote:
JP,
Sounds good. Where I can get more info on this? I tried help on a few key
words on your post, but could not find out any more details. Do you have a
reference or sample code?
--
Trefor
"JP" wrote:
The Resolved Property of the Recipient Object returns True/False
depending on whether the recipient name has been resolved. Also the
Resolve Method does the same thing. You can loop through the
Recipients Collection and run the Resolve method on each one. If
False, you can remove them from the Recipient list, build a string
showing which recipients were removed, etc.
--JP
Reply With Quote
Trefor
View Public Profile
Find all posts by Trefor