i am migrating an old php based application ( internal telefon book ) to the vaadin framework. It was possible to add telefon data via js-function to the contacts in MS Outlook.
I am connected to our internal net, via the domain user and Outlook works.
Trying this in Vaadin…until now no success.
Button outlookButton = new Button();
outlookButton.addListener(new Button.ClickListener()
{
public void buttonClick(ClickEvent event)
{
String script = "var Outlook = new ActiveXObject(\"Outlook.Application\");var myNamespace = Outlook.GetNamespace(\"MAPI\");var Kontakt = myFolder.Items.Add;var Suche = \"Test123\".indexOf(\" \");Kontakt.LastName = \"Test123\".substring(0,Suche);Kontakt.FirstName = \"Test123\".substring(0,Suche);Kontakt.Display();Kontakt.Save();Kontakt.Close(2);";
final TextArea textarea = new TextArea();
textarea.setValue(script);
textarea.setVisible(false);
mainWindow.addComponent(textarea);
mainWindow.executeJavaScript(textarea.getValue().toString());
}
});
it looks that there are also to do some settings in IE 8 ( before IE 7 was used ).
Inside the function with the test datas there are also mistakes with string separatings.
I will investigate further and update the post.
// Outlook-Export
Button outlookButton = new Button();
outlookButton.addListener(new Button.ClickListener()
{
public void buttonClick(ClickEvent event)
{
final TextArea script = new TextArea();
script.setVisible(false);
script.setValue(“var Outlook = new ActiveXObject("Outlook.Application");\n”
+ “Outlook.CreateObject("Outlook.Application");\n”
+ “var myNamespace = Outlook.GetNamespace("MAPI");\n”
+ “var myFolder = myNamespace.GetDefaultFolder(10);\n”
+ “var Kontakt = myFolder.Items.Add;\n”
+ “Kontakt.LastName = "Test456LastName";\n”
+ “Kontakt.FirstName = "Test456FirstName";\n”
+ “Kontakt.Display();\n”
+ “Kontakt.Save();\n”
+ “Kontakt.Close(2);\n”
+ “alert("Kontakt in Outlook übernommen")”);
mainWindow.addComponent(script);
mainWindow.executeJavaScript(script.getValue().toString());
}
});
Make sure, when running the applicatian that you are in your Intranet !
You have to be connected to your Outlook via your domain user.
The settings in IE 8 have to allow the running of ActiveXObjects.
Separate the first and family name and other informations out of your data container and replace the fixed values.
good Question .
Thinking about a clearly layout (for separating all the data’s like e-mail, office telephone number, mobile number etc.out of the persistence layer and concatenate it for the javascript engine) i prefer this coding.
The values for the javascript/Outlook var’s will be replaced with java strings.
Have you any doubt about performance or something else ? Until now, everything works well.
I attached a screen shot with the button functionality.