<div style="TEXT-ALIGN: left" dir=ltr id=result_box>I am using the following code for sending mail in asp.net</div> <div style="TEXT-ALIGN: left" dir=ltr> </div> <div style="TEXT-ALIGN: left" dir=ltr>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net.Mail;
using System.Net.Mime;
using System.Net;
namespace EnviaEmail
{
public partial class EnviaEmaillocaweb : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//Cria objeto com dados do e-mail.
MailMessage objEmail = new MailMessage();
//Define o remetente do e-mail.
objEmail.From = new MailAddress("List Profiles<meuemail@meudominio.com>");
//Define os destinatários do e-mail.
objEmail.To.Add("Luiz <meuemail@hotmail.com>");
//objEmail.To.Add("Nome <email@dominio.com.br>");
//Enviar cópia para.
// objEmail.To.Add("Nome <email@dominio.com.br>");
//Enviar cópia oculta para.
// objEmail.Bcc.Add("Nome <email@dominio.com.br>");
//Define a prioridade do e-mail.
objEmail.Priority = MailPriority.Normal;
//Define o formato do e-mail HTML (caso não queira HTML alocar valor false)
objEmail.IsBodyHtml = true;
//Define título do e-mail.
objEmail.Subject = "List of Profiles with Photo";
//Define o corpo do e-mail.
objEmail.Body = "Escreva aqui o seu <b>texto</b>";
//Para evitar problemas de caracteres "estranhos", configuramos o charset para "ISO-8859-1"
objEmail.SubjectEncoding = System.Text.Encoding.GetEncoding("ISO-8859-1");
objEmail.BodyEncoding = System.Text.Encoding.GetEncoding("ISO-8859-1");
//Cria objeto com os dados do SMTP
SmtpClient objSmtp = new SmtpClient();
//Alocamos o endereço do host para enviar os e-mails, localhost(recomendado) ou smtp2.locaweb.com.br
objSmtp.Host = "meusmtp.com.br";
//Enviamos o e-mail através do método .send()
try
{
objSmtp.Send(objEmail);
Response.Write("E-mail enviado com sucesso !");
}
catch (Exception ex)
{
Response.Write("Ocorreram problemas no envio do e-mail. Error = " + ex.Message);
}
//excluímos o objeto de e-mail da memória
objEmail.Dispose();
}
}
}
</div>
What I need is based on a MySql database or SQLServer, select certain records and submit them to the body of the email with some data as if it were mounted a gridview in body of email data would be enviado.Os
Profile picture - Name - City-UF
eg
What I need to know is how to hunt it in the body of the email which was a search of a database based on my code above Csharp in ASP.NET I am working with VS2008 and Framework 3.5 Pro Edition
What I need is based on a MySql database or SQLServer, select certain records and submit them to the body of the email with some data as if it were mounted a gridview in body of email data would be enviado.Os
Hi , i think you have to bind the data from you Database to you Body of your Email , so before send email , get the required data using the UserID and pass it to the Body of the Email..
<div style="TEXT-ALIGN: left" dir=ltr id=result_box>Ok but you have some example or article to show me how to mount this list of each profile with photo and link in the body of my email, based on a select command from a database sqlserver or mysql
Ok but you have some example or article to show me how to mount this list of each profile with photo and link in the body of my email, based on a select command from a database sqlserver or mysql
1. Create your message. System.Web.Mail.MailMessage. Populate the From, Subject and Body properties.
2. Query database, get multiple rows back (SQL - SELECT Email FROM Table)
3. Loop through data (DataReader best option). In each loop, append the value of the user data to the body property of the message, then send the message.
DataReader r = <ado.net code>
msg = new MailMessage;
msg.From = "";
msg.Subject = "";
msg.To ="ToAddress"
<div style="TEXT-ALIGN: left" dir=ltr id=result_box>I'm using system.net.mail to be using visual studio 2008, but you wanted to say that the body of the message I have to do the loop where each line as I put the data of each user profile and in the case as
it an example with such hyperlink field with the object image or photo of the User page and link to the details of the profile, type of mail profiles on sites for online dating
I would spend an example in the same order that you passed over me
<div dir=ltr id=result_box>Hello mudassarkhan and how I adapted this link you sent me as a reference using my code above with using System.Net Mail finally what I have to do to adapt it to my code
LuizIta
Member
21 Points
99 Posts
How to Send Mail in ASP.NET with GridView controls in body?
May 19, 2009 03:43 AM|LINK
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Net.Mail; using System.Net.Mime; using System.Net; namespace EnviaEmail { public partial class EnviaEmaillocaweb : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { //Cria objeto com dados do e-mail. MailMessage objEmail = new MailMessage(); //Define o remetente do e-mail. objEmail.From = new MailAddress("List Profiles<meuemail@meudominio.com>"); //Define os destinatários do e-mail. objEmail.To.Add("Luiz <meuemail@hotmail.com>"); //objEmail.To.Add("Nome <email@dominio.com.br>"); //Enviar cópia para. // objEmail.To.Add("Nome <email@dominio.com.br>"); //Enviar cópia oculta para. // objEmail.Bcc.Add("Nome <email@dominio.com.br>"); //Define a prioridade do e-mail. objEmail.Priority = MailPriority.Normal; //Define o formato do e-mail HTML (caso não queira HTML alocar valor false) objEmail.IsBodyHtml = true; //Define título do e-mail. objEmail.Subject = "List of Profiles with Photo"; //Define o corpo do e-mail. objEmail.Body = "Escreva aqui o seu <b>texto</b>"; //Para evitar problemas de caracteres "estranhos", configuramos o charset para "ISO-8859-1" objEmail.SubjectEncoding = System.Text.Encoding.GetEncoding("ISO-8859-1"); objEmail.BodyEncoding = System.Text.Encoding.GetEncoding("ISO-8859-1"); //Cria objeto com os dados do SMTP SmtpClient objSmtp = new SmtpClient(); //Alocamos o endereço do host para enviar os e-mails, localhost(recomendado) ou smtp2.locaweb.com.br objSmtp.Host = "meusmtp.com.br"; //Enviamos o e-mail através do método .send() try { objSmtp.Send(objEmail); Response.Write("E-mail enviado com sucesso !"); } catch (Exception ex) { Response.Write("Ocorreram problemas no envio do e-mail. Error = " + ex.Message); } //excluímos o objeto de e-mail da memória objEmail.Dispose(); } } }</div>What I need is based on a MySql database or SQLServer, select certain records and submit them to the body of the email with some data as if it were mounted a gridview in body of email data would be enviado.Os
Profile picture - Name - City-UF
eg
What I need to know is how to hunt it in the body of the email which was a search of a database based on my code above Csharp in ASP.NET I am working with VS2008 and Framework 3.5 Pro Edition
If someone can help me now thank you
venkatu2005
All-Star
32487 Points
6742 Posts
Re: Como Enviar E-mails em ASP.NET com Controles GridView no body ?
May 19, 2009 04:13 AM|LINK
Hi , i think you have to bind the data from you Database to you Body of your Email , so before send email , get the required data using the UserID and pass it to the Body of the Email..
Thanks.
LuizIta
Member
21 Points
99 Posts
Re: Como Enviar E-mails em ASP.NET com Controles GridView no body ?
May 19, 2009 04:59 PM|LINK
I look at now and I thank</div>
venkatu2005
All-Star
32487 Points
6742 Posts
Re: Como Enviar E-mails em ASP.NET com Controles GridView no body ?
May 20, 2009 04:13 AM|LINK
1. Create your message. System.Web.Mail.MailMessage. Populate the From, Subject and Body properties.
2. Query database, get multiple rows back (SQL - SELECT Email FROM Table)
3. Loop through data (DataReader best option). In each loop, append the value of the user data to the body property of the message, then send the message.
DataReader r = <ado.net code>
msg = new MailMessage;
msg.From = "";
msg.Subject = "";
msg.To ="ToAddress"
while(r.Read())
{
msg.Body = r["username"].ToString();
}
SmtpMail.Send(msg);
// close connection here.
Thanks.
LuizIta
Member
21 Points
99 Posts
Re: Como Enviar E-mails em ASP.NET com Controles GridView no body ?
May 20, 2009 06:38 AM|LINK
I would spend an example in the same order that you passed over me
I look at now and I thank</div>
venkatu2005
All-Star
32487 Points
6742 Posts
Re: Como Enviar E-mails em ASP.NET com Controles GridView no body ?
May 20, 2009 06:49 AM|LINK
hi suppos if you pass the link your email body , you have to use Anchor tag to make it as link
ex:
String sbody="Here is the link to login" + "<a href=' www.google.com' target='_blank'>" + Google + "</a>"
Thanks.
mudassarkhan
All-Star
78956 Points
13402 Posts
MVP
Re: Como Enviar E-mails em ASP.NET com Controles GridView no body ?
May 20, 2009 06:58 AM|LINK
I think you are looking to send the contents of Gridview in email
Then refer here
http://fredrik.nsquared2.com/viewpost.aspx?PostID=412
Contact me
LuizIta
Member
21 Points
99 Posts
Re: Como Enviar E-mails em ASP.NET com Controles GridView no body ?
May 20, 2009 05:15 PM|LINK
I look at now and I thank</div>