Author |
|
noamway Newbie
Joined: 24 May 2007
Online Status: Offline Posts: 15
|
Posted: 25 May 2007 at 2:31am | IP Logged
|
|
|
I get the file size and is name, I check the path and is ok too, it's only don't want to sace the file in the server (I make all the
permit for saving)
Set Attachments = objMsgs.Attachments
For i = 0 To Attachments.Count - 1
Set at = Attachments(i)
file &n bsp; &n bsp;= at.Filename
fileSizeNUM & nbsp; = at.Size
path &n bsp; &n bsp;= filesys.GetAbsolutePathName(server.mappath("/image/bizzzzz/" )&"/"&file)
If Not at.SaveFile(path) Then response.write "<br>I/O Error" End If
set at &nbs p; = nothing
Next
set Attachments & nbsp; = nothing
|
Back to Top |
|
|
Andrew AfterLogic Support
Joined: 28 April 2006 Location: United States
Online Status: Offline Posts: 1189
|
Posted: 25 May 2007 at 3:33am | IP Logged
|
|
|
As described in MailBee Objects documentation, SaveFile method requires two parameters: path to the directory and optional filename. So, you should modify your source code as follows:
Code:
Set Attachments = objMsgs.Attachments
For i = 0 To Attachments.Count - 1
Set at = Attachments(i)
file = at.Filename
fileSizeNUM = at.Size
path = filesys.GetAbsolutePathName(server.mappath("/image/bizzzzz/" ))
If Not at.SaveFile(path, file) Then response.write "<br>I/O Error" End If
set at = nothing
Next
set Attachments = nothing
|
|
|
Best regards,
Andrew
|
Back to Top |
|
|
noamway Newbie
Joined: 24 May 2007
Online Status: Offline Posts: 15
|
Posted: 25 May 2007 at 1:35pm | IP Logged
|
|
|
I think you wrong:
1. In your documentation you wrote this:
If Not Attach.SaveFile ("C:\Data Files") Then MsgBox "I/O Error"
There is no two parameters there.
2. I try what you say and I still can't save the file.
|
Back to Top |
|
|
Alex AfterLogic Support
Joined: 19 November 2003
Online Status: Offline Posts: 2206
|
Posted: 25 May 2007 at 2:36pm | IP Logged
|
|
|
If you read Andrew's posting again, you'll find that Attach.SaveFile indeed accepts two parameters, the second parameter is optional. However, it's not always possible to determine it. For instance, the filename can be empty. In this case, you should check if Filename is not empty and invent your own filename if there had been none in the attachment.
Anyway, you can save the file using FileSystemObject. Unlike Attach.SaveFile, FileSystemObject throws an exception rather than returns False in the case of failure. With FileSystemObject and additional information available in exception details, you'll be able to find out what's wrong with the code. For instance, in your code you try to save your file into a folder passing your filename as a folder name. If you wish to save your file using absolute path to the file, not to the folder, this is another reason to use FileSystemObject. But remember to check if Attach.Filename is empty and generate your own name in this case.
Code:
Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set f = fso.CreateTextFile(path_where_to_save_file)
f.Write Attach.Content
f.Close
|
|
|
Regards,
Alex
|
Back to Top |
|
|
noamway Newbie
Joined: 24 May 2007
Online Status: Offline Posts: 15
|
Posted: 25 May 2007 at 4:06pm | IP Logged
|
|
|
Hi Alex,
In FSO it's working well and I check the "Attach.Filename" and he have a name.
So I don't understand why this is not working:
Attach.SaveFile
|
Back to Top |
|
|
Andrew AfterLogic Support
Joined: 28 April 2006 Location: United States
Online Status: Offline Posts: 1189
|
Posted: 26 May 2007 at 4:02am | IP Logged
|
|
|
The following sample saves two copies of the same attachment through SaveFile and FileSystemObject with different filename prefixes:
Code:
Set Attachments = objMsgs.Attachments
For i = 0 To Attachments.Count - 1
Set at = Attachments(i)
file = at.Filename
If Len(file) > 0 Then
fileSizeNUM = at.Size
path = filesys.GetAbsolutePathName(server.mappath("/image/bizzzzz/" ))
' Save the file through SaveFile
If Not at.SaveFile(path, "SaveFile_" & file) Then response.write "<br>I/O Error" End If
' Save the file through FileSystemObject to the same location
Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set f = fso.CreateTextFile(path & "\FSO_" & file)
f.Write at.Content
f.Close
Else
response.write "<br>Filename is empty"
End If
set at = nothing
Next
set Attachments = nothing |
|
|
Does this sample save both the files (with SaveFile_ and FSO_ pefixes) for you?
Best regards,
Andrew
|
Back to Top |
|
|
noamway Newbie
Joined: 24 May 2007
Online Status: Offline Posts: 15
|
Posted: 27 May 2007 at 5:31pm | IP Logged
|
|
|
I'm sorry but it's still not working. with FSO it's save but with SaveFile it's not
|
Back to Top |
|
|
noamway Newbie
Joined: 24 May 2007
Online Status: Offline Posts: 15
|
Posted: 27 May 2007 at 5:33pm | IP Logged
|
|
|
OK, you right, it's working fine :-)
Thanks for your help
|
Back to Top |
|
|