首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >MT是否支持SMTP?

MT是否支持SMTP?
EN

Stack Overflow用户
提问于 2011-01-16 22:23:43
回答 2查看 257关注 0票数 2

MT是否支持SMTP SendMail,或者我是否坚持使用MFMailComposeViewController?现在,我让它正常工作(MFMailComposeViewController),但是当我添加附件时,收件人没有收到邮件。

我想知道SMTP是否会更可靠并处理附件。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2011-01-17 04:48:47

是的,它是在System.Net.Mail下支持的,但不推荐使用,因为除非你在你的应用程序上请求,否则没有办法从系统中获得用户凭据,但我不知道这是否违反了苹果的EULA。

我已经用下面的代码成功地从iphone上发送了带有附件的电子邮件,希望这能有所帮助:)

代码语言:javascript
复制
MFMailComposeViewController _mail;
mailButton.TouchUpInside += (o, e) =>
            {
                byte[] data = File.ReadAllBytes("photo.png");
                NSData datas = NSData.FromArray(data);
                if (MFMailComposeViewController.CanSendMail) 
                {
                    _mail = new MFMailComposeViewController ();
                    _mail.SetMessageBody ("This is the body of the email", false);
                    _mail.AddAttachmentData(datas, "image/png", "photo.png");
                    _mail.Finished += delegate(object sender, MFComposeResultEventArgs e1) 
                    {
                        if (e1.Result == MFMailComposeResult.Sent) 
                        {
                            UIAlertView alert = new UIAlertView ("Mail Alert", "Mail Sent", null, "Success", null);
                            alert.Show ();

                            //you should handle other values that could be returned in e.Result and also in e.Error 
                        }
                            e1.Controller.DismissModalViewControllerAnimated (true);
                    };

                    this.PresentModalViewController (_mail, true);

                } else {
                    //handle not being able to send mail
                }
            };

这里还有测试解决方案的链接,它基于mike bluestein的示例http://dl.dropbox.com/u/2058130/MailDemo.zip,它适用于我:)

希望这能有所帮助

亚历克斯

票数 2
EN

Stack Overflow用户

发布于 2011-01-16 22:27:49

不管它是否支持,你都不应该使用它。

您无法获取用户的SMTP连接设置,因此无法以用户身份发送邮件。

您不能假定用户的连接可以连接到您的服务器。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4705851

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档