title: Trying to send CSS in HTML email over Outlook with JavaMail
body: <p>I'm trying to send an HTML email by building a string and passing it as a parameter my mail method:</p>
  
  <pre><code>// Build string to send as email message
          StringBuilder buf = new StringBuilder();
          buf.append("&lt;html&gt;" +
                  "&lt;body&gt;" +
                  "&lt;table&gt;" +
                  "&lt;tr style=\"background-color: #8C0000; color: #fff; font-family: Arial; font-size: 14px; font-weight: bold;\"&gt;" +
                  "&lt;th style=\"padding: 10px;\"&gt;Assigned Group&lt;/th&gt;" +
                  "&lt;th style=\"padding: 10px;\"&gt;Incident Type&lt;/th&gt;" +
                  "&lt;th style=\"padding: 10px;\"&gt;Status&lt;/th&gt;" +
                  "&lt;th style=\"padding: 10px;\"&gt;Assignee&lt;/th&gt;" +
                  "&lt;th style=\"padding: 10px;\"&gt;Incident Number&lt;/th&gt;" +
                  "&lt;th style=\"padding: 10px;\"&gt;Priority&lt;/th&gt;" +
                  "&lt;th style=\"padding: 10px;\"&gt;Summary&lt;/th&gt;" +
                  "&lt;/tr&gt;");
          for (int i = 0; i &lt; incidentNumberList.size(); i++) {
              buf.append("&lt;tr style=\"font-family: Arial; font-size: 12px;\"&gt;&lt;td style=\"padding: 10px;\"&gt;")
                      .append(assignedGroup)
                      .append("&lt;/td&gt;&lt;td style=\"padding: 10px;\"&gt;")
                      .append(incidentTypeList.get(i))
                      .append("&lt;/td&gt;&lt;td style=\"padding: 10px;\"&gt;")
                      .append(statusList.get(i))
                      .append("&lt;/td&gt;&lt;td style=\"padding: 10px;\"&gt;")
                      .append(assigneeNameList.get(i))
                      .append("&lt;/td&gt;&lt;td style=\"padding: 10px;\"&gt;")
                      .append(incidentNumberList.get(i))
                      .append("&lt;/td&gt;&lt;td style=\"padding: 10px;\"&gt;")
                      .append(priorityList.get(i))
                      .append("&lt;/td&gt;&lt;td style=\"padding: 10px;\"&gt;")
                      .append(summaryList.get(i))
                      .append("&lt;/td&gt;&lt;/tr&gt;");
          }
          buf.append("&lt;/table&gt;" +
                  "&lt;/body&gt;" +
                  "&lt;/html&gt;");
          String emailMessage = buf.toString();
  
          // Send an email to the manager of the Assigned Group
          sendManagerEmail(emailMessage);
  </code></pre>
  
  <p>Email method:</p>
  
  <pre><code>private static void sendManagerEmail(String emailMessage) {
          final String username = "user";
          final String password = "pass123";
  
          Properties props = new Properties();
          props.put("mail.smtp.auth", "true");
          if (ENCRYPT) {
              props.put("mail.smtp.starttls.enable", "true");
          } else {
              props.put("mail.smtp.starttls.enable", "false");
          }
          props.put("mail.smtp.ssl.trust", "internetsmtp.example.com");
          props.put("mail.smtp.host", "internetsmtp.example.com");
          props.put("mail.smtp.port", "25");
          // SSL
          props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
  
          Session session = Session.getInstance(props,
                  new javax.mail.Authenticator() {
                      protected PasswordAuthentication getPasswordAuthentication() {
                          return new PasswordAuthentication(username, password);
                      }
                  });
  
          try {
              Message message = new MimeMessage(session);
              message.setFrom(new InternetAddress("martin@example.com"));
              message.setRecipients(Message.RecipientType.TO,
                      InternetAddress.parse("martin@example.com"));
              message.setSubject("Tickets — Attention Needed");
              message.setContent(emailMessage
                      , "text/html; charset=utf-8");
  
              Transport.send(message);
  
          } catch (MessagingException e) {
              throw new RuntimeException(e);
          }
      }
  </code></pre>
  
  <p>The important line here is <code>message.setContent(emailMessage
                      , "text/html; charset=utf-8");</code> The string of HTML code I sent into this method comprises the body of the message content.</p>
  
  <p>The email comes formatted with the table but not the CSS, which makes it fairly ugly. Is there anything I can do here to display the CSS? I assumed that building the style directly into the html tags would be enough.</p>