By baconbacon

2018-12-03 22:02:11 8 Comments

I've been working on an email generating program and I am able to generate an email that has either an attachment upon generation using

ProcessBuilder p=new ProcessBuilder("C:\\Program Files (x86)\\Microsoft Office\\Office16\\OUTLOOK.EXE","/a","C:\\BackupData.docx");

or a generated email with the recipient, subject, and body filled out using

URI msg = new URI("mailto", mailer+"&subject="+subject+"?body="+body, (String) null);

My issue is that I cannot figure out a way to generate an Outlook email that has both of these features. If there is some way to combine these to create an email with attachment, and populated subject & body, I would like to know how to do that.


@Alina Li 2018-12-04 07:12:35

You can open the system's email client using the desktop class.

Desktop.getDesktop().mail( new URI( "mailto:[email protected]" ) )

According to these docs the command you need is

"path/to/Outlook.exe /c ipm.note /a \"path/to/attachment\""

Assemble this and run it via ProcessBuilder

Reference from:

to open outlook mail from java program and to attach file to the mail from directory

Related Questions

Sponsored Content

80 Answered Questions

[SOLVED] How to validate an email address in JavaScript?

13 Answered Questions

[SOLVED] Can I set subject/content of email using mailto:?

  • 2011-01-24 12:41:08
  • Jiew Meng
  • 796483 View
  • 808 Score
  • 13 Answer
  • Tags:   html email mailto

31 Answered Questions

[SOLVED] Create ArrayList from array

54 Answered Questions

[SOLVED] Creating a memory leak with Java

71 Answered Questions

34 Answered Questions

2 Answered Questions

Add text to body of email based on recipient specified

1 Answered Questions

[SOLVED] How to pass parameters to a .msg file?

1 Answered Questions

[SOLVED] .NET creating an email with attachments in Office 2010

Sponsored Content