Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Outlook does not recognize one or more names

Status
Not open for further replies.

ctudose

Programmer
Nov 22, 2001
33
0
0
CA
I used automation for sending emails using this function :

Sub SendMessage(DisplayMsg As Boolean, CompanyEmail As Variant,AttachmentPath As Variant)
Microsoft Article ID: Q161088

I read the CompanyEmail from a table

Problem:

If DisplayMsg = True - OK - , no metter "how big" is the CompanyEmail ( e.g. " ex1@usa.net " - 1 address or "ex1@usa.net;ex1@usa.net - 2 addresses)

But... if DisplayMsg = False - for sending the messages in background, I've got an error message(see Subject)
JUST for the records with a CompanyEmail > 1 (e.g. " ex1@usa.net ; ex2@usa.net " -2 email addresses)

How can I resolve this issue ?
Any help would be very appreciate
Thx in advance
Cris

 
Cris,

It's hard to know what your problem might be without seeing the problem code. You obviously do some string concatenation to come up with the address string. It could be that is not correct, the email addresses in your table could be invalid, the code within the SendMessage subroutine could be incorrect. Have you used the debugger to stop the processing and stepped through each line of code evaluating the variables?

Steve King Growth follows a healthy professional curiosity
 
Hi Steve,

The BIG problem is as I said :

If I call the function with DisplayMsg = True it works perfect : send ALL records

If I call the function with DisplayMsj = False (SAME records, no concatenation,no wrong e-mails addresses ) it sends ALL records with ONE e-amil address and STOP at the first record with more than 1 email address in the CompanyEmail field

I used degugger and i've got :
Outlook does not recognize one or more names

Weird,isn't it ?
Any ideas ?
 
Plug this into you subroutine, set the breakpoint on the 'Resume Exit_Proc", get your error, Move the processing to the 'Resume' line and press F8. This will bring you to the line that caused the problem. Check out the variable and determine why the problem occurred. If a variable is incorrect it probably happened previously so set the breakpoint up the code and inspect the variable from where it was created.

I noticed you are quoting Microsoft Article ID: Q161088. Frequently they don't include the error handling routines.

On Error GoTo HandleErr

Exit_Proc:
Exit Sub

HandleErr:
Resume Exit_Proc
Resume

Steve King Growth follows a healthy professional curiosity
 
ctudose (Programmer) May 24, 2002
Ok Steve...

I'll give you the best example posssible :) . ok ?
Go to Microsoft web site search by :Q161088
do all the step there

Do one modification in the function's body :
Set objOutlookRecip = .Recipients.Add("Nancy Davolio")

will become

Set objOutlookRecip = .Recipients.Add("Steve King;Steve King")

run the code with true and false
see the behavior

still wait your opinion
thx a lot
cris
 
This is a cut and paste from the Knowledge Base. It is however merely a sample that would require you to add another parameter to the subroutine to pass in the email addresses from your table or to create a recordset somewhere before you are addressing it.

#1 (Externally Pass an Address)

Sub SendMessage(DisplayMsg As Boolean, ToWho As String, Optional AttachmentPath)
Set objOutlookRecip = .Recipients.Add(ToWho)

#2 (Select a list of names from inside the subroutine) Note: you would probably still want to add a parameter to the function to select a set of people using the SQL statement.

Dim rst As DAO.Recordset
Dim AddTo As String
Set rst = CurrentDb.OpenRecordset("SELECT ToNames FROM MyAddressesTable)
If rst.RecordCount <> 0 Then
rst.MoveFirst
Else
Exit Sub
End If
Do While Not rst.EOF
AddTo = AddTo & rst!MyNameInTheRecordset & &quot;;&quot;
DoEvents
Loop
Set objOutlookRecip = .Recipients.Add(AddTo)


Sub SendMessage(DisplayMsg As Boolean, Optional AttachmentPath)
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment

' Create the Outlook session.
Set objOutlook = CreateObject(&quot;Outlook.Application&quot;)

' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

With objOutlookMsg
' Add the To recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add(&quot;Nancy Davolio&quot;)
objOutlookRecip.Type = olTo

Steve King Growth follows a healthy professional curiosity
 
Steve,

I really appreciate your help .
But please be more specific
Have you ran the code with 2 e-mail addresses to see the differences ?
Can you explain why the SendMessage function acts different(True/False) when there are more than 1 e-mail address (To filed ):
Set objOutlookRecip = .Recipients.Add(&quot;Nancy Davolio;Nancy Davalio&quot;)

Can you ?????????????????
I just need a hint... no code ... please

Thx again,
Cris
 
Cris,

In my opinion, here is the reason. The sample code does not show multiple email addresses being added with the .Add. I do not believe that you can do the following

Set objOutlookRecip = .Recipients.Add(&quot;Nancy Davolio;Steve King&quot;)

But would instead need to loop through a set of recipients in a recordset or array and add each to the list of recipients.

Steve King Growth follows a healthy professional curiosity
 
Steve,

Belive me, you can do!!!!!!!
Try and see.

The only restriction is DisplayMsg = True , otherwise
you'll get that error message.

So... again WHY ????????????????

And by the way .... is nobody on this forum who had this problem before ???????????

Thx for your time
Cris



 
I've written a few of these and guess never had any problem. One thing is I that I never used a variant. Is your variant an array or a concatenated string? Just tested one of my old simple routines and it worked fine. So you are right about the .Add allowing multiple addressees. Try converting the variant to a string character. I know it shouldn't make any difference but try it. That's what troubleshooting is all about.

This worked on my subroutine.
Call SendMsg(&quot;scking;jtanner&quot;, &quot;Any Subject&quot;, &quot;My message body&quot;)

Steve King Growth follows a healthy professional curiosity
 
Hi Cris,

is your problem solved yet?

I get the same error when I try to send a message to people whose addresses I fetch from a database, but only when the email address is in any way 'wrong' in such a way, that if you would send the message manually in Outlook, it too would refuse to send it because it doesn't recognize the name.

For instance, try to send a message in Outlook (whether manually or through VBA code from Access) with any one of the following 'errors' and you will notice that Outlook won't let you:
1) two @ @ characters in one address
2) a @ at the beginning of an address
3) a @ at the end of an address

Maybe that's what went wrong in your 'Steve King' example? That there was no separating semicolon ; between the addresses and therefore Outlook saw two @ characters in one string.

Greetings from Holland,
Keimpe



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top