摘要:透過 ActiveXObject 執行 Client端的 Outlook 與 Excel
ActiveXObject 可參考 MSDN 的說明
IE安全性設定,可參考 網頁透過 JavaScript 呼叫Client端的 應用程式 下載多個檔案 的前半部說明
當執行了 ExecutOutlook 時的Outlook畫面:
當執行了 ExecutExcel 時的 Excel 畫面:
JavaScript Code:
function ExecutOutlook() { var txt = document.getElementById("txtArea").value; var outlookApp = new ActiveXObject("Outlook.Application"); var nameSpace = outlookApp.getNameSpace("MAPI"); mailFolder = nameSpace.getDefaultFolder(6); mailItem = mailFolder.Items.add('IPM.Note.FormA'); mailItem.Subject="CUSTOMER SERVICE"; mailItem.To = txt; mailItem.HTMLBody = "SOME HTML CODE"; mailItem.display (0); } function ExecutExcel() { // Declare the variables var Excel, Book; // Create the Excel application object. Excel = new ActiveXObject("Excel.Application"); // Make Excel visible. Excel.Visible = true; // Create a new work book. Book = Excel.Workbooks.Add() // Place some text in the first cell of the sheet. Book.ActiveSheet.Cells(1,1).Value = "This is column A, row 1"; // Save the sheet. Book.SaveAs("C:\\TEST.XLS"); // Close Excel with the Quit method on the Application object. //Excel.Application.Quit(); }