Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2005
    Posts
    3

    Unanswered: How to incorporate a table field into the email message body nto as an attachment?

    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?

  2. #2
    Join Date
    May 2002
    Posts
    299
    you want to execute the strSQL. Obtain the result and append it to your body string before calling the Dict.add/GetVal().
    --
    -oj
    http://www.rac4sql.net

  3. #3
    Join Date
    Oct 2005
    Posts
    3
    Quote Originally Posted by oj_n
    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?

  4. #4
    Join Date
    May 2002
    Posts
    299
    Please take a look at the link below and download the sample codes:
    http://msdn.microsoft.com/vcsharp/do...s/default.aspx

    They should help/guide you through your learning/development.
    --
    -oj
    http://www.rac4sql.net

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •