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
Anthony Clarke
NA
127
0
Add all to one message box and not individuals
Dec 13 2010 10:20 AM
Hi,
This code loops through a datagrid and anything where the datedifference is above 7 days it sends them an email. But i want to display a message with all the recipients it has been sent to in one message box and not have to have it pop up individually for every different person.
Example
{ at the end of the sendmail function, if i put messagebox.show("Recipients" + emailAdd) It will display a message box for every recipient.
Thanks
How would i go about doing this?
private
void
sendMail(
string
emailAdd,
string
emailBod,
string
emailSub)
{
Outlook.
Application
oApp =
new
Outlook.
Application
();
Outlook.
MailItem
email = (Outlook.
MailItem
)(oApp.CreateItem(Outlook.
OlItemType
.olMailItem));
email.Recipients.Add(emailAdd);
email.Subject = emailSub;
email.Body = emailBod ;
((Outlook.
_MailItem
)email).Send();
}
private
void
button1_Click(
object
sender,
EventArgs
e)
{
for
(
int
i = 0; i < dataGridView1.Rows.Count; i++)
{
if
(
Convert
.ToInt16(dataGridView1.Rows[i].Cells[7].Value) >= 7)
{
string
cusCode = (dataGridView1.Rows[i].Cells[1].Value.ToString());
string
letRef = (dataGridView1.Rows[i].Cells[0].Value.ToString());
string
name = (dataGridView1.Rows[i].Cells[2].Value.ToString());
string
emailAdd = (dataGridView1.Rows[i].Cells[5].Value.ToString());
string
emailBod = (
"Your Letter is "
+ dataGridView1.Rows[i].Cells[7].Value.ToString() +
" days old"
+
"\r"
+
"\r"
+
"CustomerCode: "
+
cusCode +
"\r"
+
"Letter Reference: "
+ letRef +
"\r"
+
"Full Name: "
+ name +
"\r"
+
"\r"
+
"Regards "
+ System.
Environment
.UserName);
string
emailSub = (
"Your Letter(s) are "
+ dataGridView1.Rows[i].Cells[7].Value.ToString()) +
" days old, Please see details below"
;
sendMail(emailAdd, emailBod, emailSub);
Reply
Answers (
3
)
Open Windows Form from Windows Service..
The name 'InitVariables' does not exist in the current context