Help me, I need send mail from Outlook, with html in the body mail. I not know set the MimeType or Content Type
public class Main { public static void main(String[] args) { ActiveXComponent oOutlook = new ActiveXComponent("Outlook.Application"); Dispatch.call(oOutlook ,"GetNamespace","MAPI").toDispatch(); Dispatch email = Dispatch.invoke(oOutlook.getObject(),"CreateItem", Dispatch.Get, new Object[] { "0" }, new int[0]).toDispatch(); Dispatch.put(email, "To", destinatario); Dispatch.put(email, "Subject", asunto); Dispatch.put(email, "Body", cuerpoMensaje); Dispatch.put(email, "Body", getCuerpoEmail("C:\\archivo.html")); Dispatch.put(email, "ReadReceiptRequested", "false"); try { Dispatch.call(email, "Send"); } catch (com.jacob.com.ComFailException e) { e.printStackTrace(); } } public static String getCuerpoEmail(String fileName) { String message = null; FileInputStream file; try { file = new FileInputStream(fileName); byte[] b = new byte[file.available()]; file.read(b); file.close(); message = new String(b); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return message; } }
Log in to post a comment.
Help me, I need send mail from Outlook, with html in the body mail.
I not know set the MimeType or Content Type