Outlook could not recognize one or more names?

D

dbguru316

I have the below code that creates an outlook e-mail. I get the error
message "Outlook could not recogniz one or more names." Now varemailtro is
where the error occurse. This variable is equal to the "(e-mail address removed)",
and have added a msgbox to show what it is equal to, so I know it exists and
with the quotes..... The line in the code for declaring its value is:

varemailtrto = Chr(34) & DLookup("[TransmittalEmailAddress]",
"tblTransmittalTo", "[TransmittalTo] Like '" &
[Forms]![frmTransmittal]![TransmittalTo] & "'") & Chr(34)

When varemailtro is used the error message occurs. If I replace the variable
from .To = varemailtrto ....
to .To = "(e-mail address removed)" .....it works, no errors. Any ideas why this
variable approach does not work?

Set objCDOConfig = CreateObject("Outlook.Application")
Set MyItem = objCDOConfig.CreateItem(0) 'olMailItem
With MyItem
.To = varemailtrto
.Subject = "Test"
.ReadReceiptRequested = False '
.Body = "test"
.Send
End With
Set objCDOConfig = Nothing
 
D

dbguru316

Bingo! That worked. Unbelievable. I racked my brains out for hours on
something so simple as that! Not sure why the quotes were a problem, but its
fixed. Many Thanks!

Alex Dybenko said:
Hi,
try to remove quotes:
varemailtrto = DLookup("[TransmittalEmailAddress]",
"tblTransmittalTo", "[TransmittalTo] Like '" &
[Forms]![frmTransmittal]![TransmittalTo] & "'")

--
Best regards,
___________
Alex Dybenko (MVP)
http://accessblog.net
http://www.PointLtd.com

dbguru316 said:
I have the below code that creates an outlook e-mail. I get the error
message "Outlook could not recogniz one or more names." Now varemailtro
is
where the error occurse. This variable is equal to the "(e-mail address removed)",
and have added a msgbox to show what it is equal to, so I know it exists
and
with the quotes..... The line in the code for declaring its value is:

varemailtrto = Chr(34) & DLookup("[TransmittalEmailAddress]",
"tblTransmittalTo", "[TransmittalTo] Like '" &
[Forms]![frmTransmittal]![TransmittalTo] & "'") & Chr(34)

When varemailtro is used the error message occurs. If I replace the
variable
from .To = varemailtrto ....
to .To = "(e-mail address removed)" .....it works, no errors. Any ideas why this
variable approach does not work?

Set objCDOConfig = CreateObject("Outlook.Application")
Set MyItem = objCDOConfig.CreateItem(0) 'olMailItem
With MyItem
.To = varemailtrto
.Subject = "Test"
.ReadReceiptRequested = False '
.Body = "test"
.Send
End With
Set objCDOConfig = Nothing

.
 

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