protected void LinkButton1_Click(object sender, EventArgs e) {
string ContactID = txtContactID.Text;
string EmailMessage = txtEmailContent.Text;
string[] words = ContactID.Split(',');
foreach (string word in words)
{
DataTable dt = reference.SendMultipleEmail_Fetch(Convert.ToInt32(words)).Tables[0];
if (dt.Rows.Count > 0)
{
foreach (DataRow row in dt.Rows)
{
if (row["Email"].ToString() != "" && txtContactID.Text != "" && txtEmailContent.Text != "")
{
Process.Start("mailto:" + row["Email"].ToString() + "?subject=" + "I love you" + "&body=" + "Hi you");
lblInfo.Text = "Message successfully sent";
}
else
{
lblInfo.Text = "Email Content is required or contact not selected";
return;
}
}
}
}
I have a grid table which multiple email addresses can be checked and mailed as a group. am trying to add a link button that will open up outlook and populate with the email addresses checked on the grid and then send mail out
If you just want to open email client window for sending a message, you can use this:
However, if you just want to send email without any input from the user, best bet would be to send directly via SMTP server. You can use SmtpClient class for that: https://msdn.microsoft.com/en-us/library/system.net.mail.smtpclient%28v=vs.110%29.aspx