Tech-Today


Send Email using MFMailComposer (Template)

1.) Import MessageUI
      import MessageUI

2.) Show Email
func showMail() {
let mailComposeViewController = configuredMailComposeViewController()
if MFMailComposeViewController.canSendMail() {
self.presentViewController(mailComposeViewController, animated: true, completion: nil)
} else {
self.showSendMailErrorAlert()
}

}

func configuredMailComposeViewController() -> MFMailComposeViewController {
let mailComposerVC = MFMailComposeViewController()
mailComposerVC.mailComposeDelegate = self // Extremely important to set the --mailComposeDelegate-- property, NOT the --delegate-- property

mailComposerVC.setToRecipients([""])

mailComposerVC.setSubject("")

mailComposerVC.setMessageBody("", isHTML: false)

return mailComposerVC
}

func showSendMailErrorAlert() {
let sendMailErrorAlert = UIAlertView(title: "Could Not Send Email", message: "Your device could not send e-mail. Please check e-mail configuration and try again.", delegate: self, cancelButtonTitle: "OK")
sendMailErrorAlert.show()
}

// MARK: MFMailComposeViewControllerDelegate Method
func mailComposeController(controller: MFMailComposeViewController!, didFinishWithResult result: MFMailComposeResult, error: NSError!) {

controller.dismissViewControllerAnimated(true, completion: nil)

switch result.value {
case MFMailComposeResultCancelled.value:
println("Mail cancelled")
case MFMailComposeResultSaved.value:
println("Mail saved")
case MFMailComposeResultSent.value:
println("Mail sent")
showAlertMessage("Your mail has been sent successfully")
case MFMailComposeResultFailed.value:
println("Mail sent failure: \(error.localizedDescription)")
showAlertMessage("Your mail has not been sent successfully")
default:
break
}

}

func showAlertMessage(value : String){
let alertController = UIAlertController(title: value, message:
nil, preferredStyle: UIAlertControllerStyle.Alert)

alertController.addAction(UIAlertAction(title: "Ok", style: UIAlertActionStyle.Default,handler: nil))

self.presentViewController(alertController, animated: true, completion: nil)
}






- Swift - Displaying Actionsheet For Ipad And Iphone
Swift - Displaying Actionsheet for Ipad and IphoneA simple tutorial on making an alert view of type action sheet that works for iphone and ipad. 1.) First you'll need a button where you can attach your pop over when you're using iPad (in iPhone...

- Location Demo In Ios 8 With Swift
What we will be doing is a simple app the tells your location base on the longitude and latitude.    For making things simpler, I already set-up the UI in this link. Once you have downloaded the files go to storyboard and change the size class...

- How To Configure Mail Resource In Jboss 7.2 With A Sample Java Client
This tutorial assumes that you have the following installed on your local system: JBoss 7.2eclipse to run a projecta mail server, can be gmailIn this page we will summarize how to configure a mail dataSource in Jboss and create a JavaEE6 client to send...

- How To Create A Custom Bean Validation In Javaee6
Bean validation has been mentioned on many articles online but I found few that explain the actual class that implements the constraint validator. For example: the bean validation article from  oracle javaee6 documentation: http://docs.oracle.com/javaee/6/tutorial/doc/gkfgx.html....

- How To Send An Email In Glassfish Using Javamail Session Injection
This tutorial will teach us how to send an email in Glassfish using JavaMail session injection. It use gmail for sending the email. Steps: 1.) First we need to create a JavaMail session by, opening Glassfish admin: http://localhost:4848, and navigating...



Tech-Today








.