sannaz
25-11-2010, 19:34
سلام دوستان
من می خوام داخل پروژه ام ایمیل ها رو از پایگاه داده استخراج کنم و به اون ایمیل ها بوسیله کد mailaddress ایمیل بفرستم، ولی نمی دونم باید به جای ایمیل گیرنده چی بنویسم.لطفا منو راهنمایی کنید:23:
public static void CreateCopyMessage(string server)
{
System.Data.SqlClient.SqlConnection con_MSG = new SqlConnection();
con_MSG.ConnectionString = "Data Source=SANNA-PC\SA;Initial Catalog=SocialNetwork;User ID=sa;Password=1";
System.Data.SqlClient.SqlCommand cmd_MSG = new SqlCommand();
cmd_MSG.Connection = con_MSG;
cmd_MSG.CommandText = "select [Email] from Register where [Email]=@em";
con_MSG .Open ();
SqlDataReader r;
r =cmd_MSG .ExecuteReader ();
if (r.Read ()=true )
{
MailAddress from = new MailAddress("fatemeh_jebeli@yahoo.com", "123");
MailAddress to = new MailAddress("??????", "??????");
MailMessage message = new MailMessage(from, to);
// message.Subject = "Using the SmtpClient class.";
message.Subject = "confrim";
message.Body = @"salam";
// Add a carbon copy recipient.
// MailAddress copy = new MailAddress("Notification_List@contoso.com");
// message.CC.Add(copy);
SmtpClient client = new SmtpClient(server);
// Include credentials if the server requires them.
// client.Credentials = CredentialCache.DefaultNetworkCredentials;
Console.WriteLine("Sending an e-mail message to {0} by using the SMTP host {1}.", to.Address, client.Host);
client.Send(message);}
}
من می خوام داخل پروژه ام ایمیل ها رو از پایگاه داده استخراج کنم و به اون ایمیل ها بوسیله کد mailaddress ایمیل بفرستم، ولی نمی دونم باید به جای ایمیل گیرنده چی بنویسم.لطفا منو راهنمایی کنید:23:
public static void CreateCopyMessage(string server)
{
System.Data.SqlClient.SqlConnection con_MSG = new SqlConnection();
con_MSG.ConnectionString = "Data Source=SANNA-PC\SA;Initial Catalog=SocialNetwork;User ID=sa;Password=1";
System.Data.SqlClient.SqlCommand cmd_MSG = new SqlCommand();
cmd_MSG.Connection = con_MSG;
cmd_MSG.CommandText = "select [Email] from Register where [Email]=@em";
con_MSG .Open ();
SqlDataReader r;
r =cmd_MSG .ExecuteReader ();
if (r.Read ()=true )
{
MailAddress from = new MailAddress("fatemeh_jebeli@yahoo.com", "123");
MailAddress to = new MailAddress("??????", "??????");
MailMessage message = new MailMessage(from, to);
// message.Subject = "Using the SmtpClient class.";
message.Subject = "confrim";
message.Body = @"salam";
// Add a carbon copy recipient.
// MailAddress copy = new MailAddress("Notification_List@contoso.com");
// message.CC.Add(copy);
SmtpClient client = new SmtpClient(server);
// Include credentials if the server requires them.
// client.Credentials = CredentialCache.DefaultNetworkCredentials;
Console.WriteLine("Sending an e-mail message to {0} by using the SMTP host {1}.", to.Address, client.Host);
client.Send(message);}
}