I am using Access to create and send an Outlook mail item. I have a table containing email addresses to use for the recipients (in user@domain.com format). I need to make sure before I send the email that the addresses have been matched to the Exchange address list.
In other words, if I were to do this manually, I would create a new mail item in Outlook. I would type in jgeo@domain.com and hit the check address button. If the address is an employee, Outlook changes it to "Geo, Johnny" and underlines it. That validation is what I am trying to capture in my code.
Does Outlook validate as soon as the recipient is added? Do I have to save the message first, etc.?
Here's my code so far:
then depending on whether "jgeo@domain.com" was recognized or not, I would either save or send
Thanks,
Johnny Geo
In other words, if I were to do this manually, I would create a new mail item in Outlook. I would type in jgeo@domain.com and hit the check address button. If the address is an employee, Outlook changes it to "Geo, Johnny" and underlines it. That validation is what I am trying to capture in my code.
Does Outlook validate as soon as the recipient is added? Do I have to save the message first, etc.?
Here's my code so far:
Code:
Sub sendEmail()
Dim myOutlook As Object
Dim myEmail As Object
Set myOutlook = CreateObject("Outlook.Application")
Set myEmail = myOutlook.CreateItem(olMailItem)
Set myRecipient = myEmail.Recipients.Add("jgeo@domain.com")
myEmail.Subject = "Subject Line"
myEmail.Body = "Body Text" & Chr(10)
Code:
if ........ then
myEmail.Send
else
myEmail.Save
end if
Set myOutlook = Nothing
End Sub
Thanks,
Johnny Geo