Results 1 to 14 of 14

Thread: how send datatable's data by email

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2008
    Posts
    42

    how send datatable's data by email

    i want to email all the data from a datatable from another form.
    is there a way i can get all the data at once?
    and if I want to sortorder the date in the datagrid, what should I put in the query builder??

    Code:
     Private Sub emailbtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles emailbtn.Click
    
    
            Dim message As New EmailMessage
            message.Subject = "test email"
            message.BodyText = ' all data here<<<<
    
            Dim client As New Recipient("ABD", "[email protected]")
            message.To.Add(client)
            Dim emailsession As New OutlookSession
    
            emailsession.EmailAccounts("GoogleMail").Send(message)
    
            MsgBox("email sent")
        End Sub

  2. #2
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    Re: how send datatable's data by email

    I think you will have to read the datatable and put the contents in the body.

    To sort on a Sql retrieval use 'order by' - is that what you mean?
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

  3. #3

    Thread Starter
    Member
    Join Date
    Nov 2008
    Posts
    42

    Re: how send datatable's data by email

    Quote Originally Posted by petevick
    I think you will have to read the datatable and put the contents in the body.

    To sort on a Sql retrieval use 'order by' - is that what you mean?

    i mean (for example. search in a table would be : LIKE @lastname +'%')

    so what do I put on the " sort by " to achieve sort according to date?

  4. #4
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    Re: how send datatable's data by email

    order by mydatename
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

  5. #5

    Thread Starter
    Member
    Join Date
    Nov 2008
    Posts
    42

    Re: how send datatable's data by email

    SELECT [Recorded date], [Food Intake], Image
    FROM foodjournal
    ORDER BY [Recorded date] DESC

    this is what i put, but it doesnt seems to work.

  6. #6
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    Re: how send datatable's data by email

    Do you get a syntax error, is it not sorted - how does it not seem to work??

    Try the same syntax on the device in query analyzer
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

  7. #7

    Thread Starter
    Member
    Join Date
    Nov 2008
    Posts
    42

    Re: how send datatable's data by email

    Quote Originally Posted by petevick
    Do you get a syntax error, is it not sorted - how does it not seem to work??

    Try the same syntax on the device in query analyzer
    ok ...i done it...just a little bit of mistake...

    back to the read datatable question...
    i am trying to use sqldatareader to read them.

    so that means i need to establishing the connection right?
    and i wonder what is the data source equals to? my filepath for the .sdf file?

    is this the connection string correct?
    Code:
    myConnection = New SqlConnection("Data Source=" & "Initial Catalog=appdatabase1;" & _
        "Integrated Security=SSPI")

  8. #8
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    Re: how send datatable's data by email

    Surely you have filled the datatable from the database - do you now not just want to read the datatable?
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

  9. #9

    Thread Starter
    Member
    Join Date
    Nov 2008
    Posts
    42

    Re: how send datatable's data by email

    Quote Originally Posted by petevick
    Surely you have filled the datatable from the database - do you now not just want to read the datatable?
    yes, sure I filled the table. but what I mean by reading the data is not displaying them in the grid.

    as my initial question was to send those data out by email, so I need to read those data and put it in a string variable. then send it out by email right?

  10. #10
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    Re: how send datatable's data by email

    Why not just read from the database, construct a string, and email the string?
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

  11. #11

    Thread Starter
    Member
    Join Date
    Nov 2008
    Posts
    42

    Re: how send datatable's data by email

    Quote Originally Posted by petevick
    Why not just read from the database, construct a string, and email the string?
    isnt this just same as what i try to do??

  12. #12
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    Re: how send datatable's data by email

    So what is the datagrid all about then?
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

  13. #13

    Thread Starter
    Member
    Join Date
    Nov 2008
    Posts
    42

    Re: how send datatable's data by email

    Quote Originally Posted by petevick
    So what is the datagrid all about then?
    it is because I have this datagrid on form1 and I enter data there...

    then I wanted to read all that data from that grid and send it out on form2

  14. #14
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    Re: how send datatable's data by email

    So now I am totally confused - where does the datatable and SQL come into things.

    You can process the grid by reading each row and column in turn, and appending to a string.
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width