簡體   English   中英

發送電子郵件時覆蓋我的web.config的某些內容

[英]Something over-riding my web.config when sending email

這是我的情況。 我們是制造工廠。 當有人向我們的維護部門提交有關機器問題的信息時,他們必須在兩個部門之間進行選擇。 電子郵件具有收件人的通用列表,但選項會發送給其他人。

我有一個問題,可以更改或添加或刪除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 += "allmaintenance@webpage.com";
                if (listDepartment.SelectedItem.Text == "Option1")
                {
                    toAddress += ", user1@webpage.com, user2@webpage.com";
                    //toAddress += ", test@webpage.com";
                }
                else if (listDepartment.SelectedItem.Text == "Option2")
                {
                    toAddress += ", user3@webpage.com";
        //toAddress += ", test@webpage.com";

這是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="noreply@webpage.com" />
 <add key="ToEmailAddr" value="Maintenanceusers@webpage.com" />
 <add key="EmailHost" value="mail.webpage.com" />
 <add key="FromEmailAddr" value="noreply@webpage.com" />
</appSettings>
<system.net>
<mailSettings>
  <smtp from="noreply@webpage.com">
    <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#編寫的,需要在列表中添加一些電子郵件

我通過在Web主機服務器上找到該網頁並卸載該頁面並通過更改將其重新部署來解決了此問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM