• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Upload file on server using applet

 
Sarfaraz Khan
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I need to create an applet for my asp.net web application.I have to make drag and drop functionality in applet.
I have created an applet where i make a functionality for email drag and drop from outlook and store that email on client machine. Its working fine but after creating a file i have to upload those file on my server.
I can not use servlet because my application is developed in asp.net mvc.


Can anyone help me how to upload file on server using applet and ASP.NET.

Below is my code for creating file on client machine


String libFile = System.getProperty("os.arch").equals("amd64") ? "jacob-1.18-M2-x64.dll" : "jacob-1.18-M2-x86.dll";
InputStream inputStream = new FileInputStream("C:\\OutlookConfig\\"+libFile);

File temporaryDll = File.createTempFile("jacob", ".dll");
FileOutputStream outputStream = new FileOutputStream(temporaryDll);
byte[] array = new byte[8192];
for (int i = inputStream.read(array); i != -1; i = inputStream.read(array)) {
outputStream.write(array, 0, i);
}
outputStream.close();

System.setProperty(LibraryLoader.JACOB_DLL_PATH, temporaryDll.getAbsolutePath());
LibraryLoader.loadJacobLibrary();

txtArea.append("Creating message files....");

ActiveXComponent xl = new ActiveXComponent("Outlook.Application");
Dispatch explorer = Dispatch.get(xl,"ActiveExplorer").toDispatch();
Dispatch selection = Dispatch.get(explorer, "Selection").toDispatch();
Variant count = Dispatch.get(selection, "Count");

// loop over selected mail items.
for (int mailIndex = 1; mailIndex <= count.getInt(); mailIndex++ ) {
Integer[] k = new Integer[]{new Integer(mailIndex)};
Dispatch mailItem = Dispatch.call(selection, "Item", k).toDispatch();
// Variant subject = Dispatch.get(mailItem, "Subject");
String fileid = UUID.randomUUID().toString();
String[] save = new String[]{"C:\\OutlookConfig\\"+fileid+".msg"};

Variant saved = Dispatch.call(mailItem, "SaveAs",save);



}


Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic