CDOSYS send email with ASP

Discussion in 'ASP General' started by paulmitchell507, Jul 31, 2008.

  1. I have a file called email2.asp which I am using to mail data obtained
    from a SQL query. I would like to pass the holiday_ID value in the
    querystring attached to the end of the URL. It all works except that
    I can't get the value of holiday_ID included as a querystring. As a
    test I can insert a value after the ?id= and this is passed as a
    querystring.

    I am sure it's just the syntax that I am having problem with


    <%
    Option Explicit
    <!--#include file="admin_navigation.asp" -->

    'Declare variables
    Dim sch, cdoConfig, cdoMessage, holiday_ID, email, auth
    holiday_ID = Request.Form("myname")
    sch = "http://schemas.microsoft.com/cdo/configuration/"

    Set cdoConfig = CreateObject("CDO.Configuration")

    With cdoConfig.Fields
    'Set CDO Port
    .Item(sch & "sendusing") = 2
    'Set mailserver name either IP address, mail.yoursite.com or
    localhost
    .Item(sch & "smtpserver") = "192.156.217.6"
    'Set SMTP port which is 25 by default
    .Item(sch & "smtpserverport") = 25
    'Set number of seconds before timeout
    .Item(sch & "smtpconnectiontimeout") = 60
    .update
    End With

    Set cdoMessage = CreateObject("CDO.Message")

    With cdoMessage
    Set .Configuration = cdoConfig
    .From = ""
    .To = ""
    .Subject = ""& email
    'Send the email in HTML format
    .HTMLBody = "<a href='http://192.156.217.134/authorise.asp?
    id=holiday_ID'>delete record</a><br><br>"
    .Send
    End With

    Set cdoMessage = Nothing
    Set cdoConfig = Nothing
    %>
     
    paulmitchell507, Jul 31, 2008
    #1
    1. Advertising

  2. paulmitchell507

    Evertjan. Guest

    paulmitchell507 wrote on 31 jul 2008 in
    microsoft.public.inetserver.asp.general:

    > I have a file called email2.asp which I am using to mail data obtained
    > from a SQL query. I would like to pass the holiday_ID value in the
    > querystring attached to the end of the URL. It all works except that
    > I can't get the value of holiday_ID included as a querystring. As a
    > test I can insert a value after the ?id= and this is passed as a
    > querystring.
    >
    > I am sure it's just the syntax that I am having problem with
    > .HTMLBody = "<a href='http://192.156.217.134/authorise.asp?
    > id=holiday_ID'>delete record</a><br><br>"


    In your example
    part of a string sould automagically change into the value of a variable?

    If you think that is possible, it would seem you have no idea what
    programming is about.

    Try:

    ..HTMLBody = "<a href='http://192.156.217.134/authorise.asp?id="&_
    holiday_ID & "'>delete record</a><br><br>"



    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., Jul 31, 2008
    #2
    1. Advertising

  3. On Jul 31, 2:50 pm, "Evertjan." <> wrote:
    > paulmitchell507 wrote on 31 jul 2008 in
    > microsoft.public.inetserver.asp.general:
    >
    > > I have a file called email2.asp which I am using to mail data obtained
    > > from a SQL query.  I would like to pass the holiday_ID value in the
    > > querystring attached to the end of the URL.  It all works except that
    > > I can't get the value of holiday_ID included as a querystring.  As a
    > > test I can insert a value after the ?id= and this is passed as a
    > > querystring.

    >
    > > I am sure it's just the syntax that I am having problem with
    > >         .HTMLBody = "<a href='http://192.156.217.134/authorise.asp?
    > > id=holiday_ID'>delete record</a><br><br>"

    >
    > In your example
    > part of a string sould automagically change into the value of a variable?
    >
    > If you think that is possible, it would seem you have no idea what
    > programming is about.
    >
    > Try:
    >
    > .HTMLBody = "<a href='http://192.156.217.134/authorise.asp?id="&_
    >  holiday_ID & "'>delete record</a><br><br>"
    >
    > --
    > Evertjan.
    > The Netherlands.
    > (Please change the x'es to dots in my emailaddress)


    You are correct, I know very little about programming, hence why I
    have posted the question. Maybe I have not explained myself very
    well. If insert the following code
    HTMLBody = "<a href='http://192.156.217.134/authorise.asp'>delete
    record</a><br><br>"
    The user will receive a hyperlink called 'delete record' which will
    take them to my authorise.asp page.
    All I want to do is add my variable, holiday_ID to the string, a bit
    like response.write "my holiday id is" & holiday_ID
    So when the user activates the link, the user gets directed to the asp
    page with the holiday_ID as a querystring. I can then use the
    holiday_ID value in the authorise.asp page.
     
    paulmitchell507, Jul 31, 2008
    #3
  4. paulmitchell507

    Evertjan. Guest

    paulmitchell507 wrote on 31 jul 2008 in
    microsoft.public.inetserver.asp.general:

    >> Try:
    >>
    >> .HTMLBody = "<a href='http://192.156.217.134/authorise.asp?id="&_
    >> ÿholiday_ID & "'>delete record</a><br><br>"
    >>


    [please do not quite signatures on usenet]

    >
    > You are correct, I know very little about programming, hence why I
    > have posted the question. Maybe I have not explained myself very
    > well. If insert the following code
    > HTMLBody = "<a href='http://192.156.217.134/authorise.asp'>delete
    > record</a><br><br>"
    > The user will receive a hyperlink called 'delete record' which will
    > take them to my authorise.asp page.
    > All I want to do is add my variable, holiday_ID to the string, a bit
    > like response.write "my holiday id is" & holiday_ID
    > So when the user activates the link, the user gets directed to the asp
    > page with the holiday_ID as a querystring. I can then use the
    > holiday_ID value in the authorise.asp page.


    .... and my example above does not do that?



    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., Jul 31, 2008
    #4
  5. On Jul 31, 4:26 pm, "Evertjan." <> wrote:
    > paulmitchell507 wrote on 31 jul 2008 in
    > microsoft.public.inetserver.asp.general:
    >
    > >> Try:

    >
    > >> .HTMLBody = "<a href='http://192.156.217.134/authorise.asp?id="&_
    > >> ÿholiday_ID & "'>delete record</a><br><br>"

    >
    > [please do not quite signatures on usenet]
    >
    >
    >
    > > You are correct, I know very little about programming, hence why I
    > > have posted the question.  Maybe I have not explained myself very
    > > well.  If insert the following code
    > > HTMLBody = "<a href='http://192.156.217.134/authorise.asp'>delete
    > > record</a><br><br>"
    > > The user will receive a hyperlink called 'delete record' which will
    > > take them to my authorise.asp page.
    > > All I want to do is add my variable, holiday_ID to the string, a bit
    > > like response.write "my holiday id is" & holiday_ID
    > > So when the user activates the link, the user gets directed to the asp
    > > page with the holiday_ID as a querystring.  I can then use the
    > > holiday_ID value in the authorise.asp page.

    >
    > ... and my example above does not do that?
    >
    > --
    > Evertjan.
    > The Netherlands.
    > (Please change the x'es to dots in my emailaddress)


    Dear Evertjan
    Sorry, I did not see your example code in the previous post. Thank
    you very much for taking the time to help me, the following code works

    .HTMLBody = "<a href='http://192.x.x.x/authorise.asp?id="& email
    &"'>delete record</a><br><br>"

    Paul
    PS Maybe you could assist me in the future...I am sure I am going to
    need it!
     
    paulmitchell507, Aug 1, 2008
    #5
  6. paulmitchell507

    Evertjan. Guest

    paulmitchell507 wrote on 01 aug 2008 in
    microsoft.public.inetserver.asp.general:

    > On Jul 31, 4:26 pm, "Evertjan." <> wrote:
    >> paulmitchell507 wrote on 31 jul 2008 in
    >> microsoft.public.inetserver.asp.general:
    >>
    >> >> Try:

    >>
    >> >> .HTMLBody = "<a href='http://192.156.217.134/authorise.asp?id="&

    > _
    >> >> ÿholiday_ID & "'>delete record</a><br><br>"

    >>
    >> [please do not quite signatures on usenet]
    >>
    >>
    >>
    >> > You are correct, I know very little about programming, hence why I
    >> > have posted the question.  Maybe I have not explained myself very
    >> > well.  If insert the following code
    >> > HTMLBody = "<a href='http://192.156.217.134/authorise.asp'>delete
    >> > record</a><br><br>"
    >> > The user will receive a hyperlink called 'delete record' which will
    >> > take them to my authorise.asp page.
    >> > All I want to do is add my variable, holiday_ID to the string, a
    >> > bit like response.write "my holiday id is" & holiday_ID
    >> > So when the user activates the link, the user gets directed to the
    >> > asp page with the holiday_ID as a querystring.  I can then use the
    >> > holiday_ID value in the authorise.asp page.

    >>
    >> ... and my example above does not do that?
    >>
    >> --
    >> Evertjan.
    >> The Netherlands.
    >> (Please change the x'es to dots in my emailaddress)

    >
    > Dear Evertjan
    > Sorry, I did not see your example code in the previous post. Thank
    > you very much for taking the time to help me, the following code works
    >
    > .HTMLBody = "<a href='http://192.x.x.x/authorise.asp?id="& email
    > &"'>delete record</a><br><br>"
    >
    > Paul
    > PS Maybe you could assist me in the future...I am sure I am going to
    > need it!
    >


    Only if you read the responses completely, as I nearly wrote:
    "[please do not quote signatures on usenet]"
    and you did not follow that Netiquette advice.

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., Aug 1, 2008
    #6
  7. On Aug 1, 2:03 pm, "Evertjan." <> wrote:
    > paulmitchell507 wrote on 01 aug 2008 in
    > microsoft.public.inetserver.asp.general:
    >
    >
    >
    >
    >
    > > On Jul 31, 4:26 pm, "Evertjan." <> wrote:
    > >> paulmitchell507 wrote on 31 jul 2008 in
    > >> microsoft.public.inetserver.asp.general:

    >
    > >> >> Try:

    >
    > >> >> .HTMLBody = "<a href='http://192.156.217.134/authorise.asp?id="&

    > > _
    > >> >> ÿholiday_ID & "'>delete record</a><br><br>"

    >
    > >> [please do not quite signatures on usenet]

    >
    > >> > You are correct, I know very little about programming, hence why I
    > >> > have posted the question.  Maybe I have not explained myself very
    > >> > well.  If insert the following code
    > >> > HTMLBody = "<a href='http://192.156.217.134/authorise.asp'>delete
    > >> > record</a><br><br>"
    > >> > The user will receive a hyperlink called 'delete record' which will
    > >> > take them to my authorise.asp page.
    > >> > All I want to do is add my variable, holiday_ID to the string, a
    > >> > bit like response.write "my holiday id is" & holiday_ID
    > >> > So when the user activates the link, the user gets directed to the
    > >> > asp page with the holiday_ID as a querystring.  I can then use the
    > >> > holiday_ID value in the authorise.asp page.

    >
    > >> ... and my example above does not do that?

    >
    > >> --
    > >> Evertjan.
    > >> The Netherlands.
    > >> (Please change the x'es to dots in my emailaddress)

    >
    > > Dear Evertjan
    > > Sorry, I did not see your example code in the previous post.  Thank
    > > you very much for taking the time to help me, the following code works

    >
    > > .HTMLBody = "<a href='http://192.x.x.x/authorise.asp?id="& email
    > > &"'>delete record</a><br><br>"

    >
    > > Paul
    > > PS Maybe you could assist me in the future...I am sure I am going to
    > > need it!

    >
    > Only if you read the responses completely, as I nearly wrote:
    > "[please do not quote signatures on usenet]"
    > and you did not follow that Netiquette advice.
    >
    > --
    > Evertjan.
    > The Netherlands.
    > (Please change the x'es to dots in my emailaddress)- Hide quoted text -
    >
    > - Show quoted text -


    Ok, no signatures!
    My next problem (again simple to solve if you have the knowledge)
    regarding CDOSYS. The CDOSYS script is located on email.asp,
    surrounded by the delimiters <% and %>. I would like to run the
    CDOSYS script and then use a SQL insert command to update the
    database. At the monent, I cant get the email.asp page to do anything
    other than run the CDOSYS script.
     
    paulmitchell507, Aug 1, 2008
    #7
  8. paulmitchell507

    Evertjan. Guest

    paulmitchell507 wrote on 01 aug 2008 in
    microsoft.public.inetserver.asp.general:

    >> Only if you read the responses completely, as I nearly wrote:
    >> "[please do not quote signatures on usenet]"
    >> and you did not follow that Netiquette advice.
    >>
    >> --
    >> Evertjan.
    >> The Netherlands.
    >> (Please change the x'es to dots in my emailaddress)- Hide quoted text
    >> -
    >>
    >> - Show quoted text -

    >
    > Ok, no signatures!


    You misunderstand. Your signature should be there,
    but there is no reason to QUOTE mine(!) in your(!) posting.

    > My next problem (again simple to solve if you have the knowledge)


    How would you know?

    > regarding CDOSYS. The CDOSYS script is located on email.asp,
    > surrounded by the delimiters <% and %>. I would like to run the
    > CDOSYS script and then use a SQL insert command to update the
    > database. At the monent, I cant get the email.asp page to do anything
    > other than run the CDOSYS script.


    There is no "CDOSYS script" as such, there is ASP-vbscript or
    ASP-jscript between the <% and the %>, that is executed by and on the
    server.

    CDOSYS commands can be inserted in such scripts, if you want that email
    functionality used. I myself use Jmail instead. The scripting can be
    done in any .asp file, the name email.asp is just the name the
    programmer that wrote your page gave to the page file, and it could have
    included other functionality as well.

    So if you want to add or change functionality, there are two options:

    1 You learn to programme in ASP-vbs and/or ASP-jscript, and programme
    yourself. If you get into trouble, we will be here to help you, but we
    will not do the task for you, see 2.

    2 You let someone else do the task. Usually you pay such programmer for
    his work.

    A good start for learning would be to read the archives of this NG, or
    to search for ASP tutorials on Google.

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., Aug 1, 2008
    #8
  9. On Aug 1, 4:13 pm, "Evertjan." <> wrote:
    > paulmitchell507 wrote on 01 aug 2008 in
    > microsoft.public.inetserver.asp.general:
    >
    > >> Only if you read the responses completely, as I nearly wrote:
    > >> "[please do not quote signatures on usenet]"
    > >> and you did not follow that Netiquette advice.

    >
    > >> --
    > >> Evertjan.
    > >> The Netherlands.
    > >> (Please change the x'es to dots in my emailaddress)- Hide quoted text
    > >> -

    >
    > >> - Show quoted text -

    >
    > > Ok, no signatures!

    >
    > You misunderstand. Your signature should be there,
    > but there is no reason to QUOTE mine(!) in your(!) posting.
    >
    > > My next problem (again simple to solve if you have the knowledge)

    >
    > How would you know?
    >
    > > regarding CDOSYS.  The CDOSYS script is located on email.asp,
    > > surrounded by the delimiters <% and %>.  I would like to run the
    > > CDOSYS script and then use a SQL insert command to update the
    > > database.  At the monent, I cant get the email.asp page to do anything
    > > other than run the CDOSYS script.

    >
    > There is no "CDOSYS script" as such, there is ASP-vbscript or
    > ASP-jscript between the <% and the %>, that is executed by and on the
    > server.
    >
    > CDOSYS commands can be inserted in such scripts, if you want that email
    > functionality used. I myself use Jmail instead. The scripting can be
    > done in any .asp file, the name email.asp is just the name the
    > programmer that wrote your page gave to the page file, and it could have
    > included other functionality as well.
    >
    > So if you want to add or change functionality, there are two options:
    >
    > 1 You learn to programme in ASP-vbs and/or ASP-jscript, and programme
    > yourself. If you get into trouble, we will be here to help you, but we
    > will not do the task for you, see 2.
    >
    > 2 You let someone else do the task. Usually you pay such programmer for
    > his work.
    >
    > A good start for learning would be to read the archives of this NG, or
    > to search for ASP tutorials on Google.
    >
    > --
    > Evertjan.
    > The Netherlands.
    > (Please change the x'es to dots in my emailaddress)


    Forget my last post!
    I was looking at the wrong asp page. The SQL INSERT command was not
    working because I had not not written it correctly. I have everything
    working except for one last task. I will do a bit more research
    before posting for help!
     
    paulmitchell507, Aug 4, 2008
    #9
  10. On Aug 4, 2:19 pm, paulmitchell507 <>
    wrote:
    > On Aug 1, 4:13 pm, "Evertjan." <> wrote:
    >
    >
    >
    >
    >
    > > paulmitchell507 wrote on 01 aug 2008 in
    > > microsoft.public.inetserver.asp.general:

    >
    > > >> Only if you read the responses completely, as I nearly wrote:
    > > >> "[please do not quote signatures on usenet]"
    > > >> and you did not follow that Netiquette advice.

    >
    > > >> --
    > > >> Evertjan.
    > > >> The Netherlands.
    > > >> (Please change the x'es to dots in my emailaddress)- Hide quoted text
    > > >> -

    >
    > > >> - Show quoted text -

    >
    > > > Ok, no signatures!

    >
    > > You misunderstand. Your signature should be there,
    > > but there is no reason to QUOTE mine(!) in your(!) posting.

    >
    > > > My next problem (again simple to solve if you have the knowledge)

    >
    > > How would you know?

    >
    > > > regarding CDOSYS.  The CDOSYS script is located on email.asp,
    > > > surrounded by the delimiters <% and %>.  I would like to run the
    > > > CDOSYS script and then use a SQL insert command to update the
    > > > database.  At the monent, I cant get the email.asp page to do anything
    > > > other than run the CDOSYS script.

    >
    > > There is no "CDOSYS script" as such, there is ASP-vbscript or
    > > ASP-jscript between the <% and the %>, that is executed by and on the
    > > server.

    >
    > > CDOSYS commands can be inserted in such scripts, if you want that email
    > > functionality used. I myself use Jmail instead. The scripting can be
    > > done in any .asp file, the name email.asp is just the name the
    > > programmer that wrote your page gave to the page file, and it could have
    > > included other functionality as well.

    >
    > > So if you want to add or change functionality, there are two options:

    >
    > > 1 You learn to programme in ASP-vbs and/or ASP-jscript, and programme
    > > yourself. If you get into trouble, we will be here to help you, but we
    > > will not do the task for you, see 2.

    >
    > > 2 You let someone else do the task. Usually you pay such programmer for
    > > his work.

    >
    > > A good start for learning would be to read the archives of this NG, or
    > > to search for ASP tutorials on Google.

    >
    > > --
    > > Evertjan.
    > > The Netherlands.
    > > (Please change the x'es to dots in my emailaddress)

    >
    > Forget my last post!
    > I was looking at the wrong asp page.  The SQL INSERT command was not
    > working because I had not not written it correctly.  I have everything
    > working except for one last task.  I will do a bit more research
    > before posting for help!- Hide quoted text -
    >
    > - Show quoted text -


    Ok, I think I am trying to doing something that is very simple,
    inserting the results of a SQL query into an existing table in my
    access DB.

    uSQL = "SELECT cal_date, holiday_ID from Calendar, holiday_tbl WHERE
    (((calendar.cal_Date) Between [holiday_tbl].[startdate] And
    [holiday_tbl].[enddate])) And Email_sent=0 AND Staff_ID=" & Staff_ID

    The query returns a holiday_ID and a cal_date for each record if finds
    that matches the criteria. I can test the results my adding the
    following,

    If recordset.EOF Then
    Response.write "<div align='centre'>Sorry no holidays found</div>"
    Else
    Do while not recordset.Eof
    response.write recordset("holiday_id") & " " & recordset("cal_date") &
    " "
    recordset.movenext
    Loop
    End If

    My question is simple, how can I insert the results into an existing
    table named holiday_dates? The table has 2 fields, holiday_ID and
    cal_date.

    Regards, Paul
     
    paulmitchell507, Aug 5, 2008
    #10
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. GJH
    Replies:
    3
    Views:
    538
    no22nd
    Feb 1, 2006
  2. Akbur
    Replies:
    8
    Views:
    969
    Akbur
    Apr 13, 2007
  3. Ray Paganini

    CDOSYS Access Denied on objMail.Send

    Ray Paganini, Nov 21, 2003, in forum: ASP General
    Replies:
    1
    Views:
    180
    Ray at
    Nov 21, 2003
  4. rschaeferhig
    Replies:
    4
    Views:
    257
  5. Orgil
    Replies:
    3
    Views:
    395
    Justin Piper
    Jul 20, 2007
Loading...

Share This Page