email - send data grid view data in an e-mail using vb.net -


i'm trying send datagridview (or data in grid) e-mail receive blank e-mail when it's sent, got ideas how fix it? code im using this:

try         smtp.usedefaultcredentials = false         smtp.credentials = new net.networkcredential("[e-mail address im sending from]", "[password e-mail]")          smtp.port = 25         smtp.enablessl = true         mail = new mailmessage         mail.from = new mailaddress("[e-mail im sending from]")         mail.to.add(useremail.text)         mail.body = datatab.tostring         mail.subject = "biology quiz highscores"         smtp.deliverymethod = smtpdeliverymethod.network         smtp.send(mail)         msgbox("e-mail sent to: " & useremail.text & "")     catch ex exception         msgbox("unable send e-mail. please try again later.")     end try 

im getting data 2003 access database using mydataadpter sql statement, data table variable called datatab.

object.tostring(), unless overridden, identical calling object.gettype().tostring().

you want show data in data table. this:

private sub yoursubwhereyousendemail()     '...      try         using smtp = new smtpclient() {                                              .usedefaultcredentials = false,                                              .credentials = new net.networkcredential("[e-mail address im sending from]", "[password e-mail]"),                                              .port = 25,                                              .enablessl = true,                                              .deliverymethod = smtpdeliverymethod.network                                            }              smtp.send(new mailmessage("[e-mail im sending from]"), useremail.text, "biology quiz highscores", datatabletocsvstring(datatab)))         end using         msgbox("e-mail sent to: " & useremail.text & "")     catch ex exception         msgbox("unable send e-mail. please try again later.")     end try      '... end sub  private function datatabletocsvstring(table datatable) string     new text.stringbuilder         dim once = false          'headers         each col datacolumn in table.columns             if once = false                 once = true             else                 .append(",")             end if             .append(col.columnname)         next          .appendline()          'rows         each s in table.select.select(function(row) string.join(",", row.itemarray))             .appendline(s)         next          return .tostring     end end function 

Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -