Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 01-31-2006, 07:17 AM   #1 (permalink)
rikb53
Registered User
 
Join Date: Jan 2006
Posts: 29
rikb53 is on a distinguished road
Email a Dataset or DataTable

hey guys, i'm in need of some serious help here.
i've got a project with little time to research and barely enough time to code.
i know this may sound simple to you guys, and that's great.
all help is appreciate and i'm picking up lunch for this.
the .exe will run as a service and seach a database every 60 seconds for records based on a condtion.
if condition exists, fetch the records and send an email.

i need to retrieve these records from a database as a dataset or datatable and then put those records in the Body of an email.
i have to display them in table form + insert a logo as well. and im thinking i need to use something like.
oMailMsg.BodyFormat = MailFormat.Html
i've had no success embedding the .jpg in the email when i dont use MailFormat.Html.
my Problem is handling the data retrieved - since it will be a collection and needs to fit neatly in a table w/ borders format.
thanks for any help
rik
Can Anyone help or direct me to a solution that can do this?
rikb53 is offline   Reply With Quote
Old 01-31-2006, 07:37 AM   #2 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,710
redhead is on a distinguished road
If you're confident with reading code, the Dynamicaly table article, might give you some idear, on how to form the data retrieved, else, yes you will need the MailFormat.Html in order to have images included inside the mail, theres no way to show an image in a TXT formed mail.
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 01-31-2006, 01:18 PM   #3 (permalink)
rikb53
Registered User
 
Join Date: Jan 2006
Posts: 29
rikb53 is on a distinguished road
figured this out

Actually that was no help but i was able to figure this out using Stringbuilder
Append Property and Use Html code and a Datarow to loop thru my dataset.
see below thanks
rik

Dim sb As New StringBuilder
oMailMsg.BodyFormat = MailFormat.Html
Dim aRow As DataRow

sb.Append("<p><img SRC=C:\SelectLogo.gif></p><br>")--Image embeded

For Each aRow In ds.Tables(0).Rows
sb.Append("<table border=1><tr><td>" + aRow.Item(0) + "</td>" + "<td>" + aRow.Item(1) + "</td></tr></table>")
Next
oMailMsg.Body = sb.ToString
rikb53 is offline   Reply With Quote
Old 01-31-2006, 01:48 PM   #4 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,710
redhead is on a distinguished road
Well, your first post didn't tell anything on how the input data was formed, and how you wanted it displayed in your table, I just assumed you were having trouble building a dynamic table from your fetched data.

On another note, you could make it:
Code:
Dim sb As New StringBuilder
    oMailMsg.BodyFormat = MailFormat.Html
Dim aRow As DataRow

sb.Append("<p><img SRC=C:\SelectLogo.gif></p><br>") --Image embeded
sb.Append("<table border=1>")
For Each aRow In ds.Tables(0).Rows
    sb.Append("<tr><td>" + aRow.Item(0) + "</td>" + "<td>" + aRow.Item(1) + "</td></tr>")
Next
sb.Append("</table>")
oMailMsg.Body = sb.ToString
For a nicer output.
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 02-01-2006, 09:16 AM   #5 (permalink)
rikb53
Registered User
 
Join Date: Jan 2006
Posts: 29
rikb53 is on a distinguished road
i like that. thanks, im in a completely new area for me. would you happen to know how i could make the Index elements recursive? in other words, i'm guessing i would need a for loop and dependent on how many rows were returned, the indexes of the DataRow would just use the number passed from the for loop.
so, instead of aRow.Item(0) & aRow.Item(1) ---hardcoded for two elements only
i could have somethng like aRow.Item(i)

which of course would correspond to a For i = 0 to "someNumber"

thanks again
rik
rikb53 is offline   Reply With Quote
Old 02-01-2006, 11:30 AM   #6 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,710
redhead is on a distinguished road
Now I have no idear what specific language this is in, but from the small code examples you've shown here, I'm guessing VB, it's been a while since I've touched that, but something like:
Code:
...
Dim sb As New StringBuilder
Dim rows As Integer
Dim colums As Integer
Dim i As Integer
Dim j As Integer
...
oMailMsg.BodyFormat = MailFormat.Html
rows = ds.Tables.Rows.Count
columns = ds.Tables.Columns.Count
sb.Append("<p><img SRC=C:\SelectLogo.gif></p><br>")
sb.Append("<table border=1>")
For i = 0 To rows
    sb.Append("<tr>")
    For j = 0 To columns
        sb.Append("<td>" + ds.Tables(i).Item(j) + "</td>")
    Next j
    sb.Append("</tr>")
Next i
sb.Append("</table>")
might give you a hint on where I'm going with how you can access the items in a NxM table.
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 02-01-2006, 11:47 AM   #7 (permalink)
rikb53
Registered User
 
Join Date: Jan 2006
Posts: 29
rikb53 is on a distinguished road
yes it's vb.net - basically im declaring a datarow - assigning a dataset and iterating thru those rows. you can get to the elements of each row (aRow.Item(0)) and as long as you dont as for more elements than are in the dataset, you're okay.
if i'm doing a select for say: select myName,MyAddress from SomeTable.
and i assign that to a datset then to a datarow, as long as i dont ask for::
aRow.Item(2) - im okay - if i ask for that third item - "it out of the Index Range"
thanks again for your help on this
rik
rikb53 is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
send email from server awieds MS Technologies ( ASP, VB, C#, .NET ) 1 04-04-2005 10:25 PM
Craigslist Anonymous Email Relay with PHP & MySQL? oc_earthling PHP 11 03-05-2005 08:10 AM
Sending email with java sde Java 2 12-02-2004 04:33 PM
About email spammers and fraudsters plonkeroo Lounge 21 11-16-2004 03:10 PM
email code aimdevil Lounge 1 05-02-2004 11:36 PM


All times are GMT -8. The time now is 04:56 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting