Hi,
im writing a little app that will run a stroed procedure on my sql database and whip the results (a list of email addresses) in to a new mail items "to" box.
I have my connection strings working and can extract the data fine.
I can create the new mail item fine.
What i cant do is the bit in the middle!! i need to take the results of the SP and populate them in to the "to" field of the mail item.
I have tried various things with no sucess..
This is my code:
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click_1(object sender, EventArgs e)
{
#region
SqlConnection conn = new SqlConnection("Data Source=LIVESERVER;Database=Live_DB;UID=admin;PWD=testing;");
SqlCommand command = new SqlCommand("SP_email_addresses", conn);
SqlDataAdapter adapter = new SqlDataAdapter(command);
DataSet ds = new DataSet();
adapter.Fill(ds, "emails");
this.dataGridView1.DataSource = ds;
this.dataGridView1.DataMember = "emails";
conn.Close();
conn.Dispose();
Outlook.Application outlookApp = new Outlook.Application();
Outlook.MailItem message =
(Outlook.MailItem)outlookApp.CreateItem(Outlook.OlItemType.olMailItem);
message.Subject = "System Message";
message.Recipients.Add();
message.Display(true);
#endregion
}
as you can see there is nothing in "to()" as yet - i can figure out how to take the result of the SP and get them in here..
any help would be great. thanks!