• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 210
  • Last Modified:

Include javascript in email handler

I want to retrieve information using a javascript and then have that information display in the email when it's sent.  I can't seem to get my quotes correct b/c it keeps giving me errors.

My code:
Dim objConn As New OleDbConnection(ConfigurationSettings.AppSettings("Bible"))
      objCmd = New OleDbCommand("Select * From BibleAYear Where Date= #" & Date.Today & "# ORDER by Date ASC", objConn)
      objConn.open()
      objRdr = objCmd.ExecuteReader()
      While objRdr.Read()
      Dim strscripture As String = objRdr("scripture")
      End While
      objRdr.close()
      objConn.close()
      
      Dim biay As String = "<script type=""text/javascript"" src=""http://www.gnpcb.org/esv/share/js/?action=doPassageQuery&passage=strscripture""></script>"
      
      Dim objMail As New MailMessage()
      objMail.From = "bibleinayear@harvestchurchofgod.com"
      objMail.To = "bsmith@walkinginchrist.com"
      objMail.Subject = "Bible In A Year"
      objMail.BodyFormat = MailFormat.HTML
      objMail.Body = "<html><head><title>" & HttpUtility.HtmlEncode("Bible In A Year") & "</title></head><body>"
      objMail.Body &= "<p>" & biay & "</p>"
      objMail.Body &= "</body></html>"
      SmtpMail.SmtpServer = "mail.harvestchurchofgod.com"
      SmtpMail.Send(objMail)      
End Sub
0
azyet24
Asked:
azyet24
1 Solution
 
azyet24Author Commented:
Also, as you can see, I need to have the strscripture replaced with the scripture data from the db.  The way that I have this set up, should this work?

Thanks,
Bobby
0
 
CtrlAltDlCommented:
This:
     Dim biay As String = "<script type=""text/javascript"" src=""http://www.gnpcb.org/esv/share/js/?action=doPassageQuery&passage=strscripture""></script>"

Should be:
Dim biay As String = "<script type='text/javascript' src='http://www.gnpcb.org/esv/share/js/?action=doPassageQuery&passage=strscripture'></script>"
0
 
azyet24Author Commented:
It gives me this error:

Compiler Error Message: BC30648: String constants must end with a double quote.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
coolcyberCommented:
at what line do u get that error?

also place "Dim strscripture As String" outside the while loop
0
 
azyet24Author Commented:
Line 31.

Compiler Error Message: BC30648: String constants must end with a double quote.

Source Error:

Line 29:       objConn.close()
Line 30:       
Line 31:       Dim biay As String = "<script type='text/javascript' src='http://www.gnpcb.org/esv/share/js/?action=doPassageQuery&passage=strscripture'></script>"
Line 32:       
Line 33:       Dim objMail As New MailMessage()
 
0
 
coolcyberCommented:
try recompiling the solution. and see if u still get the error.

I ran it on VS2005 and it works fine
0
 
coolcyberCommented:
To send strscripture change "biay" to:
Dim biay As String ="<script type='text/javascript' src='http://www.gnpcb.org/esv/share/js/?action=doPassageQuery&passage=" & strscripture &"'></script>"
0
 
coolcyberCommented:
also make sure the whole statement is  in a single line
0
 
azyet24Author Commented:
I do not pre-compile nor do I use visual studio.  All the compiling occurs on the server.

I make the shanges to biay, but I'm still getting the double quote error.
0
 
coolcyberCommented:
what do u use to compile. what environment are u on?
0
 
azyet24Author Commented:
The hosted windows server is what compiles.  I don't compile on my local machine.
0
 
azyet24Author Commented:
I got it to work by doing this:

Dim biay As String = "<script type=text/javascript src=http://www.gnpcb.org/esv/share/js/?action=doPassageQuery&passage=" & strscripture
        biay += "></"
        biay += "script>"

However, when the email is sent, this is not rendered (the syndication does not take place).  Instead, in the source of the email it just has the src script with the strscripture rendered.  Do you know how to capture the syndication and then have it insert into the email?

If not, do you know how I can capture this syndication, loop it and insert it into an access db?  

Thanks,
Bobby
0
 
GranModCommented:
PAQed with points refunded (500)

GranMod
Community Support Moderator
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now