Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Write contents of dataset into email

Write contents of dataset into email

Scheduled Pinned Locked Moved C#
csharpdatabasehelpquestion
9 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Tash18
    wrote on last edited by
    #1

    Hi guys.. I have a console application developed on c# VS2003 which sends email based on the query check now when the query returns multiple rows i store them in a dataset can anyone kindly tell me how do i extract the contents from the dataset and paste it on the content of my email. Any help is highly appreciated.. Thanx inadvance, Tash

    H L P 3 Replies Last reply
    0
    • T Tash18

      Hi guys.. I have a console application developed on c# VS2003 which sends email based on the query check now when the query returns multiple rows i store them in a dataset can anyone kindly tell me how do i extract the contents from the dataset and paste it on the content of my email. Any help is highly appreciated.. Thanx inadvance, Tash

      H Offline
      H Offline
      Hum Dum
      wrote on last edited by
      #2

      Plain logic : Iterate over datset/datatable rows. Get data from each row format/align as your need. And append this in email body. Like

      StringBuilder sb = new StringBuilder();
      foreach (DataRow item in ds.Tables["TableName"].Rows)
      {
      sb.Append(item["columnName"].ToString());
      }

      //format this sb acc. to your need
      //put this sb in your email body

      T 2 Replies Last reply
      0
      • H Hum Dum

        Plain logic : Iterate over datset/datatable rows. Get data from each row format/align as your need. And append this in email body. Like

        StringBuilder sb = new StringBuilder();
        foreach (DataRow item in ds.Tables["TableName"].Rows)
        {
        sb.Append(item["columnName"].ToString());
        }

        //format this sb acc. to your need
        //put this sb in your email body

        T Offline
        T Offline
        Tash18
        wrote on last edited by
        #3

        Thanx for the reply, Have you got any sample codes to share??? regards, Tash

        H 1 Reply Last reply
        0
        • T Tash18

          Thanx for the reply, Have you got any sample codes to share??? regards, Tash

          H Offline
          H Offline
          Hum Dum
          wrote on last edited by
          #4

          I know this going to come !! :-\ Check my previous reply, i edited it.

          T 1 Reply Last reply
          0
          • H Hum Dum

            I know this going to come !! :-\ Check my previous reply, i edited it.

            T Offline
            T Offline
            Tash18
            wrote on last edited by
            #5

            Thanx a lot dude... now have to work on it.. Thanx alot..

            1 Reply Last reply
            0
            • H Hum Dum

              Plain logic : Iterate over datset/datatable rows. Get data from each row format/align as your need. And append this in email body. Like

              StringBuilder sb = new StringBuilder();
              foreach (DataRow item in ds.Tables["TableName"].Rows)
              {
              sb.Append(item["columnName"].ToString());
              }

              //format this sb acc. to your need
              //put this sb in your email body

              T Offline
              T Offline
              Tash18
              wrote on last edited by
              #6

              is it possible to display as the table as such with the column names and all..??

              H 1 Reply Last reply
              0
              • T Tash18

                is it possible to display as the table as such with the column names and all..??

                H Offline
                H Offline
                Hum Dum
                wrote on last edited by
                #7

                <> wrote:

                is it possible to display as the table

                If by this you mean show in a tabular format like

                Col1 Col2
                1 A
                2 B

                As i said you have to format the o/p as you want to show.

                foreach (DataColumn dc in ds.Tables["TableName"].Columns)
                {
                sb.Append(dc.ColumnName);
                sb.Append(" ");
                }

                //Column end

                sb.Append(Environment.NewLine);

                //Row data
                foreach (DataRow item in ds.Tables["TableName"].Rows)
                {
                sb.Append(item["columnName1"].ToString().PadRight(20,' '));
                sb.Append(item["columnName2"].ToString().PadRight(20,' '));
                sb.Append(Environment.NewLine);
                }

                May be their better way then this !! :)

                1 Reply Last reply
                0
                • T Tash18

                  Hi guys.. I have a console application developed on c# VS2003 which sends email based on the query check now when the query returns multiple rows i store them in a dataset can anyone kindly tell me how do i extract the contents from the dataset and paste it on the content of my email. Any help is highly appreciated.. Thanx inadvance, Tash

                  L Offline
                  L Offline
                  Luc Pattyn
                  wrote on last edited by
                  #8

                  Most mail systems know how to handle HTML, so you could get a real table by adding some TABLE, TR, TD tags. :)

                  Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

                  Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

                  1 Reply Last reply
                  0
                  • T Tash18

                    Hi guys.. I have a console application developed on c# VS2003 which sends email based on the query check now when the query returns multiple rows i store them in a dataset can anyone kindly tell me how do i extract the contents from the dataset and paste it on the content of my email. Any help is highly appreciated.. Thanx inadvance, Tash

                    P Offline
                    P Offline
                    PIEBALDconsult
                    wrote on last edited by
                    #9

                    I usually write the data to an XML file and attach it. The receiver can then use XSLT to transform the data to HTML, CSV, etc.

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups