使用JavaScript打开Outlook在C#中使用附件发送邮件 [英] Open outlook with javascript for sending mail with attachment in c#
本文介绍了使用JavaScript打开Outlook在C#中使用附件发送邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用的JavaScript在asp.net C#的Web应用程序打开的默认邮件客户端。低于
是我的代码..
i am using javascript for open default mail client in asp.net c# web application. below is my code..
<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 = "anita.bharadva@compulynx.org"
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>")
}
}
这是工作正常,但在我的情况下,我想从服务器端代码的附件文件路径,因为我想送水晶报告附件。
我将如何从服务器端的路径??
this is working fine but in my case i want to get attachment file path from server side code because i want to send crystal report as attachment. how will i get that path from server side??
推荐答案
检查链接的opening展望或/和的这一次
你可以试试这部分代码
check the link opening Outlook through javascript OR/And This one You can try this part of code
function sendMail(){
location.href = "mailto:manish@simplygraphix.com?subject=Feedback for
webdevelopersnotes.com&body=The Tips and Tricks section is
great";
}
这篇关于使用JavaScript打开Outlook在C#中使用附件发送邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文