FoxPro Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript

Visual FoxPro Examples

Bounced Mail
Bz2
Character Encoding
CSV
Digital Certificates
Digital Signatures
Email
FTP
HTML-to-XML
HTTP
IMAP
Encryption
MHT / HTML Email
POP3
RSA
S/MIME
Socket
Spider
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
String
Tar
Upload
XML
XMP
Zip Compression
Self-Extractor

More Examples...
Email Object
DKIM / DomainKey
NTLM
RSS
Atom
Byte Array
Service
PPMD
Deflate
DH Key Exchange
DSA
FileAccess
Bzip2
LZW

 

Non-Chilkat Links
Text and String Handling

Download and Save Email Attachments (POP3)

Downloads emails from a POP3 mailbox and saves all attachments.

Download Chilkat Email ActiveX for POP3 / SMTP

LOCAL loMailman
LOCAL lnSuccess
LOCAL loBundle
LOCAL lcDirPath
LOCAL i
LOCAL loEmail
LOCAL n
LOCAL j

*  The mailman object is used for receiving (POP3)
*  and sending (SMTP) email.
loMailman = CreateObject('Chilkat.MailMan2')

*  Any string argument automatically begins the 30-day trial.

lnSuccess = loMailman.UnlockComponent("30-day trial")
IF (lnSuccess <> 1) THEN
    =MESSAGEBOX("Component unlock failed")
    QUIT
ENDIF

*  Set the POP3 server's hostname
loMailman.MailHost = "mail.chilkatsoft.com"

*  Set the POP3 login/password.
loMailman.PopUsername = "***"
loMailman.PopPassword = "***"

*  Copy the all email from the user's POP3 mailbox
*  into a bundle object.  The email remains on the server.
loBundle = loMailman.CopyMail()

IF (loBundle = NULL ) THEN
    =MESSAGEBOX(loMailman.LastErrorText)
    QUIT
ENDIF

lcDirPath = "c:/myAttachments"

FOR i = 0 TO loBundle.MessageCount - 1
    loEmail = loBundle.GetEmail(i)

    *  You may save all the attachments to the specified directory
    *  by calling SaveAllAttachments.
    *  The SaveAllAttachments method will automatically create the directory
    *  if it does not already exist.
    lnSuccess = loEmail.SaveAllAttachments(lcDirPath)
    IF (lnSuccess <> 1) THEN
        =MESSAGEBOX(loEmail.LastErrorText)
        QUIT
    ENDIF

    *  The OverwriteExisting property controls whether already-existing files
    *  are automatically overwritten.  By default, it is set to 1 so that existing
    *  files will be overwritten.

    *  Setting OverwriteExisting = 0 will cause the attachment-saving methods to generate
    *  unique filenames if a file with the same name already exists.  The actual filename(s)
    *  saved will be present by calling GetAttachmentFilename for each attachment *after*
    *  saving.
    *  For example...
    loEmail.OverwriteExisting = 0
    lnSuccess = loEmail.SaveAllAttachments(lcDirPath)
    IF (lnSuccess <> 1) THEN
        =MESSAGEBOX(loEmail.LastErrorText)
        QUIT
    ENDIF

    n = loEmail.NumAttachments

    FOR j = 0 TO n - 1
        *  If the attachment filename was changed to prevent overwriting,
        *  GetAttachmentFilename will return the new filename.
        ? loEmail.GetAttachmentFilename(j)
    NEXT

    *  You may also save individual attachments:
    FOR j = 0 TO n - 1

        ? "Original Filename: " + loEmail.GetAttachmentFilename(j)
        lnSuccess = loEmail.SaveAttachedFile(j,lcDirPath)
        IF (lnSuccess <> 1) THEN
            =MESSAGEBOX(loEmail.LastErrorText)
            QUIT
        ENDIF

        *  If OverwriteExisting = 1, the saved filename will always equal the original filename,
        *  unless there are characters present in the filename that are not allowed by Windows,
        *  such as * ? < > | etc.  In those cases the illegal characters are either removed or replaced
        *  with underscore characters to allow the file to be saved.
        ? "Saved Filename: " + loEmail.GetAttachmentFilename(j)
    NEXT
    RELEASE loEmail
NEXT

RELEASE loBundle

Need a specific example? Send a request to support@chilkatsoft.com

© 2000-2010 Chilkat Software, Inc. All Rights Reserved.

Mail Component · .NET Email Component · ASP Mail Component · XML Parser