Author |
|
nwebster Newbie
Joined: 12 April 2005 Location: United States
Online Status: Offline Posts: 9
|
Posted: 19 April 2005 at 9:38am | IP Logged
|
|
|
I am trying to save attachments in 2 different ways, but it's not quite working. Can you point out the problem with this?
First I try and save the first file attached like this:
(Filename is name of first attached file, otherwise I store "0" for DB purposes)
If FileName <> "0" Then
Dim FilePath As String = "C:\ServerFolder\"
Dim MyName As String = Dir(FilePath, vbDirectory) ' Retrieve the first entry.
If MyName = "" Then ' The folder is not there & to be created
MkDir(FilePath) 'Folder created
End If
FilePath = FilePath & FileName
' Let us Save uploaded file to server at C:\ServerFolder\
Try
oMsg.Attachments(1).SaveFile(FilePath)
Catch Exp As Exception
End Try
End If
And then for the rest of the files (it is broken up for some other DB workings):
For j = 2 To AttachmentCount
FileName = oMsg.Attachments(j).filename
If FileName <> "0" Then
Dim FilePath As String = "C:\ServerFolder\"
Dim MyName As String = Dir(FilePath, vbDirectory) ' Retrieve the first entry.
If MyName = "" Then ' The folder is not there & to be created
MkDir(FilePath) 'Folder created
End If
FilePath = FilePath & FileName
' Let us Save uploaded file to server at C:\ServerFolder\
Try
oMsg.Attachments(j).SaveFile(FilePath)
Catch Exp As Exception
End Try
End If
Next
The directories are created file, but the files aren't being uploaded to it. I also tried using oAttach.SaveFile(Filepath) but with the same results.
|
Back to Top |
|
|
Alex AfterLogic Support
Joined: 19 November 2003
Online Status: Offline Posts: 2206
|
Posted: 19 April 2005 at 9:51am | IP Logged
|
|
|
SaveFile method is declared as follows:
Code:
blnResult = ObjectName.SaveFile(DirPath, [Filename]) |
|
|
Please note that first parameter is directory path, not file path. This is because filename is already known, only directory name needed (if you want to save file under different name, just use both parameters: DirPath and Filename).
From the above, the following line must be removed from your code:
Code:
FilePath = FilePath & FileName |
|
|
Regards,
Alex
|
Back to Top |
|
|
nwebster Newbie
Joined: 12 April 2005 Location: United States
Online Status: Offline Posts: 9
|
Posted: 19 April 2005 at 10:06am | IP Logged
|
|
|
That did it, Thanks!
|
Back to Top |
|
|