I have opened the outlook app and send a file in it. I am able to open the outlook and set the To,Subject and Body but not sure how to attach file in the document directory The file is at path
var paths = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)
let documentsDirectory = paths[0]
let fileName = "supportdata.log"
let logFilePath = (documentsDirectory as NSString).appendingPathComponent(fileName)
let scheme : String = "ms-outlook://[email protected]&subject=Support data &body=Please find the attached file"
if let url = URL(string: scheme) {
UIApplication.shared.open(url, options: [:], completionHandler: {
(success) in
if (success)
{
print("Open \(scheme): \(success)")
}
})
}
Attach a file to a message Create a message, or for an existing message, click Reply, Reply All, or Forward. In the message window, on the Message tab, in the Include group, click Attach File. Browse to and click the file that you want to attach, and then click Insert.
Attach a file In a new email or a reply, tap the paperclip icon and then Attach file. Tap See All and select a file. Choose a file and then tap Insert OneDrive for Business Link.
You can open an attachment from the Reading Pane or from an open message. In either case, double-click the attachment to open it. To open an attachment from the message list, right-click the message that has the attachment, click View Attachments, and then click the name of the attachment.
Sadly, it is not possible. There are two main issues:
You are deeplinking to an app, meaning sending an on-device message to another app that is effectively the same as a normal URI with a GET method parameterized string. String only, no major data/files can be sent. The URL Scheme below is for reference. And it is the same as what you're using; though I think you are missing an '=' in your ms-outlook:// string.
ms-outlook://compose?to=%@&subject=%@&body=%@
iOS is pretty strict with app sandboxes, you cannot pass local files to other apps unless they are on the same app/file domain (e.g. you're the owner of both apps). There are a few alternatives that work in a watered-down format, but are not relevant for this scenario. Here's the thing, even if you could, Microsoft would need to support this file attachment feature, which it doesn't. Sadly, there's nothing we can do about it on our side... other than asking Microsoft to add the feature.
However, if you want to do this in the apple mail app, that's certainly doable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With