Send an email from a Java Web App and Outlook (with Exchange Server) should resolve the From field


My client ask me to send an automatic email from a Java Web App. The from field is automatically filled with the user lastname and firstname. I use an InternetAddress(email, personal) object to fill the from of an MimeMessage object.

When the group received the email, they see:
eg. Smith, John <>

But when they try to get more information from the GAL (Outlook on Exchange Infrastructure), they can't get any more information about the user (username, calendar, etc.)

Is there a way to generate the mail to tell Outlook to handle this field like it was sent by Outlook itself ? I tried to look at the source code of the email but didn't see any clues there.

Also, I can't use another class than javax.mail.* to do this. (Business restriction).

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

What is the default display set in GAL? Lastname, Firstname?

You said that you used Internet mail and the receiver will received as Smith, John <>, since you using the internet mail, it is normal for GAL unable to provide the details since this email address doesn't exist on GAL.

Do you try using internal email?
SolutionsTIAuthor Commented:

The format in GAL is Lastname, Firstname. I've tried to display only the display name, but it didn't work.

The same thing happen if I display only the SMTP address.

Is there a way to achieve this ? If not, I'll try to manage the problem from the client view instead of the server view (a macro like).

I think this is because the email isn't really going through exchange. Do you see the sent messages in John Smith's sent items folder?
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

SolutionsTIAuthor Commented:
No, because the email is sent by the server. We only use the user information to fill the From field of the MimeMessage to inform the recipient who had sent the email.

I suppose that Outlook (and Exchange) wrap the email with it's own information while it's processed. Do you thing we can "integrate" some code to simulate this ?

Thanks again !
Yes, there is extra information in the message that would tell Outlook that the message is from an Exchange user in the GAL.

Basically, you need to send an XML formatted POST to the EWS URL on an Exchange CAS server.

The way Exchange knows whom to send it from is to require authentication on that EWS URL. Normally, you'd use the EWS Managed API (yes, there is even a Java version) to abstract all this for you, but if that's not going to be an option, you will need to create an XMLHTTPRequest object, assign some credentials (so that it knows who is sending it), and send your XML data to the URL.

Or, you could try doing it with an automated Telnet session to the CAS server. Don't really know how you'd set that up in Java, though.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SolutionsTIAuthor Commented:
Thanks LeeDerbyshire for the explanation.

Actually, yes isn't an option to use a new API. Also, since this feature is already done in one way, and our client can manage this by updating their Macros. I'll just put some information in the body for them.

Thanks again all!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.