2014-11-24 58 views
0

这是我的情况。我们是一家制造工厂。当有人向维修部门提交有关机器问题的信息时,他们必须在2个部门之间进行选择。电子邮件有一个通用的收件人列表,但选项会发送给其他人。发送电子邮件时覆盖我的web.config

我有它,我可以更改或添加/删除在web.config中的普通电子邮件列表,但选择一个部门时,没有任何变化都会从可选部门的邮件列表中添加或删除的人的问题。我找不到它被覆盖的地方。

这是aspx.cs形式:

namespace ContactForm 
{ 
public partial class ContactForm : System.Web.UI.Page 
{ 
    public ContactForm() 
    { 
    } 




    protected void SubmitBtn_Click(object sender, EventArgs e) 
    { 
     if (Page.IsValid) 
     { 
      System.Configuration.Configuration config 
       = WebConfigurationManager.OpenWebConfiguration(base.Request.ApplicationPath); 
      AppSettingsSection appSettings = (AppSettingsSection)config.GetSection ("appSettings"); 

      string emailHost = appSettings.Settings["EmailHost"].Value; 
      string fromAddress = appSettings.Settings["FromEmailAddr"].Value; 
      string toAddress = appSettings.Settings["ToEmailAddr"].Value; 

      SmtpClient smtpClient = new SmtpClient(emailHost); 

      // Default in IIS will be localhost 
      //smtpClient.Host = "localhost"; 

      //Default port will be 25 
      smtpClient.Port = 25; 

      MailMessage message = new MailMessage(); 
      message.IsBodyHtml = false; 
      message.Priority = MailPriority.High; 
      message.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure; 

      try 
      { 
       message.Subject = "Maint Request: " + this.subjectBox.Text; 
       message.Body = "From: " + nameBox.Text.Trim() + "\n" + "\n"; 
       message.Body += "Created At: " + txtDate.Text + "\n" + "\n"; 
       message.Body += "Department: " + listDepartment.SelectedItem.Text + "\n" + "\n"; 
       message.Body += "Priority: " + listPriority.SelectedItem.Text + "\n" + "\n"; 
       message.Body += "Machine Area: " + txtMachineArea.Text + "\n" + "\n"; 
       message.Body += "Machine Number: " +txtMachineNumber.Text + "\n" + "\n"; 
       message.Body += "Problem description: " + txtQuestion1.Text; 
       toAddress += "[email protected]"; 
       if (listDepartment.SelectedItem.Text == "Option1") 
       { 
        toAddress += ", [email protected], [email protected]"; 
        //toAddress += ", [email protected]"; 
       } 
       else if (listDepartment.SelectedItem.Text == "Option2") 
       { 
        toAddress += ", [email protected]"; 
     //toAddress += ", [email protected]"; 

这是web.config文件

<?xml version="1.0" encoding="UTF-8"?> 
<configuration> 
<system.webServer> 
<defaultDocument> 
    <files> 
    <clear /> 
      <add value="index.aspx" /> 
    <add value="index.html" /> 
    <add value="Default.htm" /> 
    <add value="Default.asp" /> 
    <add value="index.htm" /> 
    <add value="iisstart.htm" /> 
    <add value="default.aspx" /> 
    </files> 
</defaultDocument> 
<staticContent> 
    <mimeMap fileExtension=".mp4" mimeType="video/mp4" /> 
    <mimeMap fileExtension=".ogv" mimeType="video/ogg" /> 
    <mimeMap fileExtension=".ogg" mimeType="application/ogg" /> 
    <mimeMap fileExtension=".webm" mimeType="video/webm" /> 
    <mimeMap fileExtension=".oga" mimeType="audio/oga" /> 
    <mimeMap fileExtension=".f4v" mimeType="video/mp4" /> 
</staticContent> 
</system.webServer> 
<appSettings> 
<add key="MyEmailAddr" value="[email protected]" /> 
<add key="ToEmailAddr" value="[email protected]" /> 
<add key="EmailHost" value="mail.webpage.com" /> 
<add key="FromEmailAddr" value="[email protected]" /> 
</appSettings> 
<system.net> 
<mailSettings> 
    <smtp from="[email protected]"> 
    <network host="mail.webpage.com" /> 
    </smtp> 
</mailSettings> 
<!-- 
    <mailSettings> 
     <smtp deliveryMethod='SpecifiedPickupDirectory'> 
      <specifiedPickupDirectory pickupDirectoryLocation="c:\maildrop" /> 
     </smtp> 
    </mailSettings>--> 
</system.net> 
<connectionStrings /> 
<system.web> 
<!-- 
     Set compilation debug="true" to insert debugging 
     symbols into the compiled page. Because this 
     affects performance, set this value to true only 
     during development. 
    --> 
<compilation debug="true" /> 
<!-- 
     The <authentication> section enables configuration 
     of the security authentication mode used by 
     ASP.NET to identify an incoming user. 
    --> 
<authentication mode="Windows" /> 
<!-- 
     The <customErrors> section enables configuration 
     of what to do if/when an unhandled error occurs 
     during the execution of a request. Specifically, 
     it enables developers to configure html error pages 
     to be displayed in place of a error stack trace.  --> 
    <customErrors mode="Off" /> 
</system.web> 
</configuration> 

如果你们能在这里找到任何东西,告诉我是怎么回事,什么正在压倒我所做的任何改变,这将是惊人的。我绝不是程序员,几个月前刚接手IT,似乎整件事都是用C#编写的,需要添加一些电子邮件到列表中

+0

重新部署它,因为你不是一个程序员,我要问的很明显,你需要重新编译代码隐藏(以下简称“aspx.cs文件”),你做后你的改变?我假设你正在改变行'toAddress + =“,[email protected],[email protected]”;'等是正确的? – user469104 2014-11-24 19:04:10

+0

你是对的。我尝试将电子邮件添加到列表选择下的toAddress行。我已经尝试了两种选择,但不管我做什么,它总是会转到原始cs上的同一个人。我甚至会从上面的CS删除它们,但它继续去他们母鸡执行测试 – Individual101 2014-11-24 19:09:47

+0

这是部署为ASP.NET“Web项目”或为ASP.NET“Web应用程序项目”?您正在修改的文件与编译的代码相关的位置在哪里?如果这是一个ASP.NET Web应用程序项目,那么在更改.cs文件后需要重新编译/重新部署该项目。在更改代码后你是否重新编译/重新部署? – user469104 2014-11-24 19:43:02

回答

0

我通过查找网页上的网页解决了这个问题虚拟主机服务器和卸载的页面,并与变化