Outlook does not recognize one or more names

Leesha
BronzeLounger
Posts: 1488
Joined: 05 Feb 2010, 22:25

Outlook does not recognize one or more names

Post by Leesha »

Hi,
I have two different Outlook databases that send multiple emails from an Access table. Both run the same code and the code has been the same for at least a year. One database started giving an error "Outlook does not recognize one or more names". I even went back and ran a previous version of the db and it gives the same error. I suspect it's due to something with the email that is blocking the email. I deleted all but one row and deleted all of the email recipients (there are 4) and hand typed in my personal email which I know is correct and I'm still getting the error. Talk about frustrating. Is there code that I can use in an update query that will clear out anything after the .com (or whatever extension they use) to be sure the are no characters that I'm not seeing? OR is there somewhere else I should be looking?
Thanks,
Leesha

User avatar
HansV
Administrator
Posts: 78488
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Outlook does not recognize one or more names

Post by HansV »

Try adding the recipients to your Contacts in Outlook (if they aren't contacts already).
Best wishes,
Hans

Leesha
BronzeLounger
Posts: 1488
Joined: 05 Feb 2010, 22:25

Re: Outlook does not recognize one or more names

Post by Leesha »

Hi Hans,
I added the 2 different email addresses to the Outlook contacts and they went out without an error. My concern is that there are 100's of emails and all are not in Outlook at users which will be an issue for the user. Is there a way around this? I've not had this issue before and haven't had it with the other db which sends out thousands of emails at a time without issue.
Thanks,
Leesha

User avatar
HansV
Administrator
Posts: 78488
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Outlook does not recognize one or more names

Post by HansV »

Which lines of code do you currently use to specify the recipients?
Best wishes,
Hans

Leesha
BronzeLounger
Posts: 1488
Joined: 05 Feb 2010, 22:25

Re: Outlook does not recognize one or more names

Post by Leesha »

Set outMsg = outApp.CreateItem(0) ' olMailItem
With outMsg
' Use the e-mail address field
'Main Email
arrNames = Split(rst![FranchiseeEmail], ",")
For i = 0 To UBound(arrNames)
.Recipients.Add arrNames(i)
Next i

If Not IsNull(rst![FranchiseeEmail2]) Then
arrNames = Split(rst![FranchiseeEmail2], ",")
For i = 0 To UBound(arrNames)
.Recipients.Add arrNames(i)
Next i
End If

If Not IsNull(rst![OtherContactEmail]) Then
arrNames = Split(rst![OtherContactEmail], ",")
For i = 0 To UBound(arrNames)
.Recipients.Add(arrNames(i)).Type = 2
Next i
End If

If Not IsNull(rst![BillingContactEmail]) Then
arrNames = Split(rst![BillingContactEmail], ",")
For i = 0 To UBound(arrNames)
.Recipients.Add(arrNames(i)).Type = 2
Next i
End If

User avatar
HansV
Administrator
Posts: 78488
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Outlook does not recognize one or more names

Post by HansV »

Try this version as a test. It should tell you which name(s) are not recognized.

Code: Select all

        Set outMsg = outApp.CreateItem(0) ' olMailItem
        With outMsg
            ' Use the e-mail address field
            'Main Email
            arrnames = Split(rst![FranchiseeEmail], ",")
            For i = 0 To UBound(arrnames)
                If Not .Recipients.Add(arrnames(i)).Resolve Then
                    MsgBox arrnames(i) & " is not recognized!"
                End If
            Next i

            If Not IsNull(rst![FranchiseeEmail2]) Then
                arrnames = Split(rst![FranchiseeEmail2], ",")
                For i = 0 To UBound(arrnames)
                    If Not .Recipients.Add(arrnames(i)).Resolve Then
                        MsgBox arrnames(i) & " is not recognized!"
                    End If
                Next i
            End If

            If Not IsNull(rst![OtherContactEmail]) Then
               arrnames = Split(rst![OtherContactEmail], ",")
                For i = 0 To UBound(arrnames)
                    If Not .Recipients.Add(arrnames(i)).Resolve Then
                        MsgBox arrnames(i) & " is not recognized!"
                    End If
                Next i
            End If

            If Not IsNull(rst![BillingContactEmail]) Then
                arrnames = Split(rst![BillingContactEmail], ",")
                For i = 0 To UBound(arrnames)
                    If Not .Recipients.Add(arrnames(i)).Resolve Then
                        MsgBox arrnames(i) & " is not recognized!"
                    End If
                Next i
            End If
Best wishes,
Hans

Leesha
BronzeLounger
Posts: 1488
Joined: 05 Feb 2010, 22:25

Re: Outlook does not recognize one or more names

Post by Leesha »

This code worked great! Love it. It also identified another issue that I've been trying to figure out without any luck.

The user chooses the names of the emails to be sent from a query called "qryEmailSpreadsheet". This query only contains very specific fields from [tblInvoice autoTemp]. The reason for this is they don't want to see all the cells from the table, just the ones that show the email has been sent. The code to pick the records points to [tblInvoice autoTemp]. As a result it looks at all the records in the table and sends out all the emails, not just ones chosen. What would the code look like so that the emails are limited to the ones in "qryEmailSpreadsheet" but pulls all the data for each email from [tblInvoice AutoTemp]? This is what the code looks like now:

strSQL = "SELECT * FROM [tblInvoice AutoTemp]" & strWhere

Thanks!
Leesha

Leesha
BronzeLounger
Posts: 1488
Joined: 05 Feb 2010, 22:25

Re: Outlook does not recognize one or more names

Post by Leesha »

Hi Hans,
Please disregard the last question as it doesn't apply. I'm working while on vacation which must be my brain fog!
Anyway, The user deletes the stores from qryEmailSpreadsheet. This also deletes the table from [tblInvoice AutoTemp]. I double checked. I'm now headed to the beach!
Thanks for the new code,
Leesha