Forum Moderators: phranque

Message Too Old, No Replies

ASP cdosys addattachment

         

crooky

4:34 pm on May 5, 2006 (gmt 0)

10+ Year Member



Hi all,

I have successfully managed to create a form where the user can browse their own PC and then select a file. When the form is submitted the file is temporarily uploaded to the webserver using aspupload and the email message is sent to the recipient along with the attachment which is then deleted from the server and the user is redirected to a thankyou page.

So, what's the problem I hear you say? Well, the sending of an attachment is optional, therefore when I try to submit the form without a file for uploading I get a "page cannot be displayed" error. The email still gets sent - but the error means the user isn't redirected to the thankyou page.

I am using cdosys to send the email. The problem is obviously created when the addattachment line is reached. I have tried using an If statement with Count e.g. If a file is attached Count has a value of 1 with no file Count has a value of 0.

If Count == 1 Then
objMessage.addattachment(g:\ etc, etc.
End If

My hope was that if Count == 0 then it would just skip over this line but this too throws an error.

Any help/advice would be greatly appreciated.
Just when you think you've cracked it, there's something else to fix!

BananaFish

5:01 pm on May 8, 2006 (gmt 0)

10+ Year Member



Is this VB script, = is equivalent to ==. It won't understand the latter.

crooky

5:21 pm on May 8, 2006 (gmt 0)

10+ Year Member



Hi Bananafish

Yes it is VB so you are correct. I just used <> 1 instead and it worked but I'll go back and change it.

Thanks for your reponse.

Regards

crooky