Author |
|
Guests Guest Group
Joined: 10 November 2003
Online Status: Online Posts: 262
|
Posted: 08 June 2004 at 1:52pm | IP Logged
|
|
|
I need to create a very simple app. I want to check one mailbox that will have PDFs and Word docs attached to messages. Is there a way to know what the attachment's filename is so that it can be saved with the correct name/extension?
|
Back to Top |
|
|
Alex AfterLogic Support
Joined: 19 November 2003
Online Status: Offline Posts: 2206
|
Posted: 08 June 2004 at 2:15pm | IP Logged
|
|
|
Yes, MailBee.Attachment object provides Filename property which returns you filename of the attachment.
Also, you can use Attachment.SaveFile method to save the attachment into any folder under the attachment's real name.
The following example retrieves a message from the server and saves all of the attachments found in the message into a disk folder. All attachments are saved under their real names.
Dim objPOP3, objMsg, objAttach
Set objPOP3 = CreateObject("MailBee.POP3")
objPOP3.LicenseKey = "put your license key here"
' Connect to the server
If objPOP3.Connect("mail.server.com", 110, "jdoe", "secret") Then
' Retrieve first message
Set objMsg = objPOP3.RetrieveSingleMessage(1)
If objPOP3.IsError Then
' Check for errors
MsgBox "Error #" & objPOP3.ErrCode
Else
' Iterate through all of the attachments
For Each objAttach In objMsg.Attachments
' Save each attachment to disk
If Not objAttach.SaveFile("C:\Attachments") Then
MsgBox "Could not save a file"
End If
Next
End If
' Disconnect when finished
objPOP3.Disconnect
End If
|
Back to Top |
|
|