|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
writing to a file attachment
I have a form which takes user data and adds it to a database, as well as generating emails to the system admins, the requesting person's manager, and back to the requester themself, which all works fine. My problem now is that I need to add a file attachment of another form to send in the email to the requesting user only. If possible, I want to capture some of the fields from the form being filled out to put in some of the blanks on this attached file. (the user then prints the file and finishes it themself).
1. What command do I use to attach the file? There is a line in the mailer object that says Quote:
which seems like it should attach something, but doesn't seem to do anything. Is this the right command, if I change the path to be my file? 2. Can I write the fields from the form to the attached file (before or after attaching it) somehow? Thanks for any help |
|
#2
|
|||
|
|||
|
ok
First thing I need to ask is:
The *file* in question that you would like to attach to the email, is it a file that the *user* *uploaded*? O R Is it a *file* that is stored somewhere on the web server? O R Are you *constructing* a file based on what's inside your <form>...</form> and *then* you decide to attach that file inside the email? As for your question 1) I'd try searching google.com for any *code example* on how to attach a file using CDO(I'm sure there is plenty of examples out there). Or read the documentation, if any, of the component. Then you say: ---BEGIN QUOTE--- I want to capture some of the fields from the form being filled out to put in some of the blanks on this attached file ---END QUOTE--- My question is: Do you want to *add* the fields from the <form>...</form> to the *inside* of the file O R Do you want to *add* the fields from the <form>...</form> to the *BODY* of the email message? These are two different things, attaching a file is one thing and creating the *body* of the email is another! Hope this helps! Sincerely Vlince Last edited by Vlince : June 19th, 2003 at 12:12 PM. |
|
#3
|
||||
|
||||
|
The file in question is not uploaded by the user, it is a separate file stored on the server. It might also be possible to create it based on the content of the <form></form>, but the former is preferrable.
As for #1, Quote:
is the attach part. In reply to Quote:
I want to *add* the contents to the *inside* of the file. I already have the body of the email made, and know how to do that part. Its the adding that I'm having trouble with thanks |
|
#4
|
|||
|
|||
|
You must use
FSO(File System Object) in order to append data to an existing file.
But one thing I'm *not* sure about is that you might only be able to append the data *at the end of the document*. I'm not sure if, for instance, you can add data let's say in the middle of your existing file. You'll have to check. One work around would be to read the entire content of the file into a variable, then append the data you want where you want it and only then reconstruct the file. From there attach the file in question. Also, if the file you want to attach will always be the same file(kinda like a template) you *could* create your/some predefine <tags> inside your template for example: <##FirstName##> <##LastName##> You save your file with those <tags> and from within your asp code simply use the Replace() function...that could be an idea? no? I'll/you'll have to check to see if we can append data in the middle/beginning/end of the file OR is it simply at the end. Hope this helps! Sincerely Vlince |
|
#5
|
||||
|
||||
|
Its definitely more to go on than i had before. The file will indeed be the same each time, so the <tags> should work. Thanks a lot
|
|
#6
|
||||
|
||||
|
Um, one more thing I guess. The MyCDO.AttachFile = "e:\files\catalog.zip"
does not seem to actually attach a file when i change the path. Does this mean it is the wrong thing, or that the attached file needs to be on the server and/or in the same directory as the web page? |
|
#7
|
|||
|
|||
|
Didn't *you* say the file was *on* the server ?
I hope, otherwise it might be somewhere in a back alley of a Hong Kong's fisherman shop and we wouldn't want that now would we? No offense to anyone </shrug>Did you try the google.com search engine for any example of attaching a file using CDO? Perhaps it needs a *virtual* path as opposed to a *physical* path. I'd check the docs on that. sorry I don't know it by heart ![]() Hope this helps! Sincerely Vlince |
|
#8
|
||||
|
||||
|
It helps
thanks |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > writing to a file attachment |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|