邮件编辑器地址问题 [英] Mail Composer Address Problem

查看:86
本文介绍了邮件编辑器地址问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从iphone OS Ref Library中找到了电子邮件作曲家示例代码。这是一个代码 -

I found email composer sample code from iphone OS Ref Library. Here is a code-

代码:

NSArray *toRecipients = [NSArray arrayWithObject:@"first@example.com"];
NSArray *ccRecipients = [NSArray arrayWithObjects:@"second@example.com", @"third@example.com", nil];
NSArray *bccRecipients = [NSArray arrayWithObject:@"fourth@example.com"];

我的问题是如何获取用户的输入?此处所有电子邮件地址均已在代码中预定那么to,CC,Bcc,主题和正文字段的ID是什么?

My question is how to take user's input? Here all email address are predefined in code. so what are the IDs of to, CC, Bcc, subject and body fields?

推荐答案

使用此代码。仅提供电子邮件地址作为用户输入。

Use this code. To Give a Email address as user input only.

MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];

picker.mailComposeDelegate = self;

NSString *msgTitle = @"Sample Title";

    [picker setSubject:msgTitle];

NSArray *toRecipients =[[NSArray alloc] init];

NSArray *ccRecipients =[[NSArray alloc] init];

NSArray *bccRecipients =[[NSArray alloc] init];

[picker setToRecipients:toRecipients];

[picker setCcRecipients:ccRecipients];  

[picker setBccRecipients:bccRecipients];

    NSString *sum = @"The Email Body string is here";

NSString *emailBody;

emailBody = [NSString stringWithFormat:@"%@",sum];

[picker setMessageBody:emailBody isHTML:YES];

[self presentModalViewController:picker animated:YES];

[picker release];


  -(void)launchMailAppOnDevice
  {
     NSString *recipients = @"mailto:?cc=,&subject=@";

     NSString *body = @"&body=";

     NSString *email = [NSString stringWithFormat:@"%@%@", recipients, body];

    email = [email stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:email]];

  }

祝您好运。

这篇关于邮件编辑器地址问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆