Friday, March 23, 2012

How to incorporate a table field into the email message body nto as an attachmen

Hello everyone,

Please i need your help...

I dont know how to place the field 'strTitle and datBorrowed " in my email? Not as an attachment though...Just write it in the mail as part of message body...

I use this SQL select statement to retrieve the strTitle and datBorrowed fields

strSQL += @."Select replace(strtitle,'[Original Book] - ',''), datBorrowed from tblBooks where convert(varchar(10),datBorrowed,101) = convert(varchar(10),(getdate() - 1),101) ORDER BY strTitle asc";

Now, I have the following code to write the email

static void SendTest()
{

int iEmailLanguage = 0;
MailMessage objMail;
objMail = new MailMessage();
objMail.From = MAIL_FROM;
objMail.To =MAIL_TO;
objMail.Subject = "Books Borrowed Yesterday";
objMail.Body = Dict.GetVal(iEmailLanguage, "EMAIL_MESSAGE");
objMail.Attachments.Add(new MailAttachment(strAttachment));
SmtpMail.SmtpServer = SSMTP_SERVER;
SmtpMail.Send(objMail);
}

And the body of the email is this.....

Dict.AddVal(0, "EMAIL_MESSAGE", "*** This e-mail is automatically generated. ***\n" +
"*** PLEASE DO NOT REPLY TO THIS E-MAIL. ***\n" +
"\n" +
"Books Borrowed Yesterday are:\n" +

"\n" +
"\n" +
"Thank you,\n" +
"\n" +
"eLibrarian\n" +
"\n" +
"================================================== ===============\n" +
"\n" +
"This e-mail is automatically generated by the Library system.\n" +
"Please do not reply.");

i need to put or wedge the data i got from the SQL Statement into this or after the line "Books Borrowed Yesterday are:\n" +

So how should i do this?you want to execute the strSQL. Obtain the result and append it to your body string before calling the Dict.add/GetVal().|||you want to execute the strSQL. Obtain the result and append it to your body string before calling the Dict.add/GetVal().

Im sorry sir...but I'm just a newbie in programming...How should i do it? Could you give me an example? :o|||Please take a look at the link below and download the sample codes:
http://msdn.microsoft.com/vcsharp/downloads/samples/default.aspx

They should help/guide you through your learning/development.sql

No comments:

Post a Comment