Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

la grecque
Posted

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

la grecque
  • Administrators
Posted

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?

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...