Skip to main content

Desktop.mail(URI) what are the limits?

3 replies [Last post]
Joined: 2003-06-10

I've found that with Java 6 on Windows XP ( running Outlook email client) that the body size included in the URI provided to Desktop.mail(URI) can cause the API call to fail with a"Error: Access denied")

Is there any way to tell what the limit is at runtime? (Other than re-trying with different length URIs until you cross the boundary.)

I noticed this first when I was making a simple bug reporter that emailed stack traces and found that the method would fail depending on exception being reported.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2008-04-17

Hi, I had the same problem, but with the mail address limits.
But, in linux didn't have problem, only in Windows.

What are the solutions for this problem ?

Joined: 2005-09-13

I'm not sure if this helps, but if the mail(URI) throws an IOException, then the mail client wasn't found OR failed to launch.
since you seem to be able to send "short" emails, my guess is that with large text java fails to launch outlook (this might be caused by outlook and not java... maybe)

anyway, i hope this helps (from java 6 documentation):

mailtoURI - the specified mailto: URI
NullPointerException - if the specified URI is null
IllegalArgumentException - if the URI scheme is not "mailto"
UnsupportedOperationException - if the current platform does not support the Desktop.Action.MAIL action
IOException - if the user default mail client is not found or fails to be launched
SecurityException - if a security manager exists and it denies the AWTPermission("showWindowWithoutWarningBanner") permission, or the calling thread is not allowed to create a subprocess"

Joined: 2003-06-10

Good call... now that I think about it this could be a limit imposed by the length of a command line or something similar. It still would be nice if this limit was documented and even better if there was a property that could be queried to get that length.

The problem would still remain that even knowing the maximum length of a command line, there is no way to know the exact length of the command line generated by this call (if that's how it works). Though, it would probably be easier to make a reasonable guess at the limit on the URL length.