Attachment Object

The Attachment object provides access to properties of a single attachment to a message and includes methods to save the attachment to a disk file.

Syntax

Attachment.property|method

 

Properties
Content Binary content of the attachment as String.
ContentAsArray Binary content of the attachment as Byte Array.
ContentDisposition The Content-Disposition value taken from the attachment header.
ContentID The Content-ID value taken from the attachment header.
ContentLocation The Content-Location value taken from the attachment header.
Content-Type The Content-Type value taken from the attachment header.
Filename The filename of the attachment, or an autogenerated name if the attachment has no name.
FilenameAsIs The filename of the attachment, or an empty string if the attachment has no name.
IsInline Indicates whether the attachment is an inline object (such as embedded picture).
IsMessage Indicates whether the attachment contains another e-mail message (such as forwarded message).
Size The size of the attachment's binary content in bytes.
Methods
SaveFile Saves the attachment to disk.

 

Example

The following example retrieves a message from the server and saves all of the attachments found in the message into a disk folder.
Dim objPOP3, objMsg, objAttach

' Using Visual Basic to create object
Set objPOP3 = CreateObject("MailBee.POP3")

' Using ASP to create object
' Set objPOP3 = Server.CreateObject("MailBee.POP3")
'
' In ASP, use Response.Write instead of MsgBox

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

 

See Also

Attachments Collection

 


Send feedback to AfterLogic
Copyright © 2002-2022, AfterLogic Corporation. All rights reserved.