Unable to set the body of outlook mail using the UIActivityViewController in SWIFTUI

Viewed 22

I had created an attributed string and want to share over the different sharing apps available, It works fine with all other apps but it doesnt set the body in outlook app. it works fine with even Gmail , anything specific do we need to for outlook?

Button("Share") {
                    let pasteBoard = UIPasteboard.general
                    pasteBoard.set(attributedString: dataSource.attributeString)
                        print("HELLO")
                    print(dataSource.attributeString)
                    let activityViewController: UIActivityViewController = UIActivityViewController(activityItems: [dataSource.attributeString], applicationActivities: nil)
                    
                    if let viewController = UIApplication.shared.windows.first?.rootViewController {
                        activityViewController.popoverPresentationController?.sourceView = viewController.view
                        
                        activityViewController.popoverPresentationController?.sourceRect =  CGRect(x: UIScreen.main.bounds.width * 0.5 - 200, y: UIScreen.main.bounds.height * 0.5 - 100, width: 400, height: 200)
                        
                      //  activityViewController.popoverPresentationController?.sourceRect = CGRect(x:viewController.view.center.x, y: viewController.view.center.y, width: 0, height: 0)
                        
                    }
                    activityViewController.setValue("", forKey: "Subject")
                    activityViewController.setValue("", forKey: "subject")
                    UIApplication.shared.windows.first?.rootViewController?.presentedViewController?.present(activityViewController, animated: true, completion: nil)
0 Answers
Related