- (void)sendBySysMail
{
MFMailComposeViewController *mailCompose = [[MFMailComposeViewController alloc] init];
[mailCompose setMailComposeDelegate:self];
[mailCompose setSubject:@"邮件主题"];
[mailCompose setToRecipients:@[@"xxxxxxxx@qq.com"]];
[mailCompose setCcRecipients:@[@"邮箱号码"]];
[mailCompose setBccRecipients:@[@"邮箱号码"]];
* 设置邮件的正文内容
*/
NSString *emailContent = @"我是邮件内容";
[mailCompose setMessageBody:emailContent isHTML:NO];
[mailCompose setMessageBody:@"<html><body><p>Hello</p><p>World!</p></body></html>" isHTML:YES];
* 添加附件
*/
UIImage *image = [UIImage imageNamed:@"image"];
NSData *imageData = UIImagePNGRepresentation(image);
[mailCompose addAttachmentData:imageData mimeType:@"" fileName:@"custom.png"];
NSString *file = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"pdf"];
NSData *pdf = [NSData dataWithContentsOfFile:file];
[mailCompose addAttachmentData:pdf mimeType:@"" fileName:@"7天精通iOS"];
[self presentViewController:mailCompose animated:YES completion:nil];
}