| Author |  | 
      
        | Guests Guest Group
 
  
 
 Joined: 10 November 2003
 Online Status: Online
 Posts: 262
 | 
          I need to save the emails that come into my app. How does this tool do that?
           | Posted: 08 September 2005 at 10:43am | IP Logged |   |  
           | 
 |  | 
       
        | Back to Top |     | 
       
       
        |  | 
        | Alex AfterLogic Support
 
  
  
 Joined: 19 November 2003
 Online Status: Offline
 Posts: 2207
 | 
          You can use SaveMessage method of Message object for this.
           | Posted: 08 September 2005 at 12:22pm | IP Logged |   |  
           | 
 |  
 
 
| 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 |     | 
       
       
        |  | 
        | teksait Guest Group
 
  
 
 Joined: 10 November 2003
 Online Status: Online
 Posts: 262
 | 
          it doesn't works me. I have all permisions in the folder specified and the code y the following:
           | Posted: 16 February 2006 at 5:21am | IP Logged |   |  
           | 
 |  <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 |     | 
       
       
        |  | 
        | Alex AfterLogic Support
 
  
  
 Joined: 19 November 2003
 Online Status: Offline
 Posts: 2207
 | 
          Message.SaveMessage method returns boolean value that is "true" if operation has been completed successfully and "false" otherwise.
           | Posted: 16 February 2006 at 10:13am | IP Logged |   |  
           | 
 |  
 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 |     | 
       
       
        |  |