MFMailComposeViewController 更改收件人

发布于 2025-01-06 02:03:40 字数 842 浏览 4 评论 0原文

您好,我想让用户能够将电子邮件发送到不同的电子邮件地址,这取决于表视图中选择的回合 - 全部来自同一视图。 我的问题是每次我尝试一些操作时都会更改收件人的电子邮件地址,例如将电子邮件地址放入字符串中,该字符串会根据按下的按钮进行更新,但我无法将电子邮件地址获取到to:作曲家中的选项卡。 我能够修复特定的电子邮件地址,但我希望每次收件人不同时“收件人:”选项卡都会更改。 任何帮助将不胜感激 - 我当前返回空白电子邮件地址的代码如下。 (邮件是我每次收到正确电子邮件地址的字符串)。

-(void)displayComposerSheet 
{
    MFMailComposeViewController *mailComposerVC = [[MFMailComposeViewController alloc] init];
    mailComposerVC.mailComposeDelegate = self;

    [mailComposerVC setSubject:@"Iphone App"];

    NSArray *toRecipients = [NSArray arrayWithContentsOfFile:mail]; 

    [mailComposerVC setToRecipients:toRecipients];

    NSString *BodyText = @"My Name Is:    \n My Phone Number Is:     \n Please Help With:    \n";
    [mailComposerVC setMessageBody:BodyText isHTML:NO];

    [self presentModalViewController:mailComposerVC animated:YES];
}

Hi I would like to enable the user to send e-mail to different e-mail address it depends on the bout ton selected in the table view - All from same view.
My problem is changing the e-mail address of the recipient each time i tried a few things like putting the e-mail address in a String which updates depending on the bout ton pressed but i was not able to get the e-mail address to the to: Tab in the composer.
I am able to fix a spesific e-mail address but i want the to: tab to change each time it is a different recipient.
Any help would be appreciated -
My current code which returns blank e-mail address is below.
(Mail is my String receiving the correct e-mail address each time).

-(void)displayComposerSheet 
{
    MFMailComposeViewController *mailComposerVC = [[MFMailComposeViewController alloc] init];
    mailComposerVC.mailComposeDelegate = self;

    [mailComposerVC setSubject:@"Iphone App"];

    NSArray *toRecipients = [NSArray arrayWithContentsOfFile:mail]; 

    [mailComposerVC setToRecipients:toRecipients];

    NSString *BodyText = @"My Name Is:    \n My Phone Number Is:     \n Please Help With:    \n";
    [mailComposerVC setMessageBody:BodyText isHTML:NO];

    [self presentModalViewController:mailComposerVC animated:YES];
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

半寸时光 2025-01-13 02:03:40

您的收件人是什么?

你为什么不这样做:

NSString *email1 = @"[email protected]"

NSString *email2 = @"[email protected]"

//if logic
NSArray *toRecipients = [NSArray arrayWithObject:email1];
//if logic
NSArray *toRecipients = [NSArray arrayWithObject:email2];

What is your toRecipients?

Why don't you just do:

NSString *email1 = @"[email protected]"

NSString *email2 = @"[email protected]"

//if logic
NSArray *toRecipients = [NSArray arrayWithObject:email1];
//if logic
NSArray *toRecipients = [NSArray arrayWithObject:email2];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文