![]() |
Checking Outlook Email Address
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 dont resolve. -- Trefor |
Checking Outlook Email Address
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 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 |
Checking Outlook Email Address
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 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 dont resolve. -- Trefor |
Checking Outlook Email Address
|
Checking Outlook Email Address
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 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 |
Checking Outlook Email Address
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 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 |
Checking Outlook Email Address
Glad to hear it!
--JP On Sep 18, 12:20*pm, Trefor 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 |
All times are GMT +1. The time now is 10:33 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com