TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Mark Fenech
NA
82
68.9k
Sending Email C# Problem
May 3 2011 1:25 PM
Hi I am trying to access an email from a table from the Name of the member. Ex: got Mark on Listbox i select and press send i send an email to mark.
This is my Code:
public DataSet fetchEmail(ListBox list_getEmail)
{
string getEmail = list_getEmail.SelectedItem.ToString();
string query = "SELECT Email FROM tblMember WHERE Member_ID = '" + getEmail + "'";
ds = new DataSet("MemberDataSet");
da = new SqlDataAdapter(cmd);
SqlCommandBuilder sqb = new SqlCommandBuilder(da);
da.Fill(ds, "tblMember");
return ds;
}
Email :
public void sendMailOutStand()
{
MailMessage message = new MailMessage();
{
SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587);
smtp.EnableSsl = true;
smtp.Timeout = 10000;
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.UseDefaultCredentials = false;
smtp.Credentials = new System.Net.NetworkCredential("
[email protected]
", "mypassword");
message.From = new MailAddress("
[email protected]
", "Mark Fenech");
string uMail = db.fetchEmail(list_MarchFee).ToString();
message.To.Add(uMail); // getting exception as not getting good email format
message.Subject = "Test";
message.Body = "Test";
message.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
smtp.Send(message);
}
}
Thanks
Reply
Answers (
4
)
Task Parallel Library (TPL)
Opening and working with excel files using C#