Results 1 to 7 of 7

Thread: [Resolved] Email address chokes Outlook.

  1. #1

    Thread Starter
    Fanatic Member Comintern's Avatar
    Join Date
    Nov 2004
    Location
    Lincoln, NE
    Posts
    826

    Resolved [Resolved] Email address chokes Outlook.

    OK, I have a macro that generates worksheets to send to another department. That department added a new member who's email address managed to break my mail routine, and I can't figure out why. I use the internal network email addressing ("Lastname, Firstname") because it's a lot easier than remembering who all the addresses belong to (our address system is kind of cryptic). Here's the code I use:

    VB Code:
    1. If Len(frmOutputOpts.cmbEmailTo.Text) > 0 Then   'ComboBox with email addresses.
    2.     Set oOutlook = New Outlook.Application
    3.     Set oEmail = oOutlook.CreateItem(olMailItem)
    4.     With oEmail
    5.         If frmOutputOpts.cbxCC.Value = True Then
    6.             Set oRecip = .Recipients.Add("Xxxxxxxxx, Xxxxx")   'Real name removed.
    7.             oRecip.Type = olCC
    8.         End If
    9.         .Recipients.Add (frmOutputOpts.cmbEmailTo.Text)
    10.         .Subject = frmDeathClaim.txtLastName.Text + ", " + frmDeathClaim.txtPolicyNum.Text
    11.         Call .Attachments.Add(sSaveAs, olByValue, 1, oEmail.Subject + ".doc")
    12.         .Send
    13.     End With
    14.     Set oRecip = Nothing
    15.     Set oEmail = Nothing
    16.     Set oOutlook = Nothing
    17. End If
    It gives Error number -1179631611, Outlook does not recognize one or more names, on the .Send line. Strange thing is, I can copy and paste the email address from my ComboBox into Outlook manually, and it works fine from there. Just not through code. The new email address is:

    Xxxxxxx, Xxxxx (Life Annuity Claims)

    I'm guessing it has something to do with the ()'s. I can do a workaround and use the [email protected] format, but I don't want to hard-code addresses into the macro.

    Any ideas?
    Last edited by Comintern; Mar 24th, 2005 at 05:43 PM. Reason: Problem resolved, thanks!

  2. #2
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Email address chokes Outlook.

    Looks like an old compuserve address. I think they've converted all of them to a more conventional naming expression.

  3. #3

    Thread Starter
    Fanatic Member Comintern's Avatar
    Join Date
    Nov 2004
    Location
    Lincoln, NE
    Posts
    826

    Re: Email address chokes Outlook.

    Actually, it's our internal intranet mail system. Problem is, when more than one person in the company has the same name, they stick the department name in parentheses after the "Last, First". The normal ([email protected]) email addresses are 5 character alfa-numerics that follow one of about 6 different conventions depending on when the individual joined the company.

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Email address chokes Outlook.

    The parenthesis is used as a delimiter for things like the "Display As" and the "File As".
    I feel you pain on this one. How about trying to resolve the address and catch the errors?

    VB Code:
    1. If Len(frmOutputOpts.cmbEmailTo.Text) > 0 Then   'ComboBox with email addresses.
    2.         Set oOutlook = New Outlook.Application
    3.         Set oEmail = oOutlook.CreateItem(olMailItem)
    4.         With oEmail
    5.             If frmOutputOpts.cbxCC.Value = True Then
    6.                 Set oRecip = .Recipients.Add("Xxxxxxxxx, Xxxxx")    'Real name removed.
    7.                 oRecip.Type = olCC
    8.                 If Not .Recipients.ResolveAll Then 'Or however else you want to handle the error
    9.                     MsgBox "Email address error!"
    10.                 End If
    11.             End If
    12.             .Recipients.Add (frmOutputOpts.cmbEmailTo.Text) 'Will the To also have the "(" chars?
    13.             .Subject = frmDeathClaim.txtLastName.Text + ", " + frmDeathClaim.txtPolicyNum.Text
    14.             Call .Attachments.Add(sSaveAs, olByValue, 1, oEmail.Subject + ".doc")
    15.             .Send
    16.         End With
    17.         Set oRecip = Nothing
    18.         Set oEmail = Nothing
    19.         Set oOutlook = Nothing
    20.     End If
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5

    Thread Starter
    Fanatic Member Comintern's Avatar
    Join Date
    Nov 2004
    Location
    Lincoln, NE
    Posts
    826

    Re: Email address chokes Outlook.

    OK, don't ask me why, but this fixed it:

    VB Code:
    1. Set oRecip = .Recipients.Add(frmOutputOpts.cmbEmailTo.Text)
    2.         oRecip.Resolve

    For some reason it likes it when I resolve it explicitly, but not when I let .Send do it. Thanks RobDog888.

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [Resolved] Email address chokes Outlook.

    Thanks

    Resolve verifies against the Address book or Contacts that the Addresses added to the
    mailitem that they are valid
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  7. #7
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950

    Re: [Resolved] Email address chokes Outlook.

    Never had that problem, but it's a handy thing to know.
    Tengo mas preguntas que contestas

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width