2
Answers

Sending an email not from gmail account

Mark Tabor

Mark Tabor

8y
325
1
I have purchased a domain with registration , so I have now mail account of my own company , i wrote a function to send an email below is the code for email sending 
protected void SendEmail(object sender, EventArgs e)
{
using (MailMessage mm = new MailMessage(txtEmail.Text, txtTo.Text))
{
mm.Subject = txtSubject.Text;
mm.Body = txtBody.Text;
if (fuAttachment.HasFile)
{
string FileName = Path.GetFileName(fuAttachment.PostedFile.FileName);
mm.Attachments.Add(new Attachment(fuAttachment.PostedFile.InputStream, FileName));
}
mm.IsBodyHtml = false;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.EnableSsl = true;
NetworkCredential NetworkCred = new NetworkCredential(txtEmail.Text, txtPassword.Text);
smtp.UseDefaultCredentials = true;
smtp.Credentials = NetworkCred;
smtp.Port = 587;
smtp.Send(mm);
ClientScript.RegisterStartupScript(GetType(), "alert", "alert('Email sent.');", true);
}
}
Now as my email is [email protected] as it is not a gmail account so instead of this line  smtp.Host = "smtp.gmail.com"; what should i write 

Answers (2)