开发者

Does MT support SMTP?

Does MT support SMTP SendMail, or am I stuc开发者_Python百科k with MFMailComposeViewController? Right now, I have it working (MFMailComposeViewController), but when I add an attachment, the mail is not received by the receipient.

I was wondering if SMTP would be more reliable and handle attachments.


Yes, it is supported its under System.Net.Mail but it is not recommended to be used because there is no way to get the user credentials from the system unless you ask for them on your application but i dont know if its against the EULA of apple.

i have successfully sent email with attachments from the iphone using the following code hope this helps :)

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
                }
            };

Also here is the link to the test solution, its based on mike bluestein's example http://dl.dropbox.com/u/2058130/MailDemo.zip and it works for me :)

hope this helps

Alex


Whether it supports it or not, you shouldn't use it.

You have no way of getting the user's SMTP connection settings, so you cannot send mail as the user.

You cannot assume that the user's connection can connect to your server.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜