{"id":1326,"date":"2012-05-25T14:07:10","date_gmt":"2012-05-25T12:07:10","guid":{"rendered":"http:\/\/www.tutego.de\/blog\/javainsel\/?p=1326"},"modified":"2012-05-25T14:07:56","modified_gmt":"2012-05-25T12:07:56","slug":"gmail-urls-generieren","status":"publish","type":"post","link":"https:\/\/www.tutego.de\/blog\/javainsel\/2012\/05\/gmail-urls-generieren\/","title":{"rendered":"GMail-URLs generieren"},"content":{"rendered":"<pre style=\"background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px\"><span style=\"color: #0000ff\">private<\/span> <span style=\"color: #0000ff\">static<\/span> String createGMailUrl( String to, String cc, String subject, String body )\n<pre style=\"background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px\">{\n<pre style=\"background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px\">  StringBuilder result = <span style=\"color: #0000ff\">new<\/span> StringBuilder( &quot;<span style=\"color: #8b0000\">https:\/\/mail.google.com\/mail\/?view=cm&amp;tf=0<\/span>&quot; );\n<pre style=\"background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px\">  \n<pre style=\"background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px\">  <span style=\"color: #0000ff\">if<\/span> ( to != <span style=\"color: #0000ff\">null<\/span> &amp;&amp; ! to.isEmpty() )\n<pre style=\"background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px\">    result.append( &quot;<span style=\"color: #8b0000\">&amp;to=<\/span>&quot; ).append( to );\n<pre style=\"background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px\"><pre style=\"background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px\">  <span style=\"color: #0000ff\">if<\/span> ( cc != <span style=\"color: #0000ff\">null<\/span> &amp;&amp; ! cc.isEmpty() )\n<pre style=\"background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px\">    result.append( &quot;<span style=\"color: #8b0000\">&amp;cc=<\/span>&quot; ).append( cc );\n<pre style=\"background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px\"><pre style=\"background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px\">  <span style=\"color: #0000ff\">if<\/span> ( subject != <span style=\"color: #0000ff\">null<\/span> &amp;&amp; ! subject.isEmpty() ) {\n<pre style=\"background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px\">    <span style=\"color: #0000ff\">try<\/span> {\n<pre style=\"background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px\">      result.append( &quot;<span style=\"color: #8b0000\">&amp;su=<\/span>&quot; ).append( encode( subject ) );\n<pre style=\"background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px\">    }\n<pre style=\"background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px\">    <span style=\"color: #0000ff\">catch<\/span> ( UnsupportedEncodingException e ) {\n<pre style=\"background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px\">      e.printStackTrace();\n<pre style=\"background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px\">    }\n<pre style=\"background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px\">  }\n<pre style=\"background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px\"><pre style=\"background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px\">  <span style=\"color: #0000ff\">if<\/span> ( body != <span style=\"color: #0000ff\">null<\/span> &amp;&amp; ! body.isEmpty() ) {\n<pre style=\"background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px\">    <span style=\"color: #0000ff\">try<\/span> {\n<pre style=\"background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px\">      result.append( &quot;<span style=\"color: #8b0000\">&amp;body=<\/span>&quot; ).append( encode( body ) );\n<pre style=\"background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px\">    }\n<pre style=\"background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px\">    <span style=\"color: #0000ff\">catch<\/span> ( UnsupportedEncodingException e ) {\n<pre style=\"background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px\">      e.printStackTrace();\n<pre style=\"background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px\">    }\n<pre style=\"background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px\">  }\n<pre style=\"background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px\"><pre style=\"background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px\">  <span style=\"color: #0000ff\">return<\/span> result.toString();\n<pre style=\"background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px\">}\n<pre style=\"background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px\"><pre style=\"background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px\"><span style=\"color: #0000ff\">private<\/span> <span style=\"color: #0000ff\">static<\/span> String encode( String param ) <span style=\"color: #0000ff\">throws<\/span> UnsupportedEncodingException\n<pre style=\"background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px\">{    \n<pre style=\"background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px\">  <span style=\"color: #0000ff\">byte<\/span>[] utf8 = param.getBytes( &quot;<span style=\"color: #8b0000\">utf-8<\/span>&quot; );\n<pre style=\"background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px\">  StringBuilder result = <span style=\"color: #0000ff\">new<\/span> StringBuilder( param.length() * 3 );\n<pre style=\"background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px\">  <span style=\"color: #0000ff\">for<\/span> ( <span style=\"color: #0000ff\">int<\/span> i = 0; i &lt; utf8.length; i++ )\n<pre style=\"background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px\">  {\n<pre style=\"background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px\">    String c = Integer.toString( utf8[ i ] &amp; 0xFF, 16 );\n<pre style=\"background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px\">    result.append( '%' ).append( c.length() == 1 ? &quot;<span style=\"color: #8b0000\">0<\/span>&quot; + c : c );\n<pre style=\"background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px\">  }\n<pre style=\"background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px\">  <span style=\"color: #0000ff\">return<\/span> result.toString();\n<pre style=\"background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 13px\">}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>private static String createGMailUrl( String to, String cc, String subject, String body ) { StringBuilder result = new StringBuilder( &quot;https:\/\/mail.google.com\/mail\/?view=cm&amp;tf=0&quot; ); if ( to != null &amp;&amp; ! to.isEmpty() ) result.append( &quot;&amp;to=&quot; ).append( to ); if ( cc != null &amp;&amp; ! cc.isEmpty() ) result.append( &quot;&amp;cc=&quot; ).append( cc ); if ( subject != null &amp;&amp; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","_links_to":"","_links_to_target":""},"categories":[1],"tags":[],"class_list":["post-1326","post","type-post","status-publish","format-standard","hentry","category-allgemein"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.tutego.de\/blog\/javainsel\/wp-json\/wp\/v2\/posts\/1326","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.tutego.de\/blog\/javainsel\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tutego.de\/blog\/javainsel\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tutego.de\/blog\/javainsel\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tutego.de\/blog\/javainsel\/wp-json\/wp\/v2\/comments?post=1326"}],"version-history":[{"count":2,"href":"https:\/\/www.tutego.de\/blog\/javainsel\/wp-json\/wp\/v2\/posts\/1326\/revisions"}],"predecessor-version":[{"id":1328,"href":"https:\/\/www.tutego.de\/blog\/javainsel\/wp-json\/wp\/v2\/posts\/1326\/revisions\/1328"}],"wp:attachment":[{"href":"https:\/\/www.tutego.de\/blog\/javainsel\/wp-json\/wp\/v2\/media?parent=1326"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tutego.de\/blog\/javainsel\/wp-json\/wp\/v2\/categories?post=1326"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tutego.de\/blog\/javainsel\/wp-json\/wp\/v2\/tags?post=1326"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}