Search The ForumSearch   RegisterRegister  LoginLogin

MailBee POP3

 AfterLogic Forum : MailBee POP3
Subject Topic: Saving Email Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
Guests
Guest Group
Guest Group


Joined: 10 November 2003
Online Status: Online
Posts: 262
Posted: 08 September 2005 at 10:43am | IP Logged Quote Guests

I need to save the emails that come into my app. How does this tool do that?
Back to Top View Guests's Profile Search for other posts by Guests
 
Alex
AfterLogic Support
AfterLogic Support
Avatar

Joined: 19 November 2003
Online Status: Offline
Posts: 2206
Posted: 08 September 2005 at 12:22pm | IP Logged Quote Alex

You can use SaveMessage method of Message object for this.

Code:

Dim Mailer, Msg
Set Mailer = CreateObject("MailBee.POP3")
Mailer.LicenseKey = "put your license key here"
If Mailer.Connect("mail.server.com", 110, "MyName", "MyPassword") Then
   If Mailer.MessageCount > 0 Then
      Set Msg = Mailer.RetrieveSingleMessage(1)
      If Not Msg Is Nothing Then
        Msg.SaveMessage "C:\Docs\msg.eml"
      End If
   End If
   Mailer.Disconnect
End If


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


Joined: 10 November 2003
Online Status: Online
Posts: 262
Posted: 16 February 2006 at 5:21am | IP Logged Quote teksait

it doesn't works me. I have all permisions in the folder specified and the code y the following:
<code>
Dim Mailer, Msg
Set Mailer = CreateObject("MailBee.IMAP4")
Mailer.LicenseKey = "###"
Mailer.Connect "mail.server.com", 143, session("usermail"), session("pasmai")

If Mailer.Connected Then
If Mailer.SelectMailbox(request.querystring("f")) Then
    Set Msg = Mailer.RetrieveSingleMessage(request.querystring("id"),false )
    Msg.SaveMessage "c:\demo.eml"
    response.write(msg.subject)
end if
Mailer.Disconnect
End If
</code>

querystring("f") = "INBOX"
querystring("id") = 1 (number of the message)

And finally, when i run the script i haven't got any error and msg.subject is printed in the screen, but there aren't any EML file in the path specified. WHY? Pliz help me!
Back to Top View teksait's Profile Search for other posts by teksait
 
Alex
AfterLogic Support
AfterLogic Support
Avatar

Joined: 19 November 2003
Online Status: Offline
Posts: 2206
Posted: 16 February 2006 at 10:13am | IP Logged Quote Alex

Message.SaveMessage method returns boolean value that is "true" if operation has been completed successfully and "false" otherwise.

Instead of .SaveMessage method call, you can also save message to disk by writing Message.RawBody string into a file (for instance, using FileSystemObject). This way, you'll have more information why the file could not be written because FileSystemObject throws an exception on error:

Code:

' Assume Msg is a Message object to be saved
Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set f = fso.CreateTextFile("c:\demo.eml")
f.Write Msg.RawBody
f.Close


You can also import a mail message from a file using the same approach:
- either via Message.ImportFromFile method which returns True or False as result
- or via FileSystemObject (useful if you want to debug why exactly the message does not load):
Code:

Set Msg = Server.CreateObject("MailBee.Message")
Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile("C:\demo.eml")
Msg.RawBody = f.ReadAll
f.Close


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