fotini Posted September 17, 2003 Posted September 17, 2003 I know that with the following code in VB.NET you can send a mail Dim myMailServer As SmtpMail Dim myMessage As New MailMessage() myMessage.BodyFormat = MailFormat.Text myMessage.Priority = MailPriority.Normal myMessage.From = "xxx@apn-automation.com" myMessage.To = "yyy@yahoo.fr" 'To Address myMessage.Subject = msgSubject myMessage.Body = body myMessage.Attachments.Add(...) myMailServer.SmtpServer = "mySMTPserver" myMailServer.Send(myMessage) myMessage = Nothing What I want to do: retrieve data from a database (with a SELECT) and mail them. How? I can't attach them because there aren't in a file, I can't put it to message body because there are not a string. Please tell me the solution. (I want to mail a DataTable) P.S. I don't want to make them in a file Quote la grecque
Administrators PlausiblyDamp Posted September 17, 2003 Administrators Posted September 17, 2003 Does the data need to be in any particualr format? If not you could just set the documents body to DataTable.GetXML. Otherwise you will have to loop through the results and append them to the document yourself. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
fotini Posted September 17, 2003 Author Posted September 17, 2003 I have an object DataTable but there is not a method Get XML I tried to append tha data myself to the document with StringBuilder.append but the mail that I recieve is empty! sb= New StringBuilder Dim myReader As SqlDataReader = command.ExecuteReader() While myReader.Read() sb.append=myReader.GetValue(0) sb.append="vbCrLf" End While Quote la grecque
Administrators PlausiblyDamp Posted September 17, 2003 Administrators Posted September 17, 2003 Sorry - was thinking about datasets not datatables. Not sure why the e-mail is blank. What code are you using to add the string to the e-mail as the code to build the string looks fine. If you step through in a debugger are the contents being appended to sb? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
fotini Posted September 17, 2003 Author Posted September 17, 2003 1.myMessage.Body = sb.ToString 2.no, and I'm wondering why... sniff... Quote la grecque
Administrators PlausiblyDamp Posted September 17, 2003 Administrators Posted September 17, 2003 shouldn't it be sb.Append(myReader.GetValue(0)) is myReader.GetValue(0) returning anything? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
fotini Posted September 18, 2003 Author Posted September 18, 2003 I wrote this line of code and it returns nothing. sb.Append(myReader.GetValue(0)) Quote la grecque
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.