Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 29762

How can I send image as an attachment to the email in amazon ses sdk?

$
0
0

I have used amazon ses sdk in my iOS app to send emails. I have successfully sent the email using the below code but now I have to send 2 images with the email as attachments and I have searched a lot on the internet regarding this but not able to find any solution. Can anyone help me to solve this issue.

let subject : AWSSESContent = AWSSESContent()
subject.data = "Test email from demo app"

let messageBody : AWSSESContent = AWSSESContent()
messageBody.data = data

let emailBody : AWSSESBody = AWSSESBody()
emailBody.text = messageBody

let message : AWSSESMessage = AWSSESMessage()
message.subject = subject
message.body = emailBody

let destination : AWSSESDestination = AWSSESDestination()
destination.toAddresses = ["xxxx.com"]

let sendRequest : AWSSESSendEmailRequest = AWSSESSendEmailRequest()
sendRequest.source = "yyyy.com"
sendRequest.destination = destination
sendRequest.message = message

AWSSES
    .default()
    .sendEmail(sendRequest)
    .continueOnSuccessWith { (task) -> Any? in
        print(task.result as AnyObject)
    }
    .continueWith { (task) -> Any? in
        if task.error != nil {
            print("Error sending email")
           let type : String? = (task.error! as NSError).userInfo["Type"] as? String
            print("Type   : \(type!)")

            let message : String? = (task.error! as NSError).userInfo["Message"] as? String
            print("Message: \(message!)")

            var code : String? = (task.error! as NSError).userInfo["Code"] as? String
            code = (code != nil ? code : "Unknown")
            print("Code   : \(code!)")
        }
        return nil
    }

Viewing all articles
Browse latest Browse all 29762

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>