Outlook does not recognize one or more names

mcintoan

New Member
Joined
May 20, 2012
Messages
13
Hi again

Got a problem where outlook comes up with an error saying "Outlook does not recognize one or more names" where on the spreadsheet it is referencing to has a single email address.

Even when i type in the email address directly into the code with the same error

Now if i swap .send with .display, the email works fine but is useless for automation purposes.

Anybody got any ideas, cause i'm stumped :confused::oops:

Code:
Sub format()

Application.ScreenUpdating = False


Dim fmt As Worksheet, inp As Worksheet, v0 As Worksheet


Set fmt = Worksheets("Format")
Set inp = Worksheets("import")
Set v0 = Worksheets("Parameters")


inp.Activate


''-----------------------------------------
'Find and insert Deliver to address
Range("B1:B20").Find("Deliver To", LookIn:=xlValues, MatchCase:=False).Activate


ActiveCell.Offset(0, 1).Activate
    If IsEmpty(ActiveCell) = True Then
        ActiveCell.Offset(1, 0).Activate
    End If


Dim dt1 As Variant, dt2 As Variant, dt3 As Variant
dt1 = Application.VLookup(ActiveCell.Value, Worksheets("Parameters").Range("A:D"), 2, False)
dt2 = Application.VLookup(ActiveCell.Value, Worksheets("Parameters").Range("A:D"), 2 + 1, False)
dt3 = Application.VLookup(ActiveCell.Value, Worksheets("Parameters").Range("A:D"), 2 + 2, False)


'VLookup Error Handling
If IsError(dt1) Then
dt1 = ActiveCell.Value
dt2 = "(Address Not programmed)"
dt3 = ""
End If


With fmt
.Range("C11").Value = dt1
.Range("C12").Value = dt2
.Range("C13").Value = dt3
End With


''-----------------------------------
'Body Content Insertion
Dim rng As Range, rng2 As Range
Dim mr As Long, r1 As Long, r2 As Long
Dim rstart As Long, rend As Long


'sets maximum row scan


mr = v0.Range("K1").Value


For r1 = 1 To mr Step 1


'finds the beginning of each POs by looking for the *** START OF PURCHASE ORDER - *** part
    If InStr(1, LCase(Range("C" & r1)), "start of purchase order") > 0 Then
        rstart = r1
          
          'get the last row of that section
        For r2 = r1 To mr Step 1
            If InStr(1, LCase(Range("C" & r2)), "end of purchase order") > 0 Then
                rend = r2
                Exit For
            End If
        Next r2


    For rstart = rstart To rend Step 1
    
    'move data over to formatting
        Select Case Range("B" & rstart).Value
    
            Case "Order Number:"
                fmt.Range("F9").Value = Range("C" & rstart)
                
                
            Case "Order Status:"
                fmt.Range("F14").Value = Range("C" & rstart)
                
            Case "Order Version:"
                fmt.Range("F10").Value = Range("C" & rstart)
            
            Case "Order Date:"
                With fmt.Range("F11")
                .Value = Range("C" & rstart)
                .NumberFormat = "dd/mm/yyyy"
                End With
            
            Case "Delivery Date:"
                With fmt.Range("F12")
                    .Value = Range("C" & rstart)
                    .NumberFormat = "dd/mm/yyyy"
                End With
                
            Case "Item Number"
                rstart = rstart + 1
                itemmove (rstart)
            
       End Select
   Next rstart
    Dim pdfpath As String, pdffn As String


'Export to PDF
    pdfpath = v0.Range("K7") & "\"
    pdffn = "colespo.pdf"
    
    fmt.ExportAsFixedFormat Type:=xlTypePDF, filename:=pdfpath & pdffn


'email the PDF
    
        Dim outapp As Object
        Dim outmail As Object
        
        Set outapp = CreateObject("Outlook.Application")
        Set outmail = outapp.CreateItem(0)
        
        With outmail
            .to = v0.Range("K10").Value


            .Subject = v0.Range("K11").Value
            .body = v0.Range("K12").Value
            .Attachments.add pdfpath & pdffn
           .Send
            
           End With
        
        Set outmail = Nothing
        Set outapp = Nothing
            
    
    Call clearformatting
    inp.Activate
    End If
    
Next r1

Application.ScreenUpdating = True

End Sub
 
Last edited:

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
I was struggling with something similar a while ago but it's back at the office and I don't remember... argh!

Try inserting .recipients.resolve after setting the .to value.

Sorry if this doesn't help but as I said, I really don't remember how I fixed it. Worth a try...
 
Upvote 0
I was struggling with something similar a while ago but it's back at the office and I don't remember... argh!

Try inserting .recipients.resolve after setting the .to value.

Sorry if this doesn't help but as I said, I really don't remember how I fixed it. Worth a try...

Thanks, after that tipped off and a little more googling, .receipents.ResolveAll appears to have done the trick :)
 
Upvote 0

Forum statistics

Threads
1,215,357
Messages
6,124,482
Members
449,165
Latest member
ChipDude83

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top