【问题标题】:Open outlook with javascript for sending mail with attachment in c#使用 javascript 打开 Outlook 以在 c# 中发送带有附件的邮件
【发布时间】:2022-05-06 06:07:25
【问题描述】:

我在 asp.net c# web 应用程序中使用 javascript 打开默认邮件客户端。 下面是我的代码..

<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>")
    }

}

这工作正常,但在我的情况下,我想从服务器端代码获取附件文件路径,因为我想将水晶报告作为附件发送。 我将如何从服务器端获取该路径??

【问题讨论】:

  • @DonalFellows 尽管它的标题,另一个问题是 ActiveX
  • 请详细说明“服务器端报告”....您的意思是 Crystal 报告 .rpt 文件或想附加从 Crystal 报告生成的报告(所需格式为 .doc / .xls / .pdf )?

标签: c# javascript email


【解决方案1】:

检查链接opening Outlook through javascript或/和This one 你可以试试这部分代码

function sendMail(){

location.href = "mailto:manish@simplygraphix.com?subject=Feedback for 
webdevelopersnotes.com&body=The Tips and Tricks section is 
great";




}

【讨论】:

    猜你喜欢
    • 2016-10-07
    • 2011-07-05
    • 2015-11-18
    • 2023-03-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多