将用户图像附加到电子邮件
我正在尝试创建一个应用程序,用户可以在其中发送带有他们选择的图像附件的电子邮件,我已经使用Uitextfield进行了此操作。文本字段中的用户类型的内容也包含在电子邮件中。
我的代码如下:
@IBOutlet var fullName: UITextField!
@IBOutlet var latestPayslip: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
let tap = UITapGestureRecognizer(target: self, action: #selector(UIInputViewController.dismissKeyboard))
view.addGestureRecognizer(tap)
// Do any additional setup after loading the view.
fullName.addToolBar()
fullName.delegate = self
}
@IBAction func sendEmail(_ sender: Any) {
if MFMailComposeViewController.canSendMail() {
let mail = MFMailComposeViewController()
let emailFullName: String = fullName.text!
mail.mailComposeDelegate = self
mail.setToRecipients([“[email protected]"])
mail.setMessageBody("<p>FullName: \(emailFullName)</p>", isHTML: true)
mail.setSubject("Application for RTO: ")
present(mail, animated: true)
}
}
private lazy var primaryTextFields: [UITextField] = {
[fullName]
}()
@objc func dismissKeyboard() {
//Causes the view (or one of its embedded text fields) to resign the first responder status.
view.endEditing(true)
}
}
I'm trying to create an app whereby the user can send an email with an image attachment of their choice, I've done this so far with UITextfield. What ever the user types in the Text Field it is also included in the email.
My code is as follows:
@IBOutlet var fullName: UITextField!
@IBOutlet var latestPayslip: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
let tap = UITapGestureRecognizer(target: self, action: #selector(UIInputViewController.dismissKeyboard))
view.addGestureRecognizer(tap)
// Do any additional setup after loading the view.
fullName.addToolBar()
fullName.delegate = self
}
@IBAction func sendEmail(_ sender: Any) {
if MFMailComposeViewController.canSendMail() {
let mail = MFMailComposeViewController()
let emailFullName: String = fullName.text!
mail.mailComposeDelegate = self
mail.setToRecipients([“[email protected]"])
mail.setMessageBody("<p>FullName: \(emailFullName)</p>", isHTML: true)
mail.setSubject("Application for RTO: ")
present(mail, animated: true)
}
}
private lazy var primaryTextFields: [UITextField] = {
[fullName]
}()
@objc func dismissKeyboard() {
//Causes the view (or one of its embedded text fields) to resign the first responder status.
view.endEditing(true)
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论