2

I'm using Java to execute a shell command (on windows) to open the default mail client. The mailto command has a lot of bcc email addresses.

If the list is too long, only some of the addresses will be displayed.

I'm guessing this is due to an issue regarding the max command line length in Windows.

Does anyone have any ideas on how I could fix this? As a last resort, I could paste the addresses into the clipboard, but this is a dirty hack IMHO and any better suggestions would be appreciated.

Volo
  • 28,673
  • 12
  • 97
  • 125
jtnire
  • 1,348
  • 5
  • 21
  • 32

2 Answers2

0

I had/have the same issue and use a function to slice the addresses into manageable chunks which are then sent one by one. This should work, but I have the problem that my mailclient won't open the second window as long as the first one is still open (see Second `window.location = mailto:` fails as long as first one is still open ). You can find the code I use there, perhaps it works for you...

Community
  • 1
  • 1
Hans
  • 1
  • 3
0

If you want literally "open default mail client" - for example to allow user to modify the mesage before sending it - then there is no general solution. If client program can read address list from a file - you can create that file and pass it as a parameter; or maybe if it can read the whole message from file /stdin, and parse mail headers - you can use that. But that strongly depends on the features of specific client, and is a bit of a hack (and obviously not portable). However if you just need to send mail - check out Java Mail API; that should be able to deal with very long lists, because implements underlying mailing protocol w/o invoking OS commands.

Andrey Nudko
  • 697
  • 5
  • 5