Solved

Truncated text

Posted on 2006-11-28
4
279 Views
Last Modified: 2010-04-07
I have a prayer chain vb.net script that retrieves the request from my MS Access database and displays them in an email.  This has been working fine, but sometimes the full request is not displayed in the email.  I looks like it gets truncated around 40+ characters.  The script is simple and should not be causing this problem. The full text is in the database so that's not the problem.  

Code:

<script language="VB" runat="server">
                   
Sub Page_Load()
                   
     Dim objCmd As OleDbCommand
     Dim objRdr As OleDbDataReader
     Dim objCmd1 As OleDbCommand
     Dim objRdr1 As OleDbDataReader
       Dim sEmail As String
     Dim sName As String
     Dim sBody As String
     Dim strprayer As String
     Dim sPrayerID as String
       Dim sPName As String
     Dim sRequest As String
      
     Dim objConn1 As New OleDbConnection(ConfigurationSettings.AppSettings("DSN"))
            dim sql as new System.Text.StringBuilder
            sql.append("SELECT Prayer.* FROM Prayer ")
            '***verify that the requestor is a member
            sql.append("WHERE ((LCase((Prayer.member))='yes') ")
            '***get the critical requests
            sql.append("AND (LCase((Prayer.severity))='critical') ")
            '***get requests that have not been sent
            sql.append("AND ((Prayer.datesent Is Null)) ")
            '***send the requests sometime after 5:00 PM
            sql.append("AND ((DatePart(""h"", Now())>16))) ")
            
            '*** Do weekly mailing if it is Monday and after 5:00 PM
        If Date.Now.DayOfWeek = DayOfWeek.Monday and Date.Now.Hour > 16 Then
                  sql.append("UNION SELECT Prayer.* FROM Prayer ")
                  '***verify that the requestor is a member
                  'sql.append("WHERE ((LCase(Prayer.member))='yes') ")
                  '***verify the request was submitted in the last week
                  'sql.append("AND ((DateDiff(""d"",[Prayer].[datePosted],Now()))<=7) ")
                  '***verify the request has not been sent
                  sql.append("WHERE ([Prayer].[datesent] Is Null) ")
                  '***verify that the request was submitted before 5:00 PM
                  '***this will ensure that if a non-critical request is submitted after 5:00 PM another email will not go out
                  sql.append("AND (DatePart(""h"", Prayer.dateposted) < 17) ")
                  '***verify that the request as not sent within the last day
                  'sql.append("OR ((DateDiff(""d"",[Prayer].[datesent],Now()))>1))")
                  sql.append("ORDER BY dateposted DESC")
            else
                sql.append("ORDER BY dateposted DESC")
            end if

          objCmd1 = New OleDbCommand(sql.tostring, objConn1)
          objConn1.open()
          objRdr1 = objCmd1.ExecuteReader()

            if objRdr1.HasRows then

          While objRdr1.Read()
          sPrayerID = objRdr1("PrayerID")
          sPName = objRdr1("name")
          sRequest = objRdr1("prayerRequest")
              Dim sDate = objRdr1("dateposted")
         strprayer &= "<br />" & "<b>" & "Name: <span class='txtname'>" & sPName & "</span></b>" & _
                              "<dl><dt>" & "Request: " & "</dt><dd>" & sRequest & "</dd></dl>" & _
                             "<div align='center' class='style1'>" & "Date Posted: " & sDate & "</div><hr size=1>"
         '*** Update the Prayer.datesent
         dim objConn2 as New OleDbConnection(ConfigurationSettings.AppSettings("DSN"))
         dim objCmd2 as New OleDbCommand("UPDATE Prayer SET datesent=Now() WHERE PrayerID=" + sPrayerID , objConn2)
         objConn2.open()
         objCmd2.ExecuteNonQuery()
         objConn2.close()
         
       End while
          objRdr1.close()
          objConn1.close()            
      
     Dim objMail As New MailMessage
     dim strbody as string
     objMail.Subject="Harvest Prayer Chain"
     Dim objConn As New OleDbConnection(ConfigurationSettings.AppSettings("DSN"))
     objCmd = New OleDbCommand("Select fname, email From Members WHERE prayerChain = 'Yes'", objConn)
     objConn.open()
     objRdr = objCmd.ExecuteReader()    
     While objRdr.Read()
     strbody = ""
       sName = ""
       sEmail = objRdr("email")
     sName =objRdr("fname")
      objMail.To = sEmail
     objMail.From = """Prayer Chain"" <webmaster@domain.com>"
     objMail.BodyFormat = MailFormat.HTML
   strbody &= "<html><head><title>" & "</title><style type='text/css'>.style1 {font-family: Verdana, Arial, Helvetica, sans-serif;font-size: 12px;}.style2 {font-size: 10px}.style3 {text-transform:capitalize;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; font-weight: bold; color: #000000; }.standard { font-family: Arial, Helvetica, sans-serif; font-size:14px; color:#333333;}</style></head><body>"
     objMail.Body &= " "
     strbody &= "<table width='658' border='0' cellspacing='0' cellpadding='0'><tr><td colspan='2'><img src='http://www.domain.com/images/pc/art_01.jpg' width='658' height='108' /></td></tr>"
     strbody &= "<tr><td colspan='2'><img src='http://www.domain.com/images/pc/art_02.jpg' width='658' height='81' /></td></tr>"
     strbody &= "<tr><td width='265' ><img src='http://www.domain.com/images/pc/art_03_01_01.jpg' width='265' height='37' /></td>"
     strbody &= "<td width='393' valign='baseline' class='style3' style='background-image:url(http://www.domain.com/images/pc/art_03_01_02.jpg); background-repeat:no-repeat '>Dear " & sName & ",</td></tr>"
     strbody &= "<tr><td colspan='2'><img src='http://www.domain.com/images/pc/art_03_02.jpg' width='658' height='20' /></td></tr>"
     strbody &= "<tr><td colspan='2'><img src='http://www.domain.com/images/pc/art_04.jpg' width='658' height='185' /></td></tr>"
     strbody &= "<tr><td colspan='2'><table width='658' border='0' cellspacing='0' cellpadding='0'><tr><td width='48' style='background-image:url(http://www.domain.com/images/pc/body_01.jpg); background-repeat:repeat-y'></td>"
     strbody &= "<td style='background-image:url(http://www.domain.com/images/pc/body_02.jpg); background-repeat:repeat-y'>" & strprayer & "</td><td width='50' style='background-image:url(http://www.domain.com/images/pc/body_03.jpg); background-repeat:repeat-y'></td></tr></table></td></tr>"
     strbody &= "<tr><td colspan='2'><img src='http://www.domain.com/images/pc/art_06.jpg' width='658' height='121' /></td></tr>"
     strbody &= "<tr><td colspan='2'><img src='http://www.domain.com/images/pc/art_07.jpg' width='658' height='66' border='0' usemap='#Map' /></td></tr></table>"
     strbody &= "<map name='Map' id='Map'><area shape='rect' coords='373,3,419,15' href='http://www.domain.com/Sites/Content/home.aspx' /></map>"
     objMail.Body = strbody & "</body></html>"
    SmtpMail.SmtpServer = "MY IP Address"
     SmtpMail.Send(objMail)              
     
     
       End While
     objRdr.close()
     objConn.close()
       end if
End Sub

</script>
0
Comment
Question by:azyet24
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 9

Accepted Solution

by:
kraffay earned 250 total points
ID: 18030549
True using a StringBuilder instead of concatination.
0
 
LVL 4

Assisted Solution

by:Xeavn
Xeavn earned 250 total points
ID: 18069819
I agree with Kraffay, but since you haven't responded in a while, I thought I might try and provide an example of how to use a StringBuilder.

Dim sbOutput As New StringBuilder()
sbOutput.Append("<html><head><title>""&""</title><style type=""text/css"">.style1 {font-family: Verdana, Arial, Helvetica, sans-serif;font-size: 12px;}.style2 {font-size: 10px}.style3 {text-transform:capitalize;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; font-weight: bold; color: #000000; }.standard { font-family: Arial, Helvetica, sans-serif; font-size:14px; color:#333333;}</style></head><body>")
sbOutput.Append("<table width=""658"" border=""0"" cellspacing=""0"" cellpadding=""0""><tr><td colspan=""2""><img src=""http://www.domain.com/images/pc/art_01.jpg"" width=""658"" height=""108"" /></td></tr>")

...

objMail.Body = sbOutput.ToString()
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question