[英]Creating new Outlook mail item with javascript and vbscript
我有一個帶有字段的自定義HTML頁面和一個按鈕,用於填寫並生成新的Outlook郵件項目。 我需要使用HTML格式化正文,因此我正在使用VBScript創建新的郵件項目。
<script>
function generateEmail() {
var emailTo = $("#toField").val();
var emailCC = $("#CC").val();
var emailSubject = $("#subject").val();
var reason = $('#otherRadioBtn').is(':checked')?$("#otherFreeTextField").val():$(".reason:checked").val();
var emailBody = "<html><body><p><b>Issue:</b> " + $("#issue").val() + "<p><b>Customer Contact Information:</b> " + $("#contactInformation").val() + "<p><b>Requested Action:</b> " + $(".requestedAction:checked").val() + "<p><b>Reason:</b> " + reason + "<p><b>Workaround Available?</b> " + $(".workaround:checked").val() + "</body></html>";
sendEmail()
};
</script>
<script type="text/vbscript">
Sub sendEmail()
Set objOutlook = CreateObject("Outlook.Application")
Set objMail = objOutlook.CreateItem(0)
objMail.display
objMail.to = emailTo
objMail.cc = emailCC
objMail.subject = emailSubject
objMail.htmlbody = emailBody
End Sub
</script>
<input type="submit" value="Generate email" onclick="generateEmail()">
每當我點擊“生成電子郵件”按鈕時,都會收到錯誤“'sendEmail'未定義”。 我不知道為什么。 我必須做些什么才能使這項工作?
該代碼僅在安裝了Outlook的系統上的Internet Explorer中有效。
您需要更改Internet Explorer的設置才能起作用:
a)轉到Internet Explorer中的“ Tools
菜單。
b)轉到Options
。
c)單擊Custom Level
按鈕。
d)選擇選項“ Initialize and script ActiveX control not marked as safe for scripting
Prompt
或Enable
。
您可以在使用Outlook Automation 2007撰寫和通過JavaScript發送電子郵件中找到更多信息和示例代碼。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.