Boas
Tenho aqui um site em ASP.net + C# + SQLServer Express2005
Será que alguem me sabe explicar como faço para enviar um email a todos os utilizadores que estão registados?
Moderadores: Administradores, Moderadores




fyngr Escreveu:como fizeste?
entao e fazer um for e percorrer todos os mails e enviar? ou fazendo o mesmo e por pa dentro duma string, dividido por ',' tambem deve dar

Dim myConnection As SqlConnection
Dim myCommand As SqlCommand
myConnection = New SqlConnection("Server=XXX;uid=XXX;pwd=XXX;database=XXX")
Dim mySelect As String = "SELECT XXX FROM XXX'"
myConnection.Open()
myCommand = New SqlCommand(mySelect, myConnection)
Dim myDR As SqlDataReader = myCommand.ExecuteReader()
Dim myStr As String = String.Empty
While myDR.Read()
myStr = myStr & ", "& myDR(0).ToString()
End while
myDR.Close()
myConnection.Close()

protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "RetPromo")
{
CheckBox caixa = (CheckBox)GridView1.Rows[int.Parse(e.CommandArgument.ToString())].FindControl("CheckBox1");
string a;
Label valor = (Label)GridView1.Rows[int.Parse(e.CommandArgument.ToString())].FindControl("Label1");
Label marca = (Label)GridView1.Rows[int.Parse(e.CommandArgument.ToString())].FindControl("Label4");
Label id = (Label)GridView1.Rows[int.Parse(e.CommandArgument.ToString())].FindControl("Label3");
Label nome = (Label)GridView1.Rows[int.Parse(e.CommandArgument.ToString())].FindControl("Label5");
a = marca.Text + " " + nome.Text + " - " + valor.Text + " €";
if (caixa.Checked == true)
{
SqlConnection ligacao2;
SqlCommand comando;
ligacao2 = new SqlConnection();
ligacao2.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["BDLojaConnectionString"].ConnectionString;
ligacao2.Open();
string myUpdate = "Update Produto SET Promo=True WHERE ID_Prod=" + id.Text;
comando = new SqlCommand(myUpdate, ligacao2);
ligacao2.Close();
Label3.Text = "Promoção retirada com sucesso";
}
else if (caixa.Checked == false)
{
SqlConnection ligacao2;
SqlCommand comando;
ligacao2 = new SqlConnection();
ligacao2.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["BDLojaConnectionString"].ConnectionString;
ligacao2.Open();
string myUpdate = "Update Produto SET Promo=True WHERE ID_Prod="+id.Text;
comando = new SqlCommand(myUpdate, ligacao2);
ligacao2.Close();
massmail(a);
Label3.Text = "Promoção inserida com sucesso";
}
}
}
Utilizador a ver este Fórum: Nenhum utilizador registado e 1 visitante