title: vb.NET SmtpClient not able to send email using email
body: <p>I'm trying to run this a block of code that exports the file I am working on to a PDF and emailing it to a 'client' using gmail. 
  I keep getting the message "Failure Sending Message", if you could help shed some light on this that would be appreciated.
  I also purposely "*****" my emails credentials for obvious reasons.</p>
  
  <pre><code> &lt;MiCode(ControlScriptEventType.AfterInkAdded, "Email")&gt; _ 
  Public Sub Ctl_Email_AfterInkAdded(ByVal e As AfterInkAddedEventArgs)
  MsgBox("1")
      Dim EmailTo As String = _EmailAddress.Value
  Dim EmailToName As String = "Client"
  Dim EmailFrom As String = "******"
  Dim EmailFromName As String = "WHSD" 
  
  
      Dim fileName As String = String.Empty
  Dim erl As New System.Collections.Generic.List(Of ExportResult)
  
  For Each er As ExportResult In _form.Validator.ExportResults
             erl.Add(er)
          fileName = System.IO.Path.GetFileNameWithoutExtension(er.ExpandedFilePath)
         Next
  
      Try
          Dim fromAddress As New MailAddress(EmailFrom, EmailFromName)
          Dim toAddress As New MailAddress(EmailTo, EmailToName)
          Using msg As New MailMessage(fromAddress, toAddress)
              msg.Body = "This will be the body of the message you are sending." &amp; VbCrLf &amp; "Thank you for your purchase."
              msg.Subject = (Me._form.Name &amp; " (" &amp; fileName &amp; ")")
  
              ' Add the mail body - an HTML file attached to this form.
              For Each attData As AttachmentData In _form.Attachments
                  If String.Compare(attData.Name, "Lead Generation.html") = 0 Then
                         msg.Body = System.Text.UTF8Encoding.UTF8.GetChars(attData.BinaryData())
                      msg.Body = msg.Body.Replace("[filename]", fileName)
                  End If
              Next
  
              ' Add pdf/csv file attachments to mail - they are datapaths of the form.
              For Each er As ExportResult In erl
                  If er.Success And ( er.DataPathName = "PDF" Or er.DataPathName = "CSV" ) Then
                      msg.Attachments.Add(New Attachment(er.ExpandedFilePath))
                  End If
              Next       
  
              Dim client As New SmtpClient("aspmx.l.google.com", 25)
              'client.EnableSsl = True
              'client.Timeout = 10000
              client.DeliveryMethod = SmtpDeliveryMethod.Network
              client.UseDefaultCredentials = False
              client.Credentials = New NetworkCredential("********", "******")
              client.Send(msg)
              Me.RecordExportResult("Email", True, "Sent email", "Sent email to " &amp; EmailToName &amp; "(" &amp; EmailTo &amp; ")", "")
              MsgBox("Sent!")
          End Using
      Catch ex As Exception
          Me.RecordExportResult("Email", False, ex.Message, ex.Message, ex.Message)
          MsgBox(ex.Message)
      End Try
  
  End Sub
  </code></pre>