Link to home
Start Free TrialLog in
Avatar of mybluegrass
mybluegrass

asked on

Launch outlook with pre-populated fields and attachments in java

Is it possible to launch outlook with some fields pre-populated (from, to, subject) and attachments attached to the email inside a java application?

Thanks!
Avatar of for_yan
for_yan
Flag of United States of America image


Do you really want to lauvnch outlook or you want to send an email
form java appalications?
If so JavaMail is the best way to dio it
You can use JavaMail to send email and can do attachements list of addresse, etc.
And you can make a simple application wehe people cn modify or edit the email before sending

If your purpiose is to send email JavaMai is every convenient.
No doubt you can launch outlook from Java but this will be much bigger overhead and less flexible in many senses
Avatar of mybluegrass
mybluegrass

ASKER

I have already used javamail to send email inside my servlet. But I also need to launch outlook so users can use their outlook address book, signature, etc. Thanks!
Well, then you can use Runtime.getRuntime().exec... to start it, but do you want it to come
up with some particular screen say sending email?

You can start it wioth switches as specified on this page (click on switch reference)
http://office.microsoft.com/en-us/outlook-help/command-line-switches-HP001003110.aspx
There are lots of options there
Will Runtime.getRuntime().exec allow me to pre-populate some fields and attach files sent from server? The mailto function can pre-populate some fields but just not attachments. I'm afraid it's a security issue and not even possible. Thanks!
Check these switches - maybe you are right - maybe no attachements there, but a lot of
options.
The other thing to consider, that most of the users may alreday have Outlook opened,
so there may be some issues with that.
In general, if possible, I'd rather avoid such situation.
If you knoe already a lot about their message, then use JavaMail,
otherwise, maybe you would just offer them to send themselves through outlook.

This intermediate suituation is possible, but when you start getting into details
 may have some clashes and inconveniences and some differences on dofferent desktops, etc.
That's at least my opinion.


In general Runtime.getRuntime().exec  should of course accept switches, etc. everything what command line accepts
Avatar of Mick Barry
> Is it possible to launch outlook with some fields pre-populated (from, to, subject) and attachments attached to the email inside a java application?

afaik its not possible
I see that the switches allow me to attach a file, but I didn't see a switch to allow me to include to, cc or subject field. Thanks!
Never mind. Found the solution here:
http://stackoverflow.com/questions/248569/starting-outlook-and-having-an-email-pre-populated-from-command-line

Just have to add
/m name@email.com&cc=name2@email.com&subject=test%20subject
Great!
Is there a way to attach multiple attachments using switch /a?

Thanks!
I don't know but you can try with different syntax

/a oneFile /a twoFile

or maybe

/a oneFile,twoFile

just try
I've tried different variations including what you've suggested. But none works. I'm wondering that it's possible or not. Thanks!
It seems that it's not possible to attache multiple attachments using the switch:

http://www.pcreview.co.uk/forums/do-launch-outlook-multi-attachments-using-command-line-t2343640.html

Has anyone done this before? If not, what will be the alternative?

Thanks!
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial