Sending emails with attachment in asp.net MVC 4

Here I am sharing how you can send email with attachment using C# MVC 4.
Before you copy and paste the code you need to consider below few points:
1) Enable gmail account to allow Less Secure App.
2) You need to add below two lines to make below code work.

using System.Net;
using System.Net.Mail; 

3) Gmail requires you to use a secure connection for sending emails else it throws error like below:
The server response was: 5.7.0 Must issue a STARTTLS command first. i16sm1806350pag.18 – gsmtp
To fix/overcome this issue make sure you enable SSL in web.config file as below:

<network host="smtp.gmail.com" enableSsl="true" ... />

Or just add a param while sending email as shown in code.

public void email()
{
    MailMessage mail = new MailMessage();
    SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
    mail.From = new MailAddress("XXXXXXX@gmail.com");
    mail.To.Add("suresh.kamrushi@gmail.com");
    mail.Subject = "Test Email";
    mail.Body = "Sample Email with Attachment";
    //making attachment
    System.Net.Mail.Attachment attachment;
    attachment = new System.Net.Mail.Attachment("C:/Users/Administrator/Desktop/php.txt");
    mail.Attachments.Add(attachment);

    //Gmail Port
    SmtpServer.Port = 587;
    SmtpServer.Credentials = new System.Net.NetworkCredential("xxxxxxx@gmail.com", "xxxxxxxxx");

    //You can specifiy below line of code either in web.config file or as below.
    SmtpServer.EnableSsl = true;  
    SmtpServer.Send(mail);
}
  Comments or questions are welcome