|
-
Mar 24th, 2005, 02:34 PM
#1
Thread Starter
Fanatic Member
[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:
If Len(frmOutputOpts.cmbEmailTo.Text) > 0 Then 'ComboBox with email addresses.
Set oOutlook = New Outlook.Application
Set oEmail = oOutlook.CreateItem(olMailItem)
With oEmail
If frmOutputOpts.cbxCC.Value = True Then
Set oRecip = .Recipients.Add("Xxxxxxxxx, Xxxxx") 'Real name removed.
oRecip.Type = olCC
End If
.Recipients.Add (frmOutputOpts.cmbEmailTo.Text)
.Subject = frmDeathClaim.txtLastName.Text + ", " + frmDeathClaim.txtPolicyNum.Text
Call .Attachments.Add(sSaveAs, olByValue, 1, oEmail.Subject + ".doc")
.Send
End With
Set oRecip = Nothing
Set oEmail = Nothing
Set oOutlook = Nothing
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!
-
Mar 24th, 2005, 04:46 PM
#2
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.
-
Mar 24th, 2005, 04:53 PM
#3
Thread Starter
Fanatic Member
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.
-
Mar 24th, 2005, 05:07 PM
#4
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:
If Len(frmOutputOpts.cmbEmailTo.Text) > 0 Then 'ComboBox with email addresses.
Set oOutlook = New Outlook.Application
Set oEmail = oOutlook.CreateItem(olMailItem)
With oEmail
If frmOutputOpts.cbxCC.Value = True Then
Set oRecip = .Recipients.Add("Xxxxxxxxx, Xxxxx") 'Real name removed.
oRecip.Type = olCC
If Not .Recipients.ResolveAll Then 'Or however else you want to handle the error
MsgBox "Email address error!"
End If
End If
.Recipients.Add (frmOutputOpts.cmbEmailTo.Text) 'Will the To also have the "(" chars?
.Subject = frmDeathClaim.txtLastName.Text + ", " + frmDeathClaim.txtPolicyNum.Text
Call .Attachments.Add(sSaveAs, olByValue, 1, oEmail.Subject + ".doc")
.Send
End With
Set oRecip = Nothing
Set oEmail = Nothing
Set oOutlook = Nothing
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Mar 24th, 2005, 05:42 PM
#5
Thread Starter
Fanatic Member
Re: Email address chokes Outlook.
OK, don't ask me why, but this fixed it:
VB Code:
Set oRecip = .Recipients.Add(frmOutputOpts.cmbEmailTo.Text)
oRecip.Resolve
For some reason it likes it when I resolve it explicitly, but not when I let .Send do it. Thanks RobDog888.
-
Mar 24th, 2005, 10:20 PM
#6
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Mar 25th, 2005, 10:37 AM
#7
Frenzied Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|