Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4042868
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T13:03:31+00:00 2026-05-20T13:03:31+00:00

I know this question has been asked but I don’t see anything that helps

  • 0

I know this question has been asked but I don’t see anything that helps me. What I have is a ticket application that records trouble tickets then sends an email to the right person. When I run this on my machine it works, but on my server I get a Null object reference error.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web.Security;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Oracle.DataAccess.Client;
using System.Text;
using System.Data.OleDb;
using System.Windows.Forms;
using System.IO;
using System.Diagnostics;
using System.Net.Mail;

namespace Ticketing {
    public partial class _Default : System.Web.UI.Page
    { 

        protected void Page_Load(object sender, EventArgs e)
        {
            "201157"; 
        }

        protected void btn_submit_Click(object sender, EventArgs e)
        {
            DateTime dtnow = DateTime.Now;
            OracleConnection conn = new OracleConnection(Global.oracle);
            conn.Open();
            StringBuilder sqls = new StringBuilder("Insert statment")

            OracleCommand cmd = new OracleCommand(sqls.ToString(), conn);
            cmd.CommandType = CommandType.Text;
            cmd.Parameters.Add(":REASON", txt_reason.Text);

            cmd.ExecuteNonQuery();
            cmd.Dispose();
            conn.Close();
            // end insert
            System.Threading.Thread.Sleep(2000);

            btn_refresh_Click(null, null);
            btn_email_Click(null, null);

            //send email
            MailMessage mail = new MailMessage();

            mail.From = new MailAddress("email@email.com");

            if (dd_urgency.SelectedValue.ToString() == "Critical")
            {
                mail.To.Add("email@email.com");
                mail.To.Add("email@email.com");
                mail.To.Add("email@email.com");

                mail.To.Add(lbl_email.Text);

            }
            else if (dd_urgency.SelectedValue.ToString() == "Urgent")
            {
                mail.To.Add("email@email.com");
                mail.To.Add("email@email.com");
                mail.To.Add("email@email.com");

                mail.To.Add(lbl_email.Text);
            }
            else if (dd_urgency.SelectedValue.ToString() == "Normal")
            {
                mail.To.Add("email@email.com");
                mail.To.Add(lbl_email.Text);
                if (dd_location.SelectedValue.ToString() == "XL")
                {
                    mail.To.Add("email@email.com");
                } 
            }
            else if (dd_urgency.SelectedValue.ToString() == "None")
            {
                mail.To.Add("email@email.com");
                mail.To.Add(lbl_email.Text);
                if (dd_location.SelectedValue.ToString() == "XL")
                {
                    mail.To.Add("email@email.com");
                }
            }

            mail.IsBodyHtml = true;

            mail.Subject = ("Ticket Id " + (label_id.Text) +" Urgency: " + dd_urgency.SelectedValue.ToString()) + "  At " + (dd_location.SelectedValue.ToString());

            mail.Body = txt_reason.Text;

            SmtpClient smtp = new SmtpClient("basic.smtp.ttu.edu");

            try
            {
                smtp.Send(mail);
            }
            catch (SmtpException ex)
            {
                Response.Write("<script>alert('There has been an error please call Travis Jorge at ')</script>");
            }

            //  this.Session.Abandon();


            Response.Write("<script>alert('You have submitted your trouble ticket we will be right with you. If you need immediate assistance contact Travis Jorge.')</script>");

            txt_reason.Text = "";
            // lbl_email.Text = "";
            label_id.Text = "";
            dd_location.SelectedIndex = 0;
            dd_urgency.SelectedIndex = 0; 
        }

        protected void btn_refresh_Click(object sender, EventArgs e)
        {
            OracleConnection conn1 = new OracleConnection(Global.oracle);
            conn1.Open();
            StringBuilder sqls1 = new StringBuilder(Select statement)

            OracleCommand cmd1 = new OracleCommand(sqls1.ToString(), conn1);
            cmd1.CommandType = CommandType.Text;

            OracleDataReader dr = cmd1.ExecuteReader();
            dr.Read();
            if (dr.HasRows)
            {
                if (!dr.IsDBNull(0))
                {
                    label_id.Text = dr.GetDecimal(0).ToString();
                }
            }
            cmd1.Dispose();
            conn1.Close();
        }

        protected void btn_email_Click(object sender, EventArgs e)
        {
            //Select email for return email

            OracleConnection conn2 = new OracleConnection(Global.oradb);
            conn2.Open();
            StringBuilder sqls2 = new StringBuilder(select statement)
            OracleCommand cmd2 = new OracleCommand(sqls2.ToString(), conn2);
            cmd2.CommandType = CommandType.Text;

            OracleDataReader dr2 = cmd2.ExecuteReader();
            dr2.Read();
            if (dr2.HasRows)
            {
               if (!dr2.IsDBNull(0))
                {
                    lbl_email.Text = dr2.GetString(0).ToString();
                }
            }
            cmd2.Dispose();
            conn2.Close();
        }
    } 
}

I can tell you that all the SQL statements work and this code runs fine on my server without the btn_email function and its associated commands. Any help would be appreciated. Also I know that all the values requested for the objects are available to the page.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T13:03:32+00:00Added an answer on May 20, 2026 at 1:03 pm

    Check if you have mailSettings in your web.config file.

    <system.net>
        <mailSettings>
            <smtp>
                <network
                    host="smtp.yourmailserver.com"
                    port="25" />
            </smtp>
        </mailSettings>
    </system.net>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that this question has been asked loads of times, but I have
I don't know if this question has been ask before. But I have a
I know this question has been asked here before, but I don't think those
I know that variations on this question have been asked, but I've tried all
I know this question has been asked several times for sure, but I have
I know that this question has a been asked many times, but I still
Hey guys, I don't know if this question has been asked yet but imagine
I know this is a question that has been asked before, but I think
I know this question has been asked before, but many answers don't give clear
I don't know if this question has been asked before, but I'll go through

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.