Full Version: Sending email via code.
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
dhapp
I have a button on a form with code behind to send an email. It works fine on my machine but not for the customer.

Here is the line of code that is causing the problem: EmailAddress = Me.ContactPerson & " [" & Me.ContactPersonEmail & "]"

This produces an address line like Joe Smith [jsmith@xyz.com] in the email client (Outlook).

The client is getting mail to bounce back with the following message: Host unknown (Name server: xyz.com]: host not found)

Apparently the mail server is reading the ] as part of the server name.

If I use the same application I do not get the bounce backs. I suspect this is an issue with my customers' email service.
Is there a way to write the code to avoid the problem?
Doug Steele
I believe all you need is

EmailAddress = Me.ContactPersonEmail
JVanKirk
What about just ditching the contact person name and just using the email address?
JVanKirk
yeah..what Doug said LOL..glad we agree sad.gif
dhapp
Doug, Jason,

Your answer is functional but less aesthetically pleasing. I may need to resort to that if the problem persists.

Thanks very much.
dhapp
I did some research on this topic and found that wrapping an email address in square brackets [ ] works on some email systems, but not all.
Wrapping an email address in chevrons < > is universally accepted.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.