Ios api: send emails

Source: Internet
Author: User

1.

// Homeviewcontroller. h
// Maildemo

# Import <uikit/uikit. h>
# Import <messageui/messageui. h>

@ Interface homeviewcontroller: uiviewcontroller <mfmailcomposeviewcontrollerdelegate>

-(Ibaction) displaycomposersheet;

@ End

 

2.

//
// Homeviewcontroller. m
// Maildemo
//

# Import "homeviewcontroller. H"

@ Interface homeviewcontroller ()

@ End

@ Implementation homeviewcontroller

-(Ibaction) displaycomposersheet
{
Mfmailcomposeviewcontroller * picker = [[mfmailcomposeviewcontroller alloc] init];

Picker. mailcomposedelegate = self;

[Picker setsubject: @ "hello"];

Nsarray * torecipients = [nsarray arraywithobjects: @ "111@qq.com", nil];

Nsarray * ccrecipients = [nsarray arraywithobjects: @ "222@qq.com", @ "333@qq.com", nil];

Nsarray * bccrecipients = [nsarray arraywithobjects: @ "444@qq.com", nil];

[Picker settorecipients: torecipients];

[Picker setccrecipients: ccrecipients];

[Picker setbccrecipients: bccrecipients];

Nsstring * Path = [[nsbundle mainbundle] pathforresource: @ "mm" oftype: @ "jpg"];

Nsdata * mydata = [nsdata datawithcontentsoffile: path];

[Picker addattachmentdata: mydata mimetype: @ "image/jpg" filename: @ "mm"];

Nsstring * emailbody = @ "Pretty mm ";

[Picker setmessagebody: emailbody ishtml: No];

[Self presentmodalviewcontroller: picker animated: Yes];

[Picker release];
}

-(Void) mailcomposecontroller :( mfmailcomposeviewcontroller *) controller didfinishwithresult :( mfmailcomposeresult) Result error :( nserror *) Error
{
[Self dismissmodalviewcontrolleranimated: Yes];
}

-(Void) viewdidload
{
[Super viewdidload];
// Do any additional setup after loading the view from Its nib.
}

-(Void) viewdidunload
{
[Super viewdidunload];
// Release any retained subviews of the main view.
// E.g. Self. myoutlet = nil;
}

-(Bool) shouldautorotatetointerfaceorientation :( uiinterfaceorientation) interfaceorientation
{
Return (interfaceorientation = uiinterfaceorientationportrait );
}

@ End

 

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.