Create a .eml (email) file in Java

You can create eml files with the following code. It works fine with thunderbird and probably with other email clients: public static void createMessage(String to, String from, String subject, String body, List<File> attachments) { try { Message message = new MimeMessage(Session.getInstance(System.getProperties())); message.setFrom(new InternetAddress(from)); message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(to)); message.setSubject(subject); // create the message part MimeBodyPart content = new … Read more

Recommendations on parsing .eml files in C#

Added August 2017: Check out MimeKit: https://github.com/jstedfast/MimeKit. It supports .NET Standard, so will run cross-platform. Original answer: I posted a sample project to illustrate this answer to Github The CDO COM DLL is part of Windows/IIS and can be referenced in .net. It will provide accurate parsing and a nice object model. Use it in … Read more

How to save MailMessage object to disk as *.eml or *.msg file

For simplicity, I’ll just quote an explanation from a Connect item: You can actually configure the SmtpClient to send emails to the file system instead of the network. You can do this programmatically using the following code: SmtpClient client = new SmtpClient(“mysmtphost”); client.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory; client.PickupDirectoryLocation = @”C:\somedirectory”; client.Send(message); You can also set this up … Read more