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
}