Search The ForumSearch   RegisterRegister  LoginLogin

MailBee POP3

 AfterLogic Forum : MailBee POP3
Subject Topic: Save attachments Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
nwebster
Newbie
Newbie


Joined: 12 April 2005
Location: United States
Online Status: Offline
Posts: 9
Posted: 19 April 2005 at 9:38am | IP Logged Quote nwebster

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 View nwebster's Profile Search for other posts by nwebster
 
Alex
AfterLogic Support
AfterLogic Support
Avatar

Joined: 19 November 2003
Online Status: Offline
Posts: 2206
Posted: 19 April 2005 at 9:51am | IP Logged Quote Alex

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 View Alex's Profile Search for other posts by Alex
 
nwebster
Newbie
Newbie


Joined: 12 April 2005
Location: United States
Online Status: Offline
Posts: 9
Posted: 19 April 2005 at 10:06am | IP Logged Quote nwebster

That did it, Thanks!
Back to Top View nwebster's Profile Search for other posts by nwebster
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump

Powered by Web Wiz Forums version 7.9
Copyright ©2001-2004 Web Wiz Guide