J'utilise la méthode Runtime.exec(mailto:......) afin d'ouvrir directement un nouveau mail depuis mon application.
Ca fonctionne, à ce détail près que le body est toujours coupé (je passe de longues chaînes en paramètres, html oblige). En essayant avec du texte quelconque, il n'y a pas de logique "à la coupure".
les commandes ci dessous contiennent toutes l268 caractères, alors qu'à chaque fois, le body contenait 10 fois tout l'alphabet, soit 260 caractères dans le body. Pourtant, j'ai
J'ai tracé mon string buffer tout le long de l'application : il est complet jusqu'à ce que je fasse Runtime.exec(cmd.toString)...mailto:toto@titi.fr;%20;%20?subject=TEST&cc=;%20;%20&body=abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyza
mailto:totototototottotototototoototototototototoototototootototoooooooooooooooooooooooooottttttttttttttooooooooooouuuuuuuuuuuuuuuuu@titi.fr;%20;%20?subject=TEST&cc=;%20;%20&body=abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghij
mailto:rouge@vert.com;%20bleu@noir.fr;%20?subject=TEST&cc=jaune@blanc.net;%20marron@rose.org;%20&body=abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghi
mailto:rouge@vert.com;%20bleu@noir.fr;%20?subject=TEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEST&cc=jaune@blanc.net;%20marron@rose.org;%20&body=abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwx
Voila le code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 private void sendMail2(String from, String[] to, String[] cc, String Subject, String Text, String[] filesAttachment, String[] filesNames, boolean deleteFiles) { String s_to="",s_cc=""; for(int i=0; i<to.length; i++) { s_to+=""+to[i]+"; "; } for(int i=0; i<to.length; i++) { s_cc+=""+cc[i]+"; "; } final String DEFAULT_CMD_LINE = System.getProperty("os.name").startsWith("Windows" ) ? "explorer " : "mozilla"; StringBuffer url=new StringBuffer(2500); url.append("mailto:"+s_to+"?subject="+Subject+"&cc="+s_cc+"&body="+Text); String[] cmd = new String[2]; cmd[0] = DEFAULT_CMD_LINE; cmd[1] = "" + url.toString() + ""; System.out.println("le buffer contient "+cmd[0]+""+cmd[1]); try { Process process = Runtime.getRuntime().exec(cmd); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } }
Partager