Chilkat Examples

ChilkatHOMEAndroid™Classic ASPCC++C#Mono C#.NET Core C#C# UWP/WinRTDataFlexDelphi ActiveXDelphi DLLVisual FoxProJavaLianjaMFCObjective-CPerlPHP ActiveXPHP ExtensionPowerBuilderPowerShellPureBasicPythonRubySQL ServerSwiftTclUnicode CUnicode C++Visual Basic 6.0VB.NETVB.NET UWP/WinRTVBScriptXojo PluginNode.jsExcel

Swift Examples

ASN.1
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Service Bus
Bounced Email
CSV
Certificates
Compression
DKIM / DomainKey
DSA
Diffie-Hellman
Digital Signatures
Dropbox
ECC
Email Object
Encryption
FTP
Facebook
Firebase
GeoOp
Google APIs
Google Cloud Storage
Google Drive
Gzip
HTML-to-XML/Text
HTTP
HTTP Misc

IMAP
JSON
Java KeyStore (JKS)
Jwt
MHT / HTML Email
MIME
NTLM
OAuth1
OAuth2
OpenSSL
PEM
PFX/P12
POP3
PRNG
PayPal
Peoplevox
QuickBooks
REST
RSA Encryption
SCP
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
Socket/SSL/TLS
Spider
Stream
Tar Archive
Twitter
XML
XMP
Xero
Zip
curl

 

 

 

(Swift) Save Email Attachments to Filesystem

Saves email attachments to a directory.

Chilkat Downloads for the Swift Programming Language

MAC OS X (Cocoa) Objective-C/Swift Libs

iOS Objective-C/Swift Libs

func chilkatTest() {

    let email = CkoEmail()

    //  Load an email object containing attachments.
    //  This .eml can be downloaded from:
    //  http://www.example-code.com/testData/HtmlEmail.eml
    var success: Bool
    success = email.LoadEml("HtmlEmail.eml")
    if success != true {
        print("\(email.LastErrorText)")
        return
    }

    //  If OverwriteExisting is turned on, files with the same
    //  name are overwritten.  If turned off, new/unique filenames
    //  are automatically generated.  The filenames actually saved
    //  are accessible via the GetAttachmentFilename method.
    email.OverwriteExisting = true

    //  Save all attachments to the "myAttachments" subdirectory
    //  found under the calling process's current working directory.
    //  This directory is automatically created if it does not already
    //  exist.
    success = email.SaveAllAttachments("myAttachments")
    if success != true {
        print("\(email.LastErrorText)")
        return
    }

    //  List the attachment filenames:
    var i: Int
    for i = 0; i <= email.NumAttachments.integerValue - 1; i++ {
        print("\(email.GetAttachmentFilename(i))")
    }


}

 

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