2012-09-03 66 views
2

我正在使用javascript打開asp.net c#web應用程序中的默認郵件客戶端。下面 是我的代碼..用javascript在c中用附件發送郵件打開outlook#

<script language="javascript"> 
function SendAttach() { 
    var theApp //Reference to Outlook.Application 
    var theMailItem //Outlook.mailItem 
    //Attach Files to the email 
    var attach3 = "c:\\mail\\test.txt" 
    //Construct the Email including To(address),subject,body 
    //var recipient 
    var subject = "Email Using JavaScript" 
    var msg = "This is a test mail,sent to you using javascript by kushan thakershy" 
    //Create a object of Outlook.Application 
    try { 
     var theApp = new ActiveXObject("Outlook.Application"); 
     var objNS = theApp.GetNameSpace('MAPI'); 
     var theMailItem = theApp.CreateItem(0) // value 0 = MailItem 
     //Bind the variables with the email 
     theMailItem.to = "[email protected]" 
     theMailItem.Subject = (subject); 
     theMailItem.Body = (msg); 
     theMailItem.Attachments.add(attach3); 
     theMailItem.display(); 

     //Show the mail before sending for review purpose 
     //You can directly use the theMailItem.send() function 
     //if you do not want to show the message. 

    } 
    catch (err) { 
     alert("The following may have cause this error: \n" + 
"1. The Outlook express 2003 is not installed on the machine.\n" + 
"2. The msoutl.olb is not availabe at the location " + 
"C:\\Program Files\\Microsoft Office\\OFFICE11\\msoutl.old on client's machine " + 
"due to bad installation of the office 2003." + 
"Re-Install office2003 with default settings.\n" + 
"3. The Initialize and Scripts ActiveX controls not marked as safe is not set to enable.") 
     document.write("<a href=\"" + "./testemail.asp" + "\"" + ">" + "Go Back" + "</a>") 
    } 

} 

這是工作正常,但在我的情況下,我想從服務器端代碼的附件文件路徑,因爲我想送水晶報表作爲附件。 我將如何從服務器端獲取該路徑?

+0

[通過JavaScript打開Outlook時]的可能重複(http://stackoverflow.com/questions/776672/opening- outlook-through-javascript) –

+0

@DonalFellows儘管它的標題,另一個問題是ActiveX – rds

+0

請詳細說明「ServerSide報告」....你的意思是水晶報告.rpt文件或想附加水晶報告生成的報告以所需的格式.doc/.xls/.pdf)? – MarmiK

回答