Search The ForumSearch   RegisterRegister  LoginLogin

MailBee POP3

 AfterLogic Forum : MailBee POP3
Subject Topic: save as Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
itzik
Guest Group
Guest Group


Joined: 10 November 2003
Online Status: Online
Posts: 262
Posted: 05 June 2005 at 7:45am | IP Logged Quote itzik

Hi,

I saw your saving sample, but, I want to let my clients to save the attachment where ever they want, please show me a code of 'save as' for attachment .

Thanks,
Itzik
Back to Top View itzik's Profile Search for other posts by itzik
 
Alex
AfterLogic Support
AfterLogic Support
Avatar

Joined: 19 November 2003
Online Status: Offline
Posts: 2206
Posted: 05 June 2005 at 8:58am | IP Logged Quote Alex

If you have Msg object of Message type (for example, received from POP3 object) you can save all attachments into temporary directory and then print links to the saved files. There are many ways to do this and they are more related to ASP programming, not MailBee. As for simplest implementation, you can save all attachments into certain folder and generate links for accessing them using the code like below:

Code:

For Each Attach In Msg.Attachments
  Attach.SaveFile "C:\wwwroot\data\folder"
  Response.Write "<a href='/data/folder/" & Attach.Filename & "'>" & Attach.Filename & "</a><br>"
Next


It's assumed "C:\wwwroot" is physical path to web root.

For more complex scenarios, you can use special ASP script which will download files to the client's browser. Attachments are saved in the same manner, the only difference is how they are accessed for download.

Attachments saving and links generation
Code:

For Each Attach In Msg.Attachments
  Attach.SaveFile "C:\wwwroot\data\folder"
  Response.Write "<a href='download.asp?dir_id=folder&file_id=" & Attach.Filename & "'>" & Attach.Filename & "</a><br>"
Next


Downloader script (download.asp):
Code:

' Always display file saving dialog
Response.AddHeader "Content-Disposition", "attachment; filename=" & Request("file_id")

Dim Msg

' Create MailBee.Message object
Set Msg = Server.CreateObject("MailBee.Message")

' Download file contents
Response.BinaryWrite Msg.GetFileAsArray("c:\wwwroot\data\" & _
  Request("dir_id") & "\" & Request("file_id"))


Using downloader script has many advantages, including the following:
1. You can display file saving dialog even for gif, jpeg, and other pre-registered files types. Without downloader script, these attachments are opened in graphics viewing program.

2. You can store temporary folder outside of wwwroot (so that temporary folder would not be mapped to web server's virtual space). This is more secure since you can add check Session for specific user_id and do not allow unauthorized access for non-logged users.

Regards,
Alex
Back to Top View Alex's Profile Search for other posts by Alex
 

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