title: Error Send Email : An invalid character was found in the mail header: ';'
body: <p>I am trying to create a sending email app and found some error. the email will be send to a certain recipient using checkbox inside gridview.
  the condition are:</p>
  
  <blockquote>
    <p>if email in coulmn 16 is not null then the email will be send directly. --> this is already work</p>
    
    <p>if email in column 16 is null then the email will be send to the recipient in column 17. --> it's throw an error in this part.</p>
  </blockquote>
  
  <p>here is my code for sending the mail:</p>
  
  <pre><code>Dim X As Integer
      For X = 0 To GridView1.Rows.Count - 1
          Dim chkBox As CheckBox = CType(GridView1.Rows(X).Cells(18).Controls(1), CheckBox)
          If chkBox.Checked = True Then
  Dim email2 As String
              If GridView1.Rows(X).Cells(16).Text &lt;&gt; "" Then
                  email2 = Trim(GridView1.Rows(X).Cells(16).Text)
              Else
                  email2 = Trim(GridView1.Rows(X).Cells(17).Text)
              End If
              Try
                  Dim EmailMessage As System.Net.Mail.MailMessage = New System.Net.Mail.MailMessage
                  EmailMessage.From = New MailAddress("mailaddress.bla.com")
                  EmailMessage.To.Add(email2)
                  EmailMessage.Subject = "Attire Request"
                  EmailMessage.IsBodyHtml = True
                  Dim link As String = "some link"
                  EmailMessage.Body = "Please login by Using this link &lt;a href=""" &amp; link &amp; """&gt;Click here &lt;/a&gt;"
  
                  Dim smtp As New SmtpClient(Server2)
                  Dim basicAuthenticationInfo As New System.Net.NetworkCredential(Username2, Password2)
                  smtp.Credentials = basicAuthenticationInfo
                  smtp.Send(EmailMessage)
  
              Catch ex As Exception
                  ' lblError.Text = lblError.Text &amp; ex.Message &amp; " " &amp; ex.InnerException.ToString
                  lblError.Text = ex.Message
                  lblError.Visible = True
              End Try
  </code></pre>
  
  <p>it's throws an error : An invalid character was found in the mail header: ';'.
  do you have any suggestion how to fix this.
  edited : code for looping</p>
  
  <p>Thanks in advances.</p>