2012-01-18 35 views
0

只是想知道在傳統的ASP/VBScript中是否有可能啓動默認郵件客戶端的新窗口。VBScript啓動默認郵件窗口

我曾嘗試以下:

set objOutlk = createobject("Outlook.Application") 
set objMail = objOutlk.createitem(olMailItem) 

,但一無所獲,但一個錯誤:的ActiveX不能創建對象:Outlook.Application。

任何意見是非常感謝。

Rob。

+0

只是要確定:您正在嘗試在客戶機或ASP-Classic服務器端腳本上運行VBScript? – Filburt 2012-01-18 16:40:46

+0

對不起,這是asp服務器端。但如果有必要,這可以做到客戶端? – rmccallum 2012-01-18 16:42:21

+0

應該在客戶端機器上打開一個郵件窗口並預先填充一些數據,然後允許客戶端發送郵件,以便通過它們的交換來跟蹤它 – rmccallum 2012-01-18 16:43:03

回答

0

如果你想提供一個簡單的方法來打開用戶的默認郵件客戶端的消息看你(ASP)頁只需添加一個mailto:超鏈接:

<a href="mailto:[email protected]?subject=Hello%20World&body=Hi%20there">Send Msg</a> 

mailto:將觸發瀏覽器中打開默認(或配置)的郵件客戶端。

您可以附加定義主題行和郵件正文查詢字符串 - 在我的例子主題是的「Hello World」和正文是「你好」

公告空白是URL編碼%20

+0

Cheers Filburt。我也可以試試這個,但是我認爲下面的答案是我之後的答案,除非你能看到JS的任何錯誤? – rmccallum 2012-01-19 11:16:50

+0

如果您還需要收集用戶發送郵件的一些數據,那麼使用JS構建鏈接是一條可行的路線 - 基本上,您最終會得到與我的靜態示例類似的「href」值。 – Filburt 2012-01-19 11:57:33

0

稍加思索後(由於一些你們的提示),它使運行該客戶端的感覺,我用下面的JScript:

<script type="text/javascript"> 

function send() { 
alert("clicked") 
    var recpt = "[email protected]" 
    var subj = "FASTER BETTER SOONER: Look at Monash Rowville rail now" 
    var text = "<Enter your name and address here> %0D%0DMelbourne is growing and more people need transport. With concern about climate change and rising petrol prices, Melbourne's growth is not sustainable without more and better public transport.%0D%0DVictorians want more people catching public transport, cycling and walking; fewer trucks on our roads, more freight on rail; and fewer kilometres travelled by car and truck.%0D%0DPublic transport should: be fast, frequent, reliable, affordable and safe; grow as Melbourne grows; be available to all Melbournians; and be managed as an integrated, co-ordinated network.%0D%0DThis means bringing forward existing public transport projects, committing to new projects and accelerating programs to move freight off our roads and onto rail.%0D%0DIt also means looking very closely at the impact on greenhouse gas emissions of any new transport projects like tunnels and freeways.%0D%0DWe especially urge you to look at a feasibility study for a Monash Rowville rail line. %0D%0DAs Melbourne's population grows, better public transport will both reduce traffic congestion and provide a much needed antidote to spiralling petrol prices. " 
    var bcc = "[email protected]" 
    var content = new Array() 

    content[0] = "mailto:" 
    content[1] = recpt 
    content[2] = "?subject=" 
    content[3] = subj 
    content[4] = "&body=" 
    content[5] = text 
    content[6] = "&bcc=" 
    content[7] = bcc 
    content = content.join("") 
    window.location = content 
} 

這似乎是我希望的結果。

Rob