-1

i have created library photo in my App and i want to put a button to share the image by email. Can someone help me with that?

i have tried this but this one is for tex:

     let firstActivityItem = "your text here"

    let secondActivityItem : NSURL = NSURL(fileURLWithPath: "your link here")!

    let activityViewController : UIActivityViewController = UIActivityViewController(
        activityItems: [firstActivityItem, secondActivityItem], applicationActivities: nil)

    activityViewController.excludedActivityTypes = [
        UIActivityTypePostToWeibo,
        UIActivityTypePrint,
        UIActivityTypeAssignToContact,
        UIActivityTypeSaveToCameraRoll,
        UIActivityTypeAddToReadingList,
        UIActivityTypePostToFlickr,
        UIActivityTypePostToVimeo,
        UIActivityTypePostToTencentWeibo
    ]
Steven
  • 762
  • 1
  • 10
  • 27

1 Answers1

0

Use MFMailComposeViewController if you want to share by email only.

See this answer on how to attach an image to it.

Community
  • 1
  • 1
Sahil Kapoor
  • 11,183
  • 13
  • 64
  • 87
  • I tried but it doesnt work, it gives error.. do you have a complete swift code? – Steven Oct 01 '15 at 15:23
  • It doesnt attach the picture on email, cause i want to select the picture from my gallery and send by email, the problem is it doesnt select the email to send. – Steven Oct 02 '15 at 10:55
  • You will have to load image via UIImagePicker and then use MFMailComposeViewController. – Sahil Kapoor Oct 02 '15 at 10:59