How can I send attributed string via Email?
mailComposerVC.setMessageBody(textView.attributedString, isHTML: false)
How can I send attributed string via Email?
mailComposerVC.setMessageBody(textView.attributedString, isHTML: false)
Updated to swift 5 Xcode 12.1
var cookedString : String!
let attributeString = myTextView.attributedText
let documentAttributes = [NSAttributedString.DocumentAttributeKey.documentType: NSAttributedString.DocumentType.html]
do
{
let htmlData = try attributeString!.data(from: NSMakeRange(0, attributeStrung!.length), documentAttributes: documentAttributes)
if let htmlString = String(data: htmlData, encoding: String.Encoding.utf8)
{
cookedString = htmlString
}
}
catch
{
print("error creating HTML from Attributed String")
} let mailComposerVC = MFMailComposeViewController()
mailComposerVC.mailComposeDelegate = self
mailComposerVC.setMessageBody(cookedString, isHTML: true)