Can't attach attachments in email using ASP CDO

Discussion in 'ASP General' started by tabonni, Aug 23, 2004.

  1. tabonni

    tabonni Guest

    Hi

    I try to grab the checked files from HTML page and then send those PDF
    files as attachments. It can just send email, there are no PDF files
    attached. Can anybody point out my error?

    My idea is:
    When people check the check boxes in HTML page for the PDF files, it
    will transfer the files' name to ASP page. Then, it will attach it in
    the email.

    ASP file - myMail.asp
    ---------------------

    <%@ Language=VBScript %>
    <!--METADATA TYPE="typelib"
    UUID="CD000000-8B95-11D1-82DB-00C04FB1625D" NAME="CDO for Windows
    Library" -->
    <!--METADATA TYPE="typelib"
    UUID="00000205-0000-0010-8000-00AA006D2EA4" NAME="ADODB Type Library"
    -->

    <%
    SUB sendmail( toWho, Subject, Body )
    Dim objCDO
    Dim iConf
    Dim Flds

    Const cdoSendUsingPort = 2

    Set objCDO = Server.CreateObject("CDO.Message")
    Set iConf = Server.CreateObject("CDO.Configuration")

    Set Flds = iConf.Fields
    With Flds
    ..Item(cdoSendUsingMethod) = cdoSendUsingPort
    ..Item(cdoSMTPServer) = "newserver"
    ..Item(cdoSMTPServerPort) = 25
    ..Item(cdoSMTPconnectiontimeout) = 10
    ..Update
    End With

    Set objCDO.Configuration = iConf

    objCDO.From = ""
    objCDO.To = toWho
    objCDO.Subject = Subject

    courseOutline = Request.Form( "Bus" )
    courseOutline = Split( courseOutline, "," )

    For Each member in courseOutline
    filepath = Server.Path("/") & member
    objCDO.AddAttachment filepath
    Next

    objCDO.TextBody = Body
    objCDO.Send
    END SUB

    toWho = TRIM( Request.Form("To") )
    Subject = TRIM( Request.Form("Subject") )
    Body = TRIM( Request.Form("Body") )
    IF toWho <> "" THEN
    sendMail toWho, Subject, Body

    'Cleanup
    Set ObjCDO = Nothing
    Set iConf = Nothing
    Set Flds = Nothing
    Response.Write "Email Sent"
    END IF
    %>

    <html>
    <body>
    <form action="mymail.asp" method="post" ID=Form1>
    <table cellspacing=0 cellpadding=2>
    <tr>
    <td> From: </td>
    </tr>
    <tr>
    <td> To: <input type="text" name="To" size="20" ID=Text1></td>
    </tr>
    <tr>
    <td> Subject: <input type="text" name="Subject" size="20"
    ID=Text2></td>
    </tr>
    <tr>
    <td> Attachments: </td>
    <td>
    <%
    courseOutline = Request.Form( "Bus" )
    courseOutline = Split( courseOutline, "," )
    For Each member in courseOutline
    response.write member & "<br>"
    Next
    %>
    </td>
    </tr>
    <tr>
    <td>Message: </td>
    </tr>
    <tr>
    <td><textarea rows="10" name="Body" cols="40"
    ID=Textarea1></textarea></td>
    </tr>
    <tr>
    <td colspan=2><input type="Submit" Name="Send" Value="Send Email"
    ></td>

    </tr>
    <tr>
    <td>
    <%
    msm = Request.Form("Test")
    response.write msm
    %>
    </td>
    </tr>
    </table>
    </form>
    </body>
    </html>


    HTML file - mailform.htm
    ---------
    <html>
    <head>
    <title>Request for More info</title>
    </head>
    <body>
    <form action="mymail.asp" method="post">
    <p>
    MS Outlook PDF Document
    <input type="checkbox" value="outlook.pdf" name="Bus" />
    </p>
    <p>
    MS Word PDF Document
    <input type="checkbox" value="word.pdf" name="Bus" />
    </p>
    <p>
    MS Excel PDF Document
    <input type="checkbox" value="excel.pdf" name="Bus" />
    </p>
    <p>
    <input type="submit" value="Submit" name="Submit" />
    </p>
    </form>
    </body>
    </html>
     
    tabonni, Aug 23, 2004
    #1
    1. Advertising

  2. Have you confirmed that your code thinks that some file should be attached?


    <%
    '...
    courseOutline = Request.Form( "Bus" )
    courseOutline = Split( courseOutline, "," )

    RESPONSE.WRITE UBOUND(courseOutline)
    RESPONSE.END

    For Each member in courseOutline
    filepath = Server.Path("/") & member
    objCDO.AddAttachment filepath
    Next
    '...
    %>

    Ray at work


    "tabonni" <> wrote in message
    news:...
    > Hi
    >
    > I try to grab the checked files from HTML page and then send those PDF
    > files as attachments. It can just send email, there are no PDF files
    > attached. Can anybody point out my error?
    >
    > My idea is:
    > When people check the check boxes in HTML page for the PDF files, it
    > will transfer the files' name to ASP page. Then, it will attach it in
    > the email.
    >
    > ASP file - myMail.asp
    > ---------------------
    >
    > <%@ Language=VBScript %>
    > <!--METADATA TYPE="typelib"
    > UUID="CD000000-8B95-11D1-82DB-00C04FB1625D" NAME="CDO for Windows
    > Library" -->
    > <!--METADATA TYPE="typelib"
    > UUID="00000205-0000-0010-8000-00AA006D2EA4" NAME="ADODB Type Library"
    > -->
    >
    > <%
    > SUB sendmail( toWho, Subject, Body )
    > Dim objCDO
    > Dim iConf
    > Dim Flds
    >
    > Const cdoSendUsingPort = 2
    >
    > Set objCDO = Server.CreateObject("CDO.Message")
    > Set iConf = Server.CreateObject("CDO.Configuration")
    >
    > Set Flds = iConf.Fields
    > With Flds
    > .Item(cdoSendUsingMethod) = cdoSendUsingPort
    > .Item(cdoSMTPServer) = "newserver"
    > .Item(cdoSMTPServerPort) = 25
    > .Item(cdoSMTPconnectiontimeout) = 10
    > .Update
    > End With
    >
    > Set objCDO.Configuration = iConf
    >
    > objCDO.From = ""
    > objCDO.To = toWho
    > objCDO.Subject = Subject
    >
    > courseOutline = Request.Form( "Bus" )
    > courseOutline = Split( courseOutline, "," )
    >
    > For Each member in courseOutline
    > filepath = Server.Path("/") & member
    > objCDO.AddAttachment filepath
    > Next
     
    Ray Costanzo [MVP], Aug 23, 2004
    #2
    1. Advertising

  3. tabonni

    tabonni Guest

    I tested the courseOutline array using For Each..Next Loop
    All items I selected in the HTML page are in the courseOutline Array.
    I don't know why I still can't attach those files as attachments in
    email. There are no error pop out either. Any idea?

    Cheers

    "Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in message news:<#>...
    > Have you confirmed that your code thinks that some file should be attached?
    >
    >
    > <%
    > '...
    > courseOutline = Request.Form( "Bus" )
    > courseOutline = Split( courseOutline, "," )
    >
    > RESPONSE.WRITE UBOUND(courseOutline)
    > RESPONSE.END
    >
    > For Each member in courseOutline
    > filepath = Server.Path("/") & member
    > objCDO.AddAttachment filepath
    > Next
    > '...
    > %>
    >
    > Ray at work
    >
    >
    > "tabonni" <> wrote in message
    > news:...
    > > Hi
    > >
    > > I try to grab the checked files from HTML page and then send those PDF
    > > files as attachments. It can just send email, there are no PDF files
    > > attached. Can anybody point out my error?
    > >
    > > My idea is:
    > > When people check the check boxes in HTML page for the PDF files, it
    > > will transfer the files' name to ASP page. Then, it will attach it in
    > > the email.
    > >
    > > ASP file - myMail.asp
    > > ---------------------
    > >
    > > <%@ Language=VBScript %>
    > > <!--METADATA TYPE="typelib"
    > > UUID="CD000000-8B95-11D1-82DB-00C04FB1625D" NAME="CDO for Windows
    > > Library" -->
    > > <!--METADATA TYPE="typelib"
    > > UUID="00000205-0000-0010-8000-00AA006D2EA4" NAME="ADODB Type Library"
    > > -->
    > >
    > > <%
    > > SUB sendmail( toWho, Subject, Body )
    > > Dim objCDO
    > > Dim iConf
    > > Dim Flds
    > >
    > > Const cdoSendUsingPort = 2
    > >
    > > Set objCDO = Server.CreateObject("CDO.Message")
    > > Set iConf = Server.CreateObject("CDO.Configuration")
    > >
    > > Set Flds = iConf.Fields
    > > With Flds
    > > .Item(cdoSendUsingMethod) = cdoSendUsingPort
    > > .Item(cdoSMTPServer) = "newserver"
    > > .Item(cdoSMTPServerPort) = 25
    > > .Item(cdoSMTPconnectiontimeout) = 10
    > > .Update
    > > End With
    > >
    > > Set objCDO.Configuration = iConf
    > >
    > > objCDO.From = ""
    > > objCDO.To = toWho
    > > objCDO.Subject = Subject
    > >
    > > courseOutline = Request.Form( "Bus" )
    > > courseOutline = Split( courseOutline, "," )
    > >
    > > For Each member in courseOutline
    > > filepath = Server.Path("/") & member
    > > objCDO.AddAttachment filepath
    > > Next
     
    tabonni, Aug 24, 2004
    #3
  4. Well, now is when you debug, by creating a test asp page that just tries to
    attach one small text file to a mail object and is as simple as possible.
    Try to narrow down where the problem may be until you find it.

    Ray at work

    "tabonni" <> wrote in message
    news:...
    >I tested the courseOutline array using For Each..Next Loop
    > All items I selected in the HTML page are in the courseOutline Array.
    > I don't know why I still can't attach those files as attachments in
    > email. There are no error pop out either. Any idea?
    >
    > Cheers
    >
    > "Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
    > message news:<#>...
    >> Have you confirmed that your code thinks that some file should be
    >> attached?
    >>
    >>
    >> <%
    >> '...
    >> courseOutline = Request.Form( "Bus" )
    >> courseOutline = Split( courseOutline, "," )
    >>
    >> RESPONSE.WRITE UBOUND(courseOutline)
    >> RESPONSE.END
    >>
    >> For Each member in courseOutline
    >> filepath = Server.Path("/") & member
    >> objCDO.AddAttachment filepath
    >> Next
    >> '...
    >> %>
    >>
    >> Ray at work
    >>
    >>
    >> "tabonni" <> wrote in message
    >> news:...
    >> > Hi
    >> >
    >> > I try to grab the checked files from HTML page and then send those PDF
    >> > files as attachments. It can just send email, there are no PDF files
    >> > attached. Can anybody point out my error?
    >> >
    >> > My idea is:
    >> > When people check the check boxes in HTML page for the PDF files, it
    >> > will transfer the files' name to ASP page. Then, it will attach it in
    >> > the email.
    >> >
    >> > ASP file - myMail.asp
    >> > ---------------------
    >> >
    >> > <%@ Language=VBScript %>
    >> > <!--METADATA TYPE="typelib"
    >> > UUID="CD000000-8B95-11D1-82DB-00C04FB1625D" NAME="CDO for Windows
    >> > Library" -->
    >> > <!--METADATA TYPE="typelib"
    >> > UUID="00000205-0000-0010-8000-00AA006D2EA4" NAME="ADODB Type Library"
    >> > -->
    >> >
    >> > <%
    >> > SUB sendmail( toWho, Subject, Body )
    >> > Dim objCDO
    >> > Dim iConf
    >> > Dim Flds
    >> >
    >> > Const cdoSendUsingPort = 2
    >> >
    >> > Set objCDO = Server.CreateObject("CDO.Message")
    >> > Set iConf = Server.CreateObject("CDO.Configuration")
    >> >
    >> > Set Flds = iConf.Fields
    >> > With Flds
    >> > .Item(cdoSendUsingMethod) = cdoSendUsingPort
    >> > .Item(cdoSMTPServer) = "newserver"
    >> > .Item(cdoSMTPServerPort) = 25
    >> > .Item(cdoSMTPconnectiontimeout) = 10
    >> > .Update
    >> > End With
    >> >
    >> > Set objCDO.Configuration = iConf
    >> >
    >> > objCDO.From = ""
    >> > objCDO.To = toWho
    >> > objCDO.Subject = Subject
    >> >
    >> > courseOutline = Request.Form( "Bus" )
    >> > courseOutline = Split( courseOutline, "," )
    >> >
    >> > For Each member in courseOutline
    >> > filepath = Server.Path("/") & member
    >> > objCDO.AddAttachment filepath
    >> > Next
     
    Ray Costanzo [MVP], Aug 24, 2004
    #4
  5. tabonni

    tabonni Guest

    Hello Ray

    I used Response.Write to print out every single elements inside
    outlines array. All the elements are what I selected in HTML Page. I'm
    even printed out the filepath after using Server.MapPath(). They are
    correct either. I really don't where are the bugs.

    But, the strange thing is if I'm hard coding the courseOutlines array
    elements. Like:

    Dim outlines(3)
    outlines(0) = "outlook.txt"
    outlines(1) = "word.txt"
    outlines(2) = "excel.txt"

    For i=0 to UBound(outlines)
    filepath = Server.MapPath(".") & TRIM("\") & TRIM(outlines(i))
    objCDO.AddAttachment filepath
    Next

    It works. It can attach all documents in the email.

    But, when I change it to:

    outlines = Request.Form("Bus")
    Outlines = Split( Outlines, "," )

    For i=0 to UBound(outlines)
    filepath = Server.MapPath(".") & TRIM("\") & TRIM(outlines(i))
    objCDO.AddAttachment filepath
    Next

    It doesn't work.

    I printed out the filepath and elements in outlines. They are fine as
    well.
    Please Help. I'm feeling hopeless.

    Cheers
    Bon



    "Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in message news:<O$M#>...
    > Well, now is when you debug, by creating a test asp page that just tries to
    > attach one small text file to a mail object and is as simple as possible.
    > Try to narrow down where the problem may be until you find it.
    >
    > Ray at work
    >
    > "tabonni" <> wrote in message
    > news:...
    > >I tested the courseOutline array using For Each..Next Loop
    > > All items I selected in the HTML page are in the courseOutline Array.
    > > I don't know why I still can't attach those files as attachments in
    > > email. There are no error pop out either. Any idea?
    > >
    > > Cheers
    > >
    > > "Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
    > > message news:<#>...
    > >> Have you confirmed that your code thinks that some file should be
    > >> attached?
    > >>
    > >>
    > >> <%
    > >> '...
    > >> courseOutline = Request.Form( "Bus" )
    > >> courseOutline = Split( courseOutline, "," )
    > >>
    > >> RESPONSE.WRITE UBOUND(courseOutline)
    > >> RESPONSE.END
    > >>
    > >> For Each member in courseOutline
    > >> filepath = Server.Path("/") & member
    > >> objCDO.AddAttachment filepath
    > >> Next
    > >> '...
    > >> %>
    > >>
    > >> Ray at work
    > >>
    > >>
    > >> "tabonni" <> wrote in message
    > >> news:...
    > >> > Hi
    > >> >
    > >> > I try to grab the checked files from HTML page and then send those PDF
    > >> > files as attachments. It can just send email, there are no PDF files
    > >> > attached. Can anybody point out my error?
    > >> >
    > >> > My idea is:
    > >> > When people check the check boxes in HTML page for the PDF files, it
    > >> > will transfer the files' name to ASP page. Then, it will attach it in
    > >> > the email.
    > >> >
    > >> > ASP file - myMail.asp
    > >> > ---------------------
    > >> >
    > >> > <%@ Language=VBScript %>
    > >> > <!--METADATA TYPE="typelib"
    > >> > UUID="CD000000-8B95-11D1-82DB-00C04FB1625D" NAME="CDO for Windows
    > >> > Library" -->
    > >> > <!--METADATA TYPE="typelib"
    > >> > UUID="00000205-0000-0010-8000-00AA006D2EA4" NAME="ADODB Type Library"
    > >> > -->
    > >> >
    > >> > <%
    > >> > SUB sendmail( toWho, Subject, Body )
    > >> > Dim objCDO
    > >> > Dim iConf
    > >> > Dim Flds
    > >> >
    > >> > Const cdoSendUsingPort = 2
    > >> >
    > >> > Set objCDO = Server.CreateObject("CDO.Message")
    > >> > Set iConf = Server.CreateObject("CDO.Configuration")
    > >> >
    > >> > Set Flds = iConf.Fields
    > >> > With Flds
    > >> > .Item(cdoSendUsingMethod) = cdoSendUsingPort
    > >> > .Item(cdoSMTPServer) = "newserver"
    > >> > .Item(cdoSMTPServerPort) = 25
    > >> > .Item(cdoSMTPconnectiontimeout) = 10
    > >> > .Update
    > >> > End With
    > >> >
    > >> > Set objCDO.Configuration = iConf
    > >> >
    > >> > objCDO.From = ""
    > >> > objCDO.To = toWho
    > >> > objCDO.Subject = Subject
    > >> >
    > >> > courseOutline = Request.Form( "Bus" )
    > >> > courseOutline = Split( courseOutline, "," )
    > >> >
    > >> > For Each member in courseOutline
    > >> > filepath = Server.Path("/") & member
    > >> > objCDO.AddAttachment filepath
    > >> > Next
     
    tabonni, Aug 26, 2004
    #5
  6. Okay, the problem is that you are doing this in a two step process, and
    you're not carrying through the values from the first page in which the user
    checks the boxes for the files. When the user does that and submits the
    form, he must then submit a second form to get the e-mail sending initiated.
    At that second submission, your Request.Form("bus") is no longer valid, as
    it's gone. You have to carry that through.

    Check out your form in action here.
    http://www.lane34.com/tabonni/mailform.htm Note the "View Code" link on the
    "mymail.asp" page.

    In your final version of this thing you're working on, you may want to
    response.redirect your users after the mail is sent. Like,
    response.redirect them to a "thankyou.htm" page or something. Otherwise,
    they can just sit there and refresh/resubmit repeatedly.

    Ray at home


    "tabonni" <> wrote in message
    news:...
    > Hello Ray
    >
    > I used Response.Write to print out every single elements inside
    > outlines array. All the elements are what I selected in HTML Page. I'm
    > even printed out the filepath after using Server.MapPath(). They are
    > correct either. I really don't where are the bugs.
    >
    > But, the strange thing is if I'm hard coding the courseOutlines array
    > elements. Like:
    >
    > Dim outlines(3)
    > outlines(0) = "outlook.txt"
    > outlines(1) = "word.txt"
    > outlines(2) = "excel.txt"
    >
    > For i=0 to UBound(outlines)
    > filepath = Server.MapPath(".") & TRIM("\") & TRIM(outlines(i))
    > objCDO.AddAttachment filepath
    > Next
    >
    > It works. It can attach all documents in the email.
    >
    > But, when I change it to:
    >
    > outlines = Request.Form("Bus")
    > Outlines = Split( Outlines, "," )
    >
    > For i=0 to UBound(outlines)
    > filepath = Server.MapPath(".") & TRIM("\") & TRIM(outlines(i))
    > objCDO.AddAttachment filepath
    > Next
    >
    > It doesn't work.
    >
    > I printed out the filepath and elements in outlines. They are fine as
    > well.
    > Please Help. I'm feeling hopeless.
    >
    > Cheers
    > Bon
    >
    >
    >
    > "Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in

    message news:<O$M#>...
    > > Well, now is when you debug, by creating a test asp page that just tries

    to
    > > attach one small text file to a mail object and is as simple as

    possible.
    > > Try to narrow down where the problem may be until you find it.
    > >
    > > Ray at work
    > >
    > > "tabonni" <> wrote in message
    > > news:...
    > > >I tested the courseOutline array using For Each..Next Loop
    > > > All items I selected in the HTML page are in the courseOutline Array.
    > > > I don't know why I still can't attach those files as attachments in
    > > > email. There are no error pop out either. Any idea?
    > > >
    > > > Cheers
    > > >
    > > > "Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote

    in
    > > > message news:<#>...
    > > >> Have you confirmed that your code thinks that some file should be
    > > >> attached?
    > > >>
    > > >>
    > > >> <%
    > > >> '...
    > > >> courseOutline = Request.Form( "Bus" )
    > > >> courseOutline = Split( courseOutline, "," )
    > > >>
    > > >> RESPONSE.WRITE UBOUND(courseOutline)
    > > >> RESPONSE.END
    > > >>
    > > >> For Each member in courseOutline
    > > >> filepath = Server.Path("/") & member
    > > >> objCDO.AddAttachment filepath
    > > >> Next
    > > >> '...
    > > >> %>
    > > >>
    > > >> Ray at work
    > > >>
    > > >>
    > > >> "tabonni" <> wrote in message
    > > >> news:...
    > > >> > Hi
    > > >> >
    > > >> > I try to grab the checked files from HTML page and then send those

    PDF
    > > >> > files as attachments. It can just send email, there are no PDF

    files
    > > >> > attached. Can anybody point out my error?
    > > >> >
    > > >> > My idea is:
    > > >> > When people check the check boxes in HTML page for the PDF files,

    it
    > > >> > will transfer the files' name to ASP page. Then, it will attach it

    in
    > > >> > the email.
    > > >> >
    > > >> > ASP file - myMail.asp
    > > >> > ---------------------
    > > >> >
    > > >> > <%@ Language=VBScript %>
    > > >> > <!--METADATA TYPE="typelib"
    > > >> > UUID="CD000000-8B95-11D1-82DB-00C04FB1625D" NAME="CDO for Windows
    > > >> > Library" -->
    > > >> > <!--METADATA TYPE="typelib"
    > > >> > UUID="00000205-0000-0010-8000-00AA006D2EA4" NAME="ADODB Type

    Library"
    > > >> > -->
    > > >> >
    > > >> > <%
    > > >> > SUB sendmail( toWho, Subject, Body )
    > > >> > Dim objCDO
    > > >> > Dim iConf
    > > >> > Dim Flds
    > > >> >
    > > >> > Const cdoSendUsingPort = 2
    > > >> >
    > > >> > Set objCDO = Server.CreateObject("CDO.Message")
    > > >> > Set iConf = Server.CreateObject("CDO.Configuration")
    > > >> >
    > > >> > Set Flds = iConf.Fields
    > > >> > With Flds
    > > >> > .Item(cdoSendUsingMethod) = cdoSendUsingPort
    > > >> > .Item(cdoSMTPServer) = "newserver"
    > > >> > .Item(cdoSMTPServerPort) = 25
    > > >> > .Item(cdoSMTPconnectiontimeout) = 10
    > > >> > .Update
    > > >> > End With
    > > >> >
    > > >> > Set objCDO.Configuration = iConf
    > > >> >
    > > >> > objCDO.From = ""
    > > >> > objCDO.To = toWho
    > > >> > objCDO.Subject = Subject
    > > >> >
    > > >> > courseOutline = Request.Form( "Bus" )
    > > >> > courseOutline = Split( courseOutline, "," )
    > > >> >
    > > >> > For Each member in courseOutline
    > > >> > filepath = Server.Path("/") & member
    > > >> > objCDO.AddAttachment filepath
    > > >> > Next
     
    Ray Costanzo [MVP], Aug 26, 2004
    #6
  7. tabonni

    tabonni Guest

    Hello Ray

    Thank you very very very much. I had that problems for 2 weeks. I
    didn't know where were the bugs.

    May I ask you how did you find the bugs? What methods did you use?
    Because I did print out all elements in the outlines array and checked
    the filepaths. All are correct. I had no idea what's wrong. So, how
    did you do that?

    Thank you anyway. You save my life. :D

    "Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in message news:<O#>...
    > Okay, the problem is that you are doing this in a two step process, and
    > you're not carrying through the values from the first page in which the user
    > checks the boxes for the files. When the user does that and submits the
    > form, he must then submit a second form to get the e-mail sending initiated.
    > At that second submission, your Request.Form("bus") is no longer valid, as
    > it's gone. You have to carry that through.
    >
    > Check out your form in action here.
    > http://www.lane34.com/tabonni/mailform.htm Note the "View Code" link on the
    > "mymail.asp" page.
    >
    > In your final version of this thing you're working on, you may want to
    > response.redirect your users after the mail is sent. Like,
    > response.redirect them to a "thankyou.htm" page or something. Otherwise,
    > they can just sit there and refresh/resubmit repeatedly.
    >
    > Ray at home
    >
    >
    > "tabonni" <> wrote in message
    > news:...
    > > Hello Ray
    > >
    > > I used Response.Write to print out every single elements inside
    > > outlines array. All the elements are what I selected in HTML Page. I'm
    > > even printed out the filepath after using Server.MapPath(). They are
    > > correct either. I really don't where are the bugs.
    > >
    > > But, the strange thing is if I'm hard coding the courseOutlines array
    > > elements. Like:
    > >
    > > Dim outlines(3)
    > > outlines(0) = "outlook.txt"
    > > outlines(1) = "word.txt"
    > > outlines(2) = "excel.txt"
    > >
    > > For i=0 to UBound(outlines)
    > > filepath = Server.MapPath(".") & TRIM("\") & TRIM(outlines(i))
    > > objCDO.AddAttachment filepath
    > > Next
    > >
    > > It works. It can attach all documents in the email.
    > >
    > > But, when I change it to:
    > >
    > > outlines = Request.Form("Bus")
    > > Outlines = Split( Outlines, "," )
    > >
    > > For i=0 to UBound(outlines)
    > > filepath = Server.MapPath(".") & TRIM("\") & TRIM(outlines(i))
    > > objCDO.AddAttachment filepath
    > > Next
    > >
    > > It doesn't work.
    > >
    > > I printed out the filepath and elements in outlines. They are fine as
    > > well.
    > > Please Help. I'm feeling hopeless.
    > >
    > > Cheers
    > > Bon
    > >
    > >
    > >
    > > "Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in

    > message news:<O$M#>...
    > > > Well, now is when you debug, by creating a test asp page that just tries

    > to
    > > > attach one small text file to a mail object and is as simple as

    > possible.
    > > > Try to narrow down where the problem may be until you find it.
    > > >
    > > > Ray at work
    > > >
    > > > "tabonni" <> wrote in message
    > > > news:...
    > > > >I tested the courseOutline array using For Each..Next Loop
    > > > > All items I selected in the HTML page are in the courseOutline Array.
    > > > > I don't know why I still can't attach those files as attachments in
    > > > > email. There are no error pop out either. Any idea?
    > > > >
    > > > > Cheers
    > > > >
    > > > > "Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote

    > in
    > > > > message news:<#>...
    > > > >> Have you confirmed that your code thinks that some file should be
    > > > >> attached?
    > > > >>
    > > > >>
    > > > >> <%
    > > > >> '...
    > > > >> courseOutline = Request.Form( "Bus" )
    > > > >> courseOutline = Split( courseOutline, "," )
    > > > >>
    > > > >> RESPONSE.WRITE UBOUND(courseOutline)
    > > > >> RESPONSE.END
    > > > >>
    > > > >> For Each member in courseOutline
    > > > >> filepath = Server.Path("/") & member
    > > > >> objCDO.AddAttachment filepath
    > > > >> Next
    > > > >> '...
    > > > >> %>
    > > > >>
    > > > >> Ray at work
    > > > >>
    > > > >>
    > > > >> "tabonni" <> wrote in message
    > > > >> news:...
    > > > >> > Hi
    > > > >> >
    > > > >> > I try to grab the checked files from HTML page and then send those

    > PDF
    > > > >> > files as attachments. It can just send email, there are no PDF

    > files
    > > > >> > attached. Can anybody point out my error?
    > > > >> >
    > > > >> > My idea is:
    > > > >> > When people check the check boxes in HTML page for the PDF files,

    > it
    > > > >> > will transfer the files' name to ASP page. Then, it will attach it

    > in
    > > > >> > the email.
    > > > >> >
    > > > >> > ASP file - myMail.asp
    > > > >> > ---------------------
    > > > >> >
    > > > >> > <%@ Language=VBScript %>
    > > > >> > <!--METADATA TYPE="typelib"
    > > > >> > UUID="CD000000-8B95-11D1-82DB-00C04FB1625D" NAME="CDO for Windows
    > > > >> > Library" -->
    > > > >> > <!--METADATA TYPE="typelib"
    > > > >> > UUID="00000205-0000-0010-8000-00AA006D2EA4" NAME="ADODB Type

    > Library"
    > > > >> > -->
    > > > >> >
    > > > >> > <%
    > > > >> > SUB sendmail( toWho, Subject, Body )
    > > > >> > Dim objCDO
    > > > >> > Dim iConf
    > > > >> > Dim Flds
    > > > >> >
    > > > >> > Const cdoSendUsingPort = 2
    > > > >> >
    > > > >> > Set objCDO = Server.CreateObject("CDO.Message")
    > > > >> > Set iConf = Server.CreateObject("CDO.Configuration")
    > > > >> >
    > > > >> > Set Flds = iConf.Fields
    > > > >> > With Flds
    > > > >> > .Item(cdoSendUsingMethod) = cdoSendUsingPort
    > > > >> > .Item(cdoSMTPServer) = "newserver"
    > > > >> > .Item(cdoSMTPServerPort) = 25
    > > > >> > .Item(cdoSMTPconnectiontimeout) = 10
    > > > >> > .Update
    > > > >> > End With
    > > > >> >
    > > > >> > Set objCDO.Configuration = iConf
    > > > >> >
    > > > >> > objCDO.From = ""
    > > > >> > objCDO.To = toWho
    > > > >> > objCDO.Subject = Subject
    > > > >> >
    > > > >> > courseOutline = Request.Form( "Bus" )
    > > > >> > courseOutline = Split( courseOutline, "," )
    > > > >> >
    > > > >> > For Each member in courseOutline
    > > > >> > filepath = Server.Path("/") & member
    > > > >> > objCDO.AddAttachment filepath
    > > > >> > Next
     
    tabonni, Aug 27, 2004
    #7
  8. It wasn't until I copied and pasted the code that you posted in your
    original message and tried it that I saw something wrong. I first through
    in the RESPONSE.WRITE filepath & "<br>" lines. When I did that, I saw that
    the file paths were valid, but then when I submitted the second form and
    didn't see them, I realized that there was no array of file paths. So,
    where was that array supposed to come from? I saw that it was supposed to
    come from Request.Form("BUS"). So, I did a view-source and searched for a
    form element named BUS, and did not see one. I guess that's how I could
    have discovered the issue anyway!

    Ray at work

    "tabonni" <> wrote in message
    news:...
    > Hello Ray
    >
    > Thank you very very very much. I had that problems for 2 weeks. I
    > didn't know where were the bugs.
    >
    > May I ask you how did you find the bugs? What methods did you use?
    > Because I did print out all elements in the outlines array and checked
    > the filepaths. All are correct. I had no idea what's wrong. So, how
    > did you do that?
    >
    > Thank you anyway. You save my life. :D
    >
    > "Ray Costanzo [MVP]" <my first name at
     
    Ray Costanzo [MVP], Aug 27, 2004
    #8
  9. tabonni

    tabonni Guest

    Anyway, I have to thanks you again.

    May I ask you one more question? I don't know why the program generate
    a tmp file everytime I submit the email form. For example, After I
    selected all the documents I required and send an email, a tmp file
    will be generated and be placed in the same directory of the
    myMail.asp and the directories I put all the PDF files. I opened the
    tmp file. There is all myMail.asp coding. How come?

    Cheers
    Bon


    "Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in message news:<>...
    > It wasn't until I copied and pasted the code that you posted in your
    > original message and tried it that I saw something wrong. I first through
    > in the RESPONSE.WRITE filepath & "<br>" lines. When I did that, I saw that
    > the file paths were valid, but then when I submitted the second form and
    > didn't see them, I realized that there was no array of file paths. So,
    > where was that array supposed to come from? I saw that it was supposed to
    > come from Request.Form("BUS"). So, I did a view-source and searched for a
    > form element named BUS, and did not see one. I guess that's how I could
    > have discovered the issue anyway!
    >
    > Ray at work
    >
    > "tabonni" <> wrote in message
    > news:...
    > > Hello Ray
    > >
    > > Thank you very very very much. I had that problems for 2 weeks. I
    > > didn't know where were the bugs.
    > >
    > > May I ask you how did you find the bugs? What methods did you use?
    > > Because I did print out all elements in the outlines array and checked
    > > the filepaths. All are correct. I had no idea what's wrong. So, how
    > > did you do that?
    > >
    > > Thank you anyway. You save my life. :D
    > >
    > > "Ray Costanzo [MVP]" <my first name at
     
    tabonni, Aug 28, 2004
    #9
  10. That is odd. I've never heard of that happening before. What's the name of
    the file?

    Ray at hom

    "tabonni" <> wrote in message
    news:...
    > Anyway, I have to thanks you again.
    >
    > May I ask you one more question? I don't know why the program generate
    > a tmp file everytime I submit the email form. For example, After I
    > selected all the documents I required and send an email, a tmp file
    > will be generated and be placed in the same directory of the
    > myMail.asp and the directories I put all the PDF files. I opened the
    > tmp file. There is all myMail.asp coding. How come?
    >
    > Cheers
    > Bon
    >
     
    Ray Costanzo [MVP], Aug 28, 2004
    #10
  11. tabonni

    tabonni Guest

    Hello Ray

    Those files' name are ve-6F47 (the myMail.asp) and ve-6F4A
    (mailForm.htm). But, every time I send an email, they will be
    generated and the name will change as well. Like, ve-6F48, ve-6F49...
    etc ve6F4A, ve6F4B... etc. Inside those TMP files are the coding of
    myMail.asp and mailForm.htm.

    Cheers
    Bon

    "Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in message news:<#>...
    > That is odd. I've never heard of that happening before. What's the name of
    > the file?
    >
    > Ray at hom
    >
    > "tabonni" <> wrote in message
    > news:...
    > > Anyway, I have to thanks you again.
    > >
    > > May I ask you one more question? I don't know why the program generate
    > > a tmp file everytime I submit the email form. For example, After I
    > > selected all the documents I required and send an email, a tmp file
    > > will be generated and be placed in the same directory of the
    > > myMail.asp and the directories I put all the PDF files. I opened the
    > > tmp file. There is all myMail.asp coding. How come?
    > >
    > > Cheers
    > > Bon
    > >
     
    tabonni, Aug 29, 2004
    #11
  12. That is interesting. I honestly have no idea what could be on your server
    that is generating .tmp files of your ASP pages. ??

    Ray at work

    "tabonni" <> wrote in message
    news:...
    > Hello Ray
    >
    > Those files' name are ve-6F47 (the myMail.asp) and ve-6F4A
    > (mailForm.htm). But, every time I send an email, they will be
    > generated and the name will change as well. Like, ve-6F48, ve-6F49...
    > etc ve6F4A, ve6F4B... etc. Inside those TMP files are the coding of
    > myMail.asp and mailForm.htm.
    >
    > Cheers
    > Bon
    >
    > "Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
    > message news:<#>...
    >> That is odd. I've never heard of that happening before. What's the name
    >> of
    >> the file?
    >>
    >> Ray at hom
    >>
    >> "tabonni" <> wrote in message
    >> news:...
    >> > Anyway, I have to thanks you again.
    >> >
    >> > May I ask you one more question? I don't know why the program generate
    >> > a tmp file everytime I submit the email form. For example, After I
    >> > selected all the documents I required and send an email, a tmp file
    >> > will be generated and be placed in the same directory of the
    >> > myMail.asp and the directories I put all the PDF files. I opened the
    >> > tmp file. There is all myMail.asp coding. How come?
    >> >
    >> > Cheers
    >> > Bon
    >> >
     
    Ray Costanzo [MVP], Aug 30, 2004
    #12
  13. tabonni

    tabonni Guest

    It's ok. Thank you for your help

    By the way, how often you check the google newsgroup? If I have
    problem later on, may I ask you again?

    Cheers
    Bon

    "Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in message news:<>...
    > That is interesting. I honestly have no idea what could be on your server
    > that is generating .tmp files of your ASP pages. ??
    >
    > Ray at work
    >
    > "tabonni" <> wrote in message
    > news:...
    > > Hello Ray
    > >
    > > Those files' name are ve-6F47 (the myMail.asp) and ve-6F4A
    > > (mailForm.htm). But, every time I send an email, they will be
    > > generated and the name will change as well. Like, ve-6F48, ve-6F49...
    > > etc ve6F4A, ve6F4B... etc. Inside those TMP files are the coding of
    > > myMail.asp and mailForm.htm.
    > >
    > > Cheers
    > > Bon
    > >
    > > "Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
    > > message news:<#>...
    > >> That is odd. I've never heard of that happening before. What's the name
    > >> of
    > >> the file?
    > >>
    > >> Ray at hom
    > >>
    > >> "tabonni" <> wrote in message
    > >> news:...
    > >> > Anyway, I have to thanks you again.
    > >> >
    > >> > May I ask you one more question? I don't know why the program generate
    > >> > a tmp file everytime I submit the email form. For example, After I
    > >> > selected all the documents I required and send an email, a tmp file
    > >> > will be generated and be placed in the same directory of the
    > >> > myMail.asp and the directories I put all the PDF files. I opened the
    > >> > tmp file. There is all myMail.asp coding. How come?
    > >> >
    > >> > Cheers
    > >> > Bon
    > >> >
     
    tabonni, Aug 31, 2004
    #13
  14. Just post your questions to the group. Somebody'll probably answer them.

    Ray at work


    "tabonni" <> wrote in message
    news:...
    > It's ok. Thank you for your help
    >
    > By the way, how often you check the google newsgroup? If I have
    > problem later on, may I ask you again?
    >
    > Cheers
    > Bon
    >
    > "Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
    > message news:<>...
    >> That is interesting. I honestly have no idea what could be on your
    >> server
    >> that is generating .tmp files of your ASP pages. ??
    >>
    >> Ray at work
    >>
    >> "tabonni" <> wrote in message
    >> news:...
    >> > Hello Ray
    >> >
    >> > Those files' name are ve-6F47 (the myMail.asp) and ve-6F4A
    >> > (mailForm.htm). But, every time I send an email, they will be
    >> > generated and the name will change as well. Like, ve-6F48, ve-6F49...
    >> > etc ve6F4A, ve6F4B... etc. Inside those TMP files are the coding of
    >> > myMail.asp and mailForm.htm.
    >> >
    >> > Cheers
    >> > Bon
    >> >
    >> > "Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
    >> > message news:<#>...
    >> >> That is odd. I've never heard of that happening before. What's the
    >> >> name
    >> >> of
    >> >> the file?
    >> >>
    >> >> Ray at hom
    >> >>
    >> >> "tabonni" <> wrote in message
    >> >> news:...
    >> >> > Anyway, I have to thanks you again.
    >> >> >
    >> >> > May I ask you one more question? I don't know why the program
    >> >> > generate
    >> >> > a tmp file everytime I submit the email form. For example, After I
    >> >> > selected all the documents I required and send an email, a tmp file
    >> >> > will be generated and be placed in the same directory of the
    >> >> > myMail.asp and the directories I put all the PDF files. I opened the
    >> >> > tmp file. There is all myMail.asp coding. How come?
    >> >> >
    >> >> > Cheers
    >> >> > Bon
    >> >> >
     
    Ray Costanzo [MVP], Aug 31, 2004
    #14
  15. tabonni

    tabonni Guest

    If I want to make my ASP CDO email application to have Reply & Forward
    functions, how can I do that? Do I need to use Outlook.Application
    object? If so, do you know any website about it?

    Cheers
    Bon

    "Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in message news:<>...
    > Just post your questions to the group. Somebody'll probably answer them.
    >
    > Ray at work
    >
    >
    > "tabonni" <> wrote in message
    > news:...
    > > It's ok. Thank you for your help
    > >
    > > By the way, how often you check the google newsgroup? If I have
    > > problem later on, may I ask you again?
    > >
    > > Cheers
    > > Bon
    > >
    > > "Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
    > > message news:<>...
    > >> That is interesting. I honestly have no idea what could be on your
    > >> server
    > >> that is generating .tmp files of your ASP pages. ??
    > >>
    > >> Ray at work
    > >>
    > >> "tabonni" <> wrote in message
    > >> news:...
    > >> > Hello Ray
    > >> >
    > >> > Those files' name are ve-6F47 (the myMail.asp) and ve-6F4A
    > >> > (mailForm.htm). But, every time I send an email, they will be
    > >> > generated and the name will change as well. Like, ve-6F48, ve-6F49...
    > >> > etc ve6F4A, ve6F4B... etc. Inside those TMP files are the coding of
    > >> > myMail.asp and mailForm.htm.
    > >> >
    > >> > Cheers
    > >> > Bon
    > >> >
    > >> > "Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
    > >> > message news:<#>...
    > >> >> That is odd. I've never heard of that happening before. What's the
    > >> >> name
    > >> >> of
    > >> >> the file?
    > >> >>
    > >> >> Ray at hom
    > >> >>
    > >> >> "tabonni" <> wrote in message
    > >> >> news:...
    > >> >> > Anyway, I have to thanks you again.
    > >> >> >
    > >> >> > May I ask you one more question? I don't know why the program
    > >> >> > generate
    > >> >> > a tmp file everytime I submit the email form. For example, After I
    > >> >> > selected all the documents I required and send an email, a tmp file
    > >> >> > will be generated and be placed in the same directory of the
    > >> >> > myMail.asp and the directories I put all the PDF files. I opened the
    > >> >> > tmp file. There is all myMail.asp coding. How come?
    > >> >> >
    > >> >> > Cheers
    > >> >> > Bon
    > >> >> >
     
    tabonni, Sep 1, 2004
    #15
  16. You're new to newsgroups, aren't you. :] When you have a new topic, please
    start a new thread. If you just keep using the same thread, the number of
    eyes that read your question will be pretty low, as this just appears to be
    part of a thread that is already in progress!

    One thing that would make things a bit easier is if you started using a news
    client to post to the newsgroups instead of Google's web-based interface.
    If interested, see here for setup instructions of common usenet
    applications. http://www.aspfaq.com/5007 http://www.aspfaq.com/2081 is
    another good article.

    Ray at home


    "tabonni" <> wrote in message
    news:...
    > If I want to make my ASP CDO email application to have Reply & Forward
    > functions, how can I do that? Do I need to use Outlook.Application
    > object? If so, do you know any website about it?
    >
    > Cheers
    > Bon
    >
    > "Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in

    message news:<>...
    > > Just post your questions to the group. Somebody'll probably answer

    them.
    > >
    > > Ray at
     
    Ray Costanzo [MVP], Sep 1, 2004
    #16
    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. Replies:
    0
    Views:
    664
  2. Warren Tang
    Replies:
    1
    Views:
    553
    Warren Tang
    Sep 17, 2008
  3. Replies:
    0
    Views:
    279
  4. MoFo22

    asp, cdo and attachments

    MoFo22, Apr 15, 2004, in forum: ASP General
    Replies:
    1
    Views:
    203
    Ray at
    Apr 16, 2004
  5. Naveen Jain
    Replies:
    1
    Views:
    151
    Anthony Jones
    Jul 17, 2006
Loading...

Share This Page