PC Review


Reply
Thread Tools Rate Thread

Checking Outlook Email Address

 
 
Trefor
Guest
Posts: n/a
 
      16th Sep 2008
I have written some VBA that sends a bunch of email to internal email
address. I am using a table that contains their name not their email address
and sometimes it will resolve to their correct email address, sometimes it
won't. Is there a way to programmatically check to see if the email has
resolved correctly? Currently I am using .Display and then manually sending
if they are ok, or correcting if they are wrong, ideally I would like to
..Send them all and perhaps hold the ones that don’t resolve.

--
Trefor
 
Reply With Quote
 
 
 
 
JP
Guest
Posts: n/a
 
      16th Sep 2008
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

On Sep 16, 12:31*pm, Trefor <Tre...@home.com> wrote:
> I have written some VBA that sends a bunch of email to internal email
> address. I am using a table that contains their name not their email address
> and sometimes it will resolve to their correct email address, sometimes it
> won't. Is there a way to programmatically check to see if the email has
> resolved correctly? Currently I am using .Display and then manually sending
> if they are ok, or correcting if they are wrong, ideally I would like to
> .Send them all and perhaps hold the ones that don’t resolve.
>
> --
> Trefor


 
Reply With Quote
 
Trefor
Guest
Posts: n/a
 
      16th Sep 2008
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
>
> On Sep 16, 12:31 pm, Trefor <Tre...@home.com> wrote:
> > I have written some VBA that sends a bunch of email to internal email
> > address. I am using a table that contains their name not their email address
> > and sometimes it will resolve to their correct email address, sometimes it
> > won't. Is there a way to programmatically check to see if the email has
> > resolved correctly? Currently I am using .Display and then manually sending
> > if they are ok, or correcting if they are wrong, ideally I would like to
> > .Send them all and perhaps hold the ones that don’t resolve.
> >
> > --
> > Trefor

>
>

 
Reply With Quote
 
JP
Guest
Posts: n/a
 
      17th Sep 2008
I guess I should have mentioned that if you are only having trouble
with specific email addresses, just convert them to (E-Mail Removed)
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
"(E-Mail Removed)", 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 <Tre...@home.com> 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
Guest
Posts: n/a
 
      18th Sep 2008
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 (E-Mail Removed)

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 (E-Mail Removed)
> 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
> "(E-Mail Removed)", 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 <Tre...@home.com> 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
 
JP
Guest
Posts: n/a
 
      18th Sep 2008
In your code, you have to set an object reference to the Recipients
collection, because ResolveAll is a method of the Recipients
collection. So your code would be

Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Dim myRecipients As Outlook.Recipients

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
Exit Sub

If EDisplayorSend = "Send" Then
Set myRecipients = .Recipients
If Not myRecipients.ResolveAll Then
.Display
Else
.Send
End If
End If

End With

Set myRecipients = Nothing
Set OutMail = Nothing
Set OutApp = Nothing



Just curious, why not try to change the inputs -- can you get the list
of email addresses instead of the names?

Is there any other way you can get a list of the email addresses?
Maybe you can export the contact information (name and email address)
from Outlook, then use VLOOKUP or a fuzzy match to match them to the
names from your list.

Where does the table come from that the names are written so
differently than what they are in Outlook?

--JP



On Sep 18, 7:44*am, Trefor <Tre...@home.com> wrote:
> 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 Rod.Jo...@nowhere.com
>

 
Reply With Quote
 
Trefor
Guest
Posts: n/a
 
      18th Sep 2008
JP,

Many thanks for you help, your comments prompted to look in the Outlook
forum and I found a few hints and just tested by revised code (which is
essentially what you said below).

If EDisplayorSend = "Send" Then
If .Recipients.ResolveAll Then
.Send
Else
.Display
End If
Else
.Display
End If

--
Trefor


"JP" wrote:

> In your code, you have to set an object reference to the Recipients
> collection, because ResolveAll is a method of the Recipients
> collection. So your code would be
>
> Dim OutApp As Outlook.Application
> Dim OutMail As Outlook.MailItem
> Dim myRecipients As Outlook.Recipients
>
> 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
> Exit Sub
>
> If EDisplayorSend = "Send" Then
> Set myRecipients = .Recipients
> If Not myRecipients.ResolveAll Then
> .Display
> Else
> .Send
> End If
> End If
>
> End With
>
> Set myRecipients = Nothing
> Set OutMail = Nothing
> Set OutApp = Nothing
>
>
>
> Just curious, why not try to change the inputs -- can you get the list
> of email addresses instead of the names?
>
> Is there any other way you can get a list of the email addresses?
> Maybe you can export the contact information (name and email address)
> from Outlook, then use VLOOKUP or a fuzzy match to match them to the
> names from your list.
>
> Where does the table come from that the names are written so
> differently than what they are in Outlook?
>
> --JP
>
>
>
> On Sep 18, 7:44 am, Trefor <Tre...@home.com> wrote:
> > 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 Rod.Jo...@nowhere.com
> >

>

 
Reply With Quote
 
JP
Guest
Posts: n/a
 
      18th Sep 2008
Glad to hear it!

--JP

On Sep 18, 12:20*pm, Trefor <Tre...@home.com> wrote:
> JP,
>
> Many thanks for you help, your comments prompted to look in the Outlook
> forum and I found a few hints and just tested by revised code (which is
> essentially what you said below).
>
> * * * * If EDisplayorSend = "Send" Then
> * * * * * * If .Recipients.ResolveAll Then
> * * * * * * * * .Send
> * * * * * * Else
> * * * * * * * * .Display
> * * * * * * End If
> * * * * Else
> * * * * * * .Display
> * * * * End If
>
> --
> Trefor
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Checking email address JD Microsoft ASP .NET 2 9th Sep 2005 02:36 PM
Howto Disable Automatic Internet Email Address Checking =?Utf-8?B?U3RldmUgR2Fu?= Microsoft Outlook Discussion 5 4th Nov 2004 06:35 AM
Checking all subfolders as email address books =?Utf-8?B?ZGF2aWQ=?= Microsoft Outlook Contacts 1 17th Oct 2004 07:38 PM
Outlook 2000/2003 and LDAP address checking Microsoft Outlook Discussion 0 4th Jun 2004 08:26 PM
CHECKING EMAIL ADRESSE S AGAINSTTHOSE IN ADDRESS BOOK RON Microsoft Outlook 1 24th Nov 2003 04:47 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:53 AM.