An exception of type 'System.ArgumentNullException' occurred in System.dll but was not handled in user code
Additional information: Value cannot be null.
can't seem to find where the error is coming from, error appears on line 88
https://github.com/SubhanjanBasu/MailServices/blob/master/SIGNUP1.aspx.cs - this is the codes that i tried using
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
using System.Text;
using System.Net.Mail;
using System.Net;
public partial class UserCreate : System.Web.UI.Page
{
string CustLoginID, CustName, CustGender, CustDOB, CustEmail, CustTelNo, CustAddress, CustPassword;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btn_back_Click(object sender, EventArgs e)
{
Response.Redirect("UserCorL.aspx");
}
protected void btn_ok_Click(object sender, EventArgs e)
{
int result = 0;
Customer cust = new Customer(tb_CustLoginID.Text, tb_CustName.Text, rb_CustGender.SelectedItem.Text, tb_CustDOB.Text, tb_CustAddress.Text, tb_CustTelNo.Text, tb_CustEmail.Text, tb_CustPassword.Text);
result = cust.CustomerInsert();
sendMsg(CustLoginID, CustName, CustGender, CustDOB, CustEmail, CustTelNo, CustAddress, CustPassword);
Session["id"] = cust;
Response.Write("<script>alert('Email Sent');</script>");
}
public static void sendMsg(string CustLoginID, string CustName, string CustGender, string CustDOB, string CustAddress, string CustTelNo, string CustEmail, string CustPassword)
{
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.Credentials = new System.Net.NetworkCredential("projectwingsdrinks@gmail.com", "WingsDrinks");
smtp.EnableSsl = true;
MailMessage msg = new MailMessage();
msg.Subject = "Hello" + CustName;
msg.Body = "Hello" + CustName + "Thank You for Registering, Your Account Details are given below:";
msg.Body += "<tr>";
msg.Body += "<td>LoginID: " + CustLoginID + "</td>";
msg.Body += "</tr>";
msg.Body += "<tr>";
msg.Body += "<td>Password: " + CustPassword + "</td>";
msg.Body += "</tr>";
msg.Body += "<tr>";
msg.Body += "<td>DOB:" + CustDOB + "</td>";
msg.Body += "</tr>";
msg.Body += "<tr>";
msg.Body += "<td>Email: " + CustEmail + "</td>";
msg.Body += "</tr>";
msg.Body += "<tr>";
msg.Body += "<td>Gender: " + CustGender + "</td>";
msg.Body += "</tr>";
msg.Body += "<tr>";
msg.Body += "<td>Contact No.: " + CustTelNo + "</td>";
msg.Body += "</tr>";
msg.Body += "<tr>";
msg.Body += "<td>Address: " + CustAddress + "</td>";
msg.Body += "</tr>";
msg.Body += "<tr>";
msg.Body += "<td>Thank you</td>";
msg.Body += "</tr>";
msg.Body += "<td>From Team WingsDrinks </td>";
msg.Body += "<tr>";
string toAddress = CustEmail;
msg.To.Add(toAddress);
string fromAddress = "\"WingsDrinks\"<projectwingsdrinks@gmail.com>";
msg.From = new MailAddress(fromAddress);
msg.IsBodyHtml = true;
try
{
smtp.Send(msg);
}
catch
{
throw;
}
}
}