I've searched as much as I can, for the previous two weeks between projects, and have yet to find a clear answer (I'm still new to C#, so what's clear to most does not apply.) Our website has a member login and then members can update various contact information for their company. We need an email notification to be sent each time an update is made. Below is the part of the code that sends new submitions and allows updates to current contact info. Like I said, all I need is an email notification to send out everytime the submit button is clicked and all of this code is put to work.
protected void btnSubmit_Click(object sender, EventArgs e)
{
OleHelper olHelper = new OleHelper();
if (hdl.Value == "Yes")
{
if (Session["MemberCode"] != null)
{
if (ViewState["New"] != null)
{
if (ViewState["New"].ToString() == "N")
{
string strInsert = "Insert Into MemberContacts (mMemCode,mCoName,mTypeOfContact,mFirstName,mLastName,mTitle,mAddress,mCity,mState,mZip,mPhone,mFax,mEmail,mUtilityTypes,mUpdatedBy) values ";
strInsert = strInsert + " ('" + Session["MemberCode"].ToString() + "','" + txtCompanyName.Text.Trim() + "','" + lblTypeContact.Text + "','" + txtFName.Text + "','" + txtLName.Text + "','" + txtTitle.Text + "','" + txtAddress.Text + "','" + txtCity.Text + "','" + txtState.Text + "','" + txtZip.Text + "','" + txtPhone.Text + "','" + txtFax.Text + "','" + txtEmail.Text + "','" + txtUtility.Text + "','" + txtFullName.Text + "')";
int result = olHelper.ExecuteNonQuery(null, CommandType.Text, strInsert);
if (result > 0)
{
lblSucc.Text = "Record Successfully Inserted.";
hdl.Value = "";
}
else
{
lblError.Text = "Failed,Try again";
}
}
}
else
{
string strUpdate = "Update MemberContacts set mCoName = '" + txtCompanyName.Text.Trim() + "', mTypeOfContact = '" + lblTypeContact.Text + "',mFirstName = '" + txtFName.Text + "',mLastName = '" + txtLName.Text + "',mTitle = '" + txtTitle.Text + "',mAddress = '" + txtAddress.Text + "',mCity='" + txtCity.Text + "',mState = '" + txtState.Text + "',mZip = '" + txtZip.Text + "',mPhone = '" + txtPhone.Text + "',mFax = '" + txtFax.Text + "',mEmail = '" + txtEmail.Text + "',mUtilityTypes ='" + txtUtility.Text + "',mUpdatedBy = '" + txtFullName.Text + "' where mMemCode = '" + Session["MemberCode"].ToString() + "' and mTypeOfContact = '" + lblTypeContact.Text + "'";
int result = olHelper.ExecuteNonQuery(null, CommandType.Text, strUpdate);
if (result > 0)
{
lblSucc.Text = "Record Successfully Updated.";
hdl.Value = "";
}
else
{
lblError.Text = "Failed,Try again";
}
}
}
}
else
{
lblSucc.Text = "No Changes are made";
}
}