Ayuda

18/04/2005 - 17:48 por Jorge Landaeta | Informe spam
Tengo un select el cual retorna varios registros, los cuales deseo que se
incluyan en el body del email. Cómo puedo incluír un while sin que aparezca
en el texto y que funcione claro está.

Dim objdruser As SqlDataReader
Dim sqluser As String = "select u.Firstn + ' ' + u.Lastn name, u.email from
users u"
Dim Cmduser As New SqlCommand(sqluser, connection)
connection.Open()
objdruser = Cmduser.ExecuteReader(System.Data.CommandBehavior.CloseConnection)

If objdruser.Read = True Then

Dim iMsg As New CDO.Message

With iMsg

.To = "" & objdruser("name") & " <" & objdruser("email") & ">"
.From = "" & username & " <xxx@xxx.com>"
.Subject = "Text"
.HTMLBody = "<p><font size=""3"" face=""Arial, Helvetica,
sans-serif"">Users:<BR><B>" & objdruser("name") & "</B>font></p>"
.Send()

End With

iMsg = Nothing

End If
 

Leer las respuestas

#1 Khaoz
18/04/2005 - 18:12 | Informe spam
Hola Jorge,

Haz las siguientes modificaciones: En el IF y antes del .TO

Dim objdruser As SqlDataReader
Dim sqluser As String = "select u.Firstn + ' ' + u.Lastn name, u.email from
users u"
Dim Cmduser As New SqlCommand(sqluser, connection)
connection.Open()
objdruser = Cmduser.ExecuteReader(System.Data.CommandBehavior.CloseConnection)

If objdruser.HasRows Then

Dim iMsg As New CDO.Message

With iMsg
Dim strTo As String = ""
Do While objdruser.Read()
If strTo = "" Then
strTo = objdruser("name") & " <" & objdruser("email") & ">"
Else
strTo = strTo & ", " & objdruser("name") & " <" & objdruser("email")
& ">"
End If
Loop
.To = strTo
.From = "" & username & " "
.Subject = "Text"
.HTMLBody = "<p><font size=""3"" face=""Arial, Helvetica,
sans-serif"">Users:<BR><B>" & objdruser("name") & "</B>font></p>"
.Send()

End With

iMsg = Nothing

End If


-

"Jorge Landaeta" wrote:

Tengo un select el cual retorna varios registros, los cuales deseo que se
incluyan en el body del email. Cómo puedo incluír un while sin que aparezca
en el texto y que funcione claro está.

Dim objdruser As SqlDataReader
Dim sqluser As String = "select u.Firstn + ' ' + u.Lastn name, u.email from
users u"
Dim Cmduser As New SqlCommand(sqluser, connection)
connection.Open()
objdruser = Cmduser.ExecuteReader(System.Data.CommandBehavior.CloseConnection)

If objdruser.Read = True Then

Dim iMsg As New CDO.Message

With iMsg

.To = "" & objdruser("name") & " <" & objdruser("email") & ">"
.From = "" & username & " "
.Subject = "Text"
.HTMLBody = "<p><font size=""3"" face=""Arial, Helvetica,
sans-serif"">Users:<BR><B>" & objdruser("name") & "</B>font></p>"
.Send()

End With

iMsg = Nothing

End If

Preguntas similares