File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other JSE/JEE APIs and the fly likes Adding attachment to outlook express Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Adding attachment to outlook express" Watch "Adding attachment to outlook express" New topic
Author

Adding attachment to outlook express

bosu remalle
Greenhorn

Joined: Jan 05, 2006
Posts: 4
I need to invoke outlook express mailer from hyperlink or button or what ever after that i need to add To,CC,BCC,BODY and attachment part.
I tried with the following code using HTML like this

<a href='mailto:test@snai1mai1.com?subject=Test Subject message
&cc=test@yahoo.com
&bcc=testfriend@rediff.com
&body=Hi this is test body.
&Attachment="c:\test.txt"'>

i added above code in anchor tag of HTML. i am able to add all things except attachment part to the outlook express.
Is there anyway that we can achieve this?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42931
    
  68
Welcome to JavaRanch.

The parameter should read "attach", not "Attachment".
bosu remalle
Greenhorn

Joined: Jan 05, 2006
Posts: 4
I tried parameter with attach=""c:\test.txt" too. And also i tried all combinations of parameter like attachments,attachment,Attachment etc....
But i am not able to add attachment to the outlook express. I am using outlook express 6 version with win 2k.
Is there anyway that i can do with java apis...

Thanks in advance.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42931
    
  68
I had seen a post somewhere that seemed to indicate that "attach" would work, but apparently attachments are not covered by the mailto spec at all.

How could a Java API help with starting an email client from a link in a web page?
bosu remalle
Greenhorn

Joined: Jan 05, 2006
Posts: 4
My Intention is to invoke HttpServlet at server side. So servlet will use some java apis to handle these mail invocation process.
I thought i would run mailto commands from command line using Runtime.exec("cmd.exe /c start mailto:test@test.com?subject=sample....") some thing like this. But from command line mailto protocal not accepting more than one parameter. I mean in this URL mailto:?subject=test&cc=test@yahoo.com, outlook express not taking cc attribute in consideration. Its only taking first attribute after mailto: convention what ever it is.

So i am still searching for answer? I thought so many ways like using JNI or use some java-com+ bridges api's. but not through.

Pls let me know if anyone have any idea or suggestion?
Thanks in advance!!
Yari Podio
Greenhorn

Joined: Feb 02, 2006
Posts: 4
Originally posted by bosu remalle:
My Intention is to invoke HttpServlet at server side. So servlet will use some java apis to handle these mail invocation process.
I thought i would run mailto commands from command line using Runtime.exec("cmd.exe /c start mailto:test@test.com?subject=sample....") some thing like this. But from command line mailto protocal not accepting more than one parameter. I mean in this URL mailto:?subject=test&cc=test@yahoo.com, outlook express not taking cc attribute in consideration. Its only taking first attribute after mailto: convention what ever it is.

So i am still searching for answer? I thought so many ways like using JNI or use some java-com+ bridges api's. but not through.

Pls let me know if anyone have any idea or suggestion?
Thanks in advance!!


I've already been fighting with that, and I think that should work for you...

You should see your problem if you open a cmd in windows and try to execute:

start mailto:test@test.com?subject=sample&body=text

You will receive a message of "body" is not recognized as an intern or extern command, blah blah blah. I think it's because the "&" char means something when using command line (I don't know what though)

If you put that, it should work fine:

start mailto:"test@test.com?subject=sample&body=text"

So, from java you should put:

Runtime.exec("cmd.exe /c start mailto:\"test@test.com?subject=sample&body=text\"")

Hope this works for you (for me it does)

But, I have a problem with that. I want to open the outlook new message window with an attachment. From an HTML link I have no problems, if I put that:

<a href='mailto:test@test.com?subject=Test&attachment=""c:\test.txt""'>link text</a>

But if I put the same from command line, there's no way to get the attachment to work:

start mailto:"test@test.com?subject=Test&attachment=""c:\test.txt"""

I've tried doubled-double quotes, single quotes, slashed quotes, double slashed quotes, and all the stuff and still doesn't work... anybody (for the gods sake) know how should it work?

[ February 02, 2006: Message edited by: Yari Podio ]
[ February 02, 2006: Message edited by: Yari Podio ]
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18991
    
    8

Why should it work at all? Was there some document that said "&attachment=" should work, or was that just a guess? If there was a document, then re-reading it might help, I suppose.
Yari Podio
Greenhorn

Joined: Feb 02, 2006
Posts: 4
Originally posted by Paul Clapham:
Why should it work at all? Was there some document that said "&attachment=" should work, or was that just a guess? If there was a document, then re-reading it might help, I suppose.


In fact it WORKS from cmd when you don't use attachment, exactly as it works when you use a HTML link. Then, the question is, why attachment works from the HTML link but not from the cmd? The service "mailto:" is supposed to be the same.

I've been doing more tests, but it still doesn't work. If you put that:

start mailto:"test@test.com?subject=%22%22c:\test.txt%22%22"

...that's it, with the quotes url-encoded, it works fine (puts in the subject of the message the string ""c:\test.txt"" )

But when using it with the attachment, it doesn't work

start mailto:"test@test.com?attachment=%22%22c:\test.txt%22%22"

But when I've got crazy all the way was when executing that:

explorer mailto:"test@test.com?attachment=""""c:\test.txt"""""

It WORKS!!! (opening a explorer window in the middle, that's the shame). But puttin the same to the mailto: service:

start mailto:"test@test.com?attachment=""""c:\test.txt"""""

It DOESN'T work!!!

Also, I tried the HTML link with the attachment also from FireFox, and it works fine. I've thought to get the FireFox code and see what the they do to make it work... but guess what? Just NOW, the ftp server of mozilla.org is down

It's a global conspiration, that's for sure

[ February 02, 2006: Message edited by: Yari Podio ]
[ February 02, 2006: Message edited by: Yari Podio ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Adding attachment to outlook express