Esempio n. 1
0
		private void CreateMail(string html)
		{
			if (MFMailComposeViewController.CanSendMail) {
	            _mail = new MFMailComposeViewController ();
				_mail.NavigationBar.BarStyle = UIBarStyle.Black;
				_mail.Title = Utils.Translate("sendmail");
				if(jakt != null)
					_mail.SetSubject(string.Format(Utils.Translate("mailsubject"), jakt.Sted, jakt.DatoFra.ToLocalDateAndYearString()));
	            else 
					_mail.SetSubject(Utils.Translate("mailsubject_generic"));
				
				_mail.SetMessageBody (html, true);
	            _mail.Finished += HandleMailFinished;
				
				
				//Get e-mails:
				var selectedJegerIds = new List<int>();
				var jegerIds = JaktLoggApp.instance.JegerList.Select(j => j.ID).ToList<int>();
				if(jakt != null)
					jegerIds = jakt.JegerIds;
				
				var jegerScreen = new JegerPickerScreen(jegerIds, screen => {
					selectedJegerIds = screen.jegerIds;
					//get email pr. jegerid
					if(selectedJegerIds.Count > 0){
						List<string> emails = new List<string>();
						foreach(var jegerId in selectedJegerIds){
							var jeger = JaktLoggApp.instance.JegerList.Where(j => j.ID == jegerId).FirstOrDefault();
							if(jeger.Email != "")
								emails.Add(jeger.Email);
							else
								MessageBox.Show(string.Format(Utils.Translate("report.mailmissing"), jeger.Fornavn), "");
						}
						if(emails.Count > 0)
							_mail.SetToRecipients(emails.ToArray());
						
					}
					this.PresentModalViewController (_mail, true);
				});
				jegerScreen.Title = Utils.Translate("report.jegereheader");
				jegerScreen.Footer = Utils.Translate("report.jegerefooter");
				jegerScreen.ModalTransitionStyle = UIModalTransitionStyle.CoverVertical;
				
				this.NavigationController.PushViewController(jegerScreen, true);
	            
	        } 
			else {
	        	MessageBox.Show(Utils.Translate("sorry"), Utils.Translate("error_mailnotsupported"));
	        }

		}
        public override void ViewDidLoad ()
        {
            base.ViewDidLoad ();
            
			// wire up the send-mail compose view controller
			sendButton.TouchUpInside += (sender, e) => {       
				if (MFMailComposeViewController.CanSendMail) {
            
					var to = new string[]{ "*****@*****.**" };

					if (MFMailComposeViewController.CanSendMail) {
						mailController = new MFMailComposeViewController ();
						mailController.SetToRecipients (to);
						mailController.SetSubject ("mail test");
						mailController.SetMessageBody ("this is a test", false);
						mailController.Finished += (object s, MFComposeResultEventArgs args) => {

							Console.WriteLine ("result: " + args.Result.ToString ()); // sent or cancelled

							BeginInvokeOnMainThread (() => {
								args.Controller.DismissViewController (true, null);
							});
						};
					}

					this.PresentViewController (mailController, true, null);
				} else {
					new UIAlertView("Mail not supported", "Can't send mail from this device", null, "OK");
				}
            };
        }
        public void ComposeEmail(
            IEnumerable<string> to, IEnumerable<string> cc = null, string subject = null,
            string body = null, bool isHtml = false,
            IEnumerable<EmailAttachment> attachments = null, string dialogTitle = null)
        {
            if (!MFMailComposeViewController.CanSendMail)
                throw new MvxException("This device cannot send mail");

            _mail = new MFMailComposeViewController();
            _mail.SetMessageBody(body ?? string.Empty, isHtml);
            _mail.SetSubject(subject ?? string.Empty);

            if (cc != null)
                _mail.SetCcRecipients(cc.ToArray());

            _mail.SetToRecipients(to?.ToArray() ?? new[] { string.Empty });
            if (attachments != null)
            {
                foreach (var a in attachments)
                {
                    _mail.AddAttachmentData(NSData.FromStream(a.Content), a.ContentType, a.FileName);
                }
            }
            _mail.Finished += HandleMailFinished;

            _modalHost.PresentModalViewController(_mail, true);
        }
Esempio n. 4
0
        public Task OpenEmailManager(string[] emails, string subject, string text, string[] attachments)
        {
            var tcs = new TaskCompletionSource<bool>();
            if (MFMailComposeViewController.CanSendMail)
            {
                var c = new MFMailComposeViewController();
                c.SetToRecipients(emails);
                c.SetSubject(subject ?? "");
                c.SetMessageBody(text ?? "", false);
                foreach (string attachment in attachments)
                {
                    NSData data = NSData.FromFile(attachment);
                    if (data != null)
                        c.AddAttachmentData(data, GetMimeType(attachment), Path.GetFileName(attachment));
                }

                _application.RootController.PresentViewController(c, true, null);
                c.Finished += (sender, e) =>
                {
                    tcs.SetResult(e.Result == MFMailComposeResult.Sent);
                    _application.InvokeOnMainThread(() => e.Controller.DismissViewController(true, null));
                };
            }
            else
            {
                var alert = new UIAlertView("Cannot send report", "E-mail messages not allowed", null, "OK");
                alert.Clicked += (sender, args) => tcs.SetResult(false);
                alert.Show();
            }
            return tcs.Task;
        }
		/// <summary>
		/// Shows the draft.
		/// </summary>
		/// <param name="subject">The subject.</param>
		/// <param name="body">The body.</param>
		/// <param name="html">if set to <c>true</c> [HTML].</param>
		/// <param name="to">To.</param>
		/// <param name="cc">The cc.</param>
		/// <param name="bcc">The BCC.</param>
		/// <param name="attachments">The attachments.</param>
		public void ShowDraft(
			string subject,
			string body,
			bool html,
			string[] to,
			string[] cc,
			string[] bcc,
			IEnumerable<string> attachments = null)
		{
			var mailer = new MFMailComposeViewController();

			mailer.SetMessageBody(body ?? string.Empty, html);
			mailer.SetSubject(subject ?? string.Empty);
			mailer.SetCcRecipients(cc);
			mailer.SetToRecipients(to);
			mailer.Finished += (s, e) => ((MFMailComposeViewController)s).DismissViewController(true, () => { });

			if (attachments != null) 
			{
				foreach (var attachment in attachments) 
				{
					mailer.AddAttachmentData (NSData.FromFile (attachment), GetMimeType (attachment), Path.GetFileName (attachment));
				}
			}

			UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController(mailer, true, null);
		}
Esempio n. 6
0
        public void SendMail(MemoryStream stream)
        {
            SaveExcel(stream);

            string path = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            string filePath = Path.Combine(path, "reports.xlsx");

            NSData data = NSData.FromFile (filePath);

            if (MFMailComposeViewController.CanSendMail)
            {
                var mail = new MFMailComposeViewController ();
                mail.SetSubject ("Exports");
                mail.SetMessageBody ("Hi, Please find the report here.", false);
                mail.AddAttachmentData (data, "application/vnd.ms-excel", "reports.xlsx");

                var window= UIApplication.SharedApplication.KeyWindow;
                var vc = window.RootViewController;
                vc.PresentViewController (mail, false, null);

                mail.Finished += ( object s, MFComposeResultEventArgs args) => {

                        args.Controller.DismissViewController (true, null);

                };
            }
        }
Esempio n. 7
0
        public void Email(string message, string subject, string[] recivers)
        {
            if (!MFMailComposeViewController.CanSendMail) {
                return;
            }
            MFMailComposeViewController mailController = new MFMailComposeViewController();
            if (!MFMailComposeViewController.CanSendMail)
            {
                return;
            }
            if (recivers != null)
            {
                mailController.SetToRecipients(recivers);
            }
            mailController.SetSubject(subject);
            mailController.SetMessageBody(message, false);
            mailController.Finished += ( s, args) =>
            {

                if(fromScreen==Screen.ContactList)
                {
                    c_ViewController.DismissViewController(true,null);
                    c_ViewController.NavigationController.PopViewController(false);
                }
                else{
                    c_ViewController.DismissViewController(true,null);
                }
            };

            c_ViewController.PresentViewController(mailController, true, null);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            // HTML is perfect to display this kind of content.
            this.webView.LoadData (NSData.FromFile ("about.html"), "text/html", "UTF8", NSUrl.FromString ("."));

            //  We want to open links in the real Safari and mailto links should also be handled correctly.
            this.webView.ShouldStartLoad = (webView, request, navigationType) => {

                // If a "mailto:" link is clicked, open a mail composition sheet.
                if(request.Url.AbsoluteString.StartsWith("mailto:"))
                {
                    string recipient = request.Url.AbsoluteString.Replace("mailto:", "");
                    var mail = new MFMailComposeViewController();
                    mail.SetToRecipients(new[] { recipient });
                    mail.SetSubject("MultiMode LED");
                    mail.Finished += (sender, e) => ((MFMailComposeViewController)sender).DismissViewController(true, null);
                    this.PresentViewController(mail, true, null);
                    return false;
                }

                // For other links, open Safari.
                if(navigationType == UIWebViewNavigationType.LinkClicked)
                {
                    UIApplication.SharedApplication.OpenUrl(request.Url);
                    return false;
                }
                return true;
            };
        }
Esempio n. 9
0
 public Task<bool> SendReport(IReport report)
 {
     var tcs = new TaskCompletionSource<bool>();
     if (MFMailComposeViewController.CanSendMail)
     {
         var c = new MFMailComposeViewController();
         c.SetSubject(report.Title);
         c.SetToRecipients(new[] {_settings.DevelopersEmail});
         c.SetMessageBody(report.Body, false);
         NSData data = new NSString(report.Attachment).DataUsingEncoding(NSStringEncoding.UTF8);
         c.AddAttachmentData(data, "text/xml", "info.xml");
         _application.RootController.PresentViewController(c, true, null);
         c.Finished += (sender, e) =>
         {
             tcs.SetResult(e.Result == MFMailComposeResult.Sent);
             e.Controller.DismissViewController(true, null);
         };
     }
     else
     {
         var alert = new UIAlertView("Cannot send report", "E-mail messages not allowed", null, "OK");
         alert.Clicked += (sender, args) => tcs.SetResult(false);
         alert.Show();
     }
     return tcs.Task;
 }
Esempio n. 10
0
        public void Show(string to = null, string subject = null, string body = null)
        {
            if (!MFMailComposeViewController.CanSendMail)
            {
                Alert.ShowErrorBox("Email is not setup correctly on this device");
                return;
            }

            var mail = new MFMailComposeViewController ();
            mail.ModalPresentationStyle = UIModalPresentationStyle.FormSheet;
            mail.Finished += delegate {
                mail.DismissViewController(true, null);
            };

            if (!string.IsNullOrEmpty(to))
                mail.SetToRecipients(new string[] { to });

            if (!string.IsNullOrEmpty (subject))
                mail.SetSubject (subject);

            if (!string.IsNullOrEmpty (body))
                mail.SetMessageBody (body, true);

            _c.PresentViewController(mail, true, null);
        }
        public override void ViewDidLoad ()
        {
            base.ViewDidLoad ();
            
            // Perform any additional setup after loading the view, typically from a nib.
            
            button = UIButton.FromType (UIButtonType.RoundedRect);
            button.Frame = new CGRect (10, 10, 100, 44);
            button.SetTitle ("Send Email", UIControlState.Normal);
            View.AddSubview (button);
			to = new string[]{ "*****@*****.**" };

			if (MFMailComposeViewController.CanSendMail) {
				mailController = new MFMailComposeViewController ();
				mailController.SetToRecipients (to);
				mailController.SetSubject ("mail test");
				mailController.SetMessageBody ("this is a test", false);
				mailController.Finished += ( object s, MFComposeResultEventArgs args) => {
                
					Console.WriteLine (args.Result.ToString ());
                
					BeginInvokeOnMainThread (() => {
						args.Controller.DismissViewController (true, null);
					});
				};
			}
            button.TouchUpInside += (sender, e) => {       
				if (MFMailComposeViewController.CanSendMail) {
                	this.PresentViewController (mailController, true, null);
				} else {
					new UIAlertView("Mail not supported", "Can't send mail from this device", null, "OK");
				}
            };
        }
        public override void ViewDidAppear(bool animated)
        {
            base.ViewDidAppear(animated);

            if (MFMailComposeViewController.CanSendMail)
            {
                var mailController = new MFMailComposeViewController();
                mailController.SetToRecipients(new[] {
                        "*****@*****.**"
                    });
                mailController.SetSubject("This seems to work :)");
                mailController.SetMessageBody("Lorem ipsum", false);
                mailController.Finished += (sender, e) =>
                {
                    this.DismissViewController(true, null);
                };
                this.PresentViewController(mailController, true, null);
            }
            else
            {
                var alert = UIAlertController.Create("Mail sending disabled", "It seems this device can't send mail!", UIAlertControllerStyle.Alert);
                alert.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
                this.PresentViewController(alert, true, null);
            }
        }
Esempio n. 13
0
 private void OpenMailer()
 {
     var mailer = new MFMailComposeViewController();
     mailer.SetSubject("AppreciateUI Feedback");
     mailer.SetToRecipients(new string[] { "*****@*****.**" });
     mailer.ModalPresentationStyle = UIModalPresentationStyle.PageSheet;
     mailer.Finished += (sender, e) => this.DismissViewController(true, null);
     this.PresentViewController(mailer, true, null);
 }
Esempio n. 14
0
 private void ContactUs()
 {
     if (MFMailComposeViewController.CanSendMail)
     {
         _mailViewController = new MFMailComposeViewController();
         _mailViewController.SetToRecipients(new[] { "*****@*****.**" });
         _mailViewController.Finished += (sender, e) => e.Controller.DismissViewController(true, null);
         _mailViewController.SetSubject("Feedback");
         PresentViewController(_mailViewController, true, null);
     }
 }
		public void Compose(string to, string subject, string body)
		{
			var mail = new MFMailComposeViewController();
			mail.SetToRecipients(new [] {to});
			mail.SetSubject(subject);
			mail.SetMessageBody(body, false);

			mail.Finished += (sender, args) => args.Controller.DismissViewController(true, null);

			UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController(mail, true, null);
		}
		MFMailComposeViewController configuredMailComposeViewController ()
		{
			var mailComposerVC = new MFMailComposeViewController ();
			mailComposerVC.MailComposeDelegate = this;

			mailComposerVC.SetToRecipients(new [] { AppKeys.ContactEmail });
			mailComposerVC.SetSubject(AppKeys.Contact.IntegrationSubject);
			mailComposerVC.SetMessageBody(AppKeys.Contact.IntegrationBody, false);

			return mailComposerVC;
		}
 public void ShowDraft(string subject, string body, bool html, string[] to, string[] cc, string[] bcc)
 {
     var mailer = new MFMailComposeViewController();
     mailer.SetMessageBody(body ?? string.Empty, html);
     mailer.SetSubject(subject ?? string.Empty);
     mailer.SetCcRecipients(cc);
     mailer.SetToRecipients(to);
     mailer.Finished += (s, e) =>
     {
         ((MFMailComposeViewController)s).DismissViewController(true, () => { });
     };
 }
Esempio n. 18
0
		public static MFMailComposeViewController Email (string[] recipients, string subject)
		{
			var mailController = new MFMailComposeViewController ();

			mailController.SetToRecipients (recipients);
			mailController.SetSubject (subject);

			mailController.Finished += ( object s, MFComposeResultEventArgs e) => {
				e.Controller.DismissViewController (true, null);
			};

			return mailController;
		}
Esempio n. 19
0
        public void ComposeEmail(string to, string cc, string subject, string body, bool isHtml)
        {
            if (!MFMailComposeViewController.CanSendMail)
                return;

            _mail = new MFMailComposeViewController();
            _mail.SetMessageBody(body ?? string.Empty, isHtml);
            _mail.SetSubject(subject ?? string.Empty);
            _mail.SetCcRecipients(new[] {cc ?? string.Empty});
            _mail.SetToRecipients(new[] {to ?? string.Empty});
            _mail.Finished += HandleMailFinished;

            _presenter.PresentModalViewController(_mail, true);
        }
Esempio n. 20
0
        public void ShowDraft(string subject, string body, bool html, string[] to, string[] cc, string[] bcc, IEnumerable<string> attachments)
        {
            var mailer = new MFMailComposeViewController();
            mailer.SetMessageBody(body ?? string.Empty, html);
            mailer.SetSubject(subject ?? string.Empty);
            mailer.SetCcRecipients(cc);
            mailer.SetToRecipients(to);
            mailer.Finished += (s, e) =>
            {
                ((MFMailComposeViewController)s).DismissViewController(true, () => { });
            };

            UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController(mailer, true, null);
        }
		public bool Email (string emailAddress)
		{
			if (MFMailComposeViewController.CanSendMail) {
				var composer = new MFMailComposeViewController ();
				composer.SetToRecipients (new string[] { emailAddress });
				composer.SetSubject ("Hello from EmployeeDirectory!");

				composer.Finished += (sender, e) => RootViewController.DismissViewController (true, null);
				RootViewController.PresentViewController (composer, true, null);
				return true;
			} else {
				return false;
			}
		}
Esempio n. 22
0
 public void ComposeMail(string[] recipients, string subject, string messagebody = null, Action<bool> completed = null)
 {
     var controller = new MFMailComposeViewController();
     controller.SetToRecipients(recipients);
     controller.SetSubject(subject);
     if (!string.IsNullOrEmpty(messagebody))
         controller.SetMessageBody(messagebody, false);
     controller.Finished += (object sender, MFComposeResultEventArgs e) => {
         if (completed != null)
             completed(e.Result == MFMailComposeResult.Sent);
         e.Controller.DismissViewController(true, null);
     };
     
     UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController(controller, true, null);
 }
Esempio n. 23
0
        public void SendEmail(string toAddress, string subject, string body)
        {
            MFMailComposeViewController _mailController = new MFMailComposeViewController();
            _mailController.SetToRecipients(new string[] { toAddress });
            _mailController.SetSubject(subject);
            _mailController.SetMessageBody(body, false);

            _mailController.Finished += (object s, MFComposeResultEventArgs args) =>
            {
                Console.WriteLine(args.Result.ToString());
                args.Controller.DismissViewController(true, null);
            };

            UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController(_mailController, true, null);    
        }
		public void ComposeEmail(string to, string cc, string subject, string body, bool isHtml, byte[] attachment)
		{
			
			if (!MFMailComposeViewController.CanSendMail)
				return;
			
			_mail = new MFMailComposeViewController ();
			_mail.SetMessageBody (body ?? string.Empty, isHtml);
			_mail.SetSubject(subject ?? string.Empty);
			_mail.SetCcRecipients(new [] {cc ?? string.Empty});
			_mail.SetToRecipients(new [] {to ?? string.Empty});
			_mail.AddAttachmentData(NSData.FromArray(attachment), "image/jpeg", "screenshot.jpg");
			_mail.Finished += HandleMailFinished;
			
			_presenter.PresentModalViewController(_mail, true);
		}
Esempio n. 25
0
 public Bullying()
     : base(UITableViewStyle.Grouped, null)
 {
     Title = NSBundle.MainBundle.LocalizedString ("Bullying", "Bullying");
     TabBarItem.Image = UIImage.FromBundle("bullying");
     //			var HelpButton = new UIButton(UIButtonType.RoundedRect);
     //			HelpButton.SetTitle("Help Me!", UIControlState.Normal);
     Root = new RootElement ("Student Guide") {
         new Section("Bullying"){
             new StyledStringElement ("Help me!", () => {
                 //AppDelegate.getControl.calling(); //Phones a number all like 'SAVE ME PLS'
             }){ TextColor=UIColor.Red,},
             new RootElement("Speak Up!") {
                 new Section("Speak up form") {
                     (FullName = new EntryElement("Full Name","Full Name","")),
                     (Incident = new EntryElement("Incedent","Incedent","",false)),
                     (Location = new EntryElement("Location of Incident","Location of Incident","")),
                     (ThoseInvolved = new EntryElement("Persons Involved","Persons Involved","")),
                 },
                 new Section() {
                     new StringElement("Submit", delegate {
                         UIAlertView popup = new UIAlertView("Alert","Do you wish to send an Email, a Text or cancel the form?",null,"Cancel","Text","Email");
                         popup.Show();
                         popup.Dismissed += delegate(object sender, UIButtonEventArgs e) {
                             if (e.ButtonIndex==1) {
                                 MFMessageComposeViewController msg = new MFMessageComposeViewController();
                                 msg.Recipients= new string[] {"07624808747"};
                                 msg.Body="Hello, I am being bullied by " + ThoseInvolved.Value + " they were " + Incident.Value + " this all happened " + Location.Value + "" + Environment.NewLine + "" + FullName.Value;
                                 this.NavigationController.PresentViewController(msg,true,null);
                             } else if (e.ButtonIndex==2) {
                                 MFMailComposeViewController email = new MFMailComposeViewController();
                                 email.SetSubject("Help me i'm being bullied");
                                 email.SetToRecipients(new string[] {"*****@*****.**"});
                                 email.SetMessageBody("Hello, I am being bullied by " + ThoseInvolved.Value + " they were " + Incident.Value + " this all happened " + Location.Value + "" + Environment.NewLine + "" + FullName.Value,false);
                                 this.NavigationController.PresentViewController(email,true,null);
                             }
                         };
                     }),
                 },
             },
             new RootElement("Bullying Information") {
                 from x in bullyingInfo
                     select (Section)Generate (x)
             },
         }
     };
 }
Esempio n. 26
0
		public override async Task ExecuteAsync ()
		{
			await base.ExecuteAsync ();

			if (string.IsNullOrWhiteSpace (Address))
				return;

			var fromVC = UIApplication.SharedApplication.Windows [0].RootViewController;

			var c = new MFMailComposeViewController ();
			c.Finished += (sender, e) => c.DismissViewController (true, null);
			c.SetToRecipients (new [] { Address });
			c.SetSubject (Subject);
			c.SetMessageBody (BodyHtml, true);

			await fromVC.PresentViewControllerAsync (c, true);
		}
Esempio n. 27
0
        public bool Email(string emailAddress)
        {
            if (MFMailComposeViewController.CanSendMail)
            {
                var composer = new MFMailComposeViewController();
                composer.SetToRecipients(new string[] { emailAddress });
                composer.SetSubject("");

                composer.Finished += (sender, e) => RootViewController.DismissViewController(true, null);
                RootViewController.PresentViewController(composer, true, null);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 28
0
        private static async Task ComposeEmailWithMFAsync(EmailMessage message)
        {
            if (UIApplication.SharedApplication.KeyWindow?.RootViewController == null)
            {
                throw new InvalidOperationException("Root view controller is null, API called too early in the application lifecycle.");
            }

#if __MACCATALYST__ // catalyst https://github.com/xamarin/xamarin-macios/issues/13935
            throw new InvalidOperationException("Not supported on catalyst (https://github.com/xamarin/xamarin-macios/issues/13935)");
#else
            var controller = new MFMailComposeViewController();

            if (!string.IsNullOrEmpty(message?.Body))
            {
                controller.SetMessageBody(message.Body, true);
            }

            if (!string.IsNullOrEmpty(message?.Subject))
            {
                controller.SetSubject(message.Subject);
            }

            if (message?.To?.Count > 0)
            {
                controller.SetToRecipients(
                    message.To.Select(r => r.Address).ToArray());
            }

            if (message?.CC?.Count > 0)
            {
                controller.SetCcRecipients(
                    message.CC.Select(cc => cc.Address).ToArray());
            }

            if (message?.Bcc?.Count > 0)
            {
                controller.SetBccRecipients(
                    message.Bcc.Select(bcc => bcc.Address).ToArray());
            }

            await UIApplication.SharedApplication.KeyWindow?.RootViewController.PresentViewControllerAsync(controller, true);

            await controller.DismissViewControllerAsync(true);
#endif
        }
Esempio n. 29
0
        void FillData(string nombre      = "", string apellido     = "", string puesto = "", string profesion = "",
                      string habilidades = "", bool disponibilidad = true, string pais = "", string estado    = "",
                      string municipio   = "")
        {
            using (UIScrollView scrollView = new UIScrollView(new CGRect(0, position, UIScreen.MainScreen.Bounds.Width, UIScreen.MainScreen.Bounds.Height)))
            {
                foreach (MiembroModel usuario in new MiembrosController().GetDirectorioUsuarios(nombre, apellido, puesto, profesion, habilidades, disponibilidad, pais, estado, municipio))
                {
                    InfoPersonaCard personaCard = new InfoPersonaCard(usuario, scrollView, position);
                    personaCard.lblMail.TouchUpInside += (sender, e) =>
                    {
                        MFMailComposeViewController mailController;
                        if (MFMailComposeViewController.CanSendMail)
                        {
                            mailController = new MFMailComposeViewController();

                            mailController.SetToRecipients(new string[] { usuario.Miembro_Correo_Electronico });
                            mailController.SetSubject("Contacto - Worklabs");
                            mailController.SetMessageBody("", false);

                            mailController.Finished += (object s, MFComposeResultEventArgs args) =>
                            {
                                Console.WriteLine(args.Result.ToString());
                                args.Controller.DismissViewController(true, null);
                            };

                            this.PresentViewController(mailController, true, null);
                        }
                    };
                    personaCard.lblNombre.TouchUpInside += (sender, e) =>
                    {
                        PerfilController perfilController = (PerfilController)Storyboard.InstantiateViewController("PerfilIndividualController");
                        perfilController.Tipo    = usuario.Miembro_Tipo;
                        perfilController.Usuario = usuario.Miembro_Id;
                        perfilController.Title   = "Perfil";
                        NavigationController.PushViewController(perfilController, true);
                        ((UIButton)sender).BackgroundColor = UIColor.Clear;
                    };
                    position += 400;
                }
                scrollView.ContentSize = new CGSize(UIScreen.MainScreen.Bounds.Width, position);
                View.AddSubview(scrollView);
                scrollView.SendSubviewToBack(View);
            }
        }
        public ServicesController() : base(UITableViewStyle.Grouped)
        {
            try {
                Title = "OData Services";

                _servicesSection = new DialogSection();
                Sections.Add(_servicesSection);

                var asec = new DialogSection();
                asec.Add(new ActionElement("About", delegate {
                    var c = new BrowserController("About", "<h1>OData Browser</h1><p>By <a href='http://kruegersystems.com'>Krueger Systems, Inc.</a></p>");
                    NavigationController.PushViewController(c, true);
                }));
                if (MFMailComposeViewController.CanSendMail)
                {
                    asec.Add(new ActionElement("Support", delegate {
                        _mail = new MFMailComposeViewController();
                        _mail.SetSubject("OData Browser");
                        _mail.SetToRecipients(new string[] { "*****@*****.**" });
                        _mail.MailComposeDelegate = new MailDel();
                        PresentModalViewController(_mail, true);
                    }));
                }

                Sections.Add(asec);

                this.NavigationItem.HidesBackButton = false;

                NavigationItem.BackBarButtonItem = new UIBarButtonItem("Services", UIBarButtonItemStyle.Bordered, delegate {
                    try {
                        NavigationController.PopViewControllerAnimated(true);
                    } catch (Exception e1) {
                        Log.Error(e1);
                    }
                });

                NavigationItem.LeftBarButtonItem = new UIBarButtonItem("Edit", UIBarButtonItemStyle.Bordered, HandleEditButton);

                NavigationItem.RightBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Add, HandleAddButton);

                BeginLoadingServices();
            } catch (Exception error) {
                Log.Error(error);
            }
        }
Esempio n. 31
0
 public override void ShareFileAsync(string path, string subject, string mimeType)
 {
     SensusContext.Current.MainThreadSynchronizer.ExecuteThreadSafe(() =>
     {
         if (MFMailComposeViewController.CanSendMail)
         {
             MFMailComposeViewController mailer = new MFMailComposeViewController();
             mailer.SetSubject(subject);
             mailer.AddAttachmentData(NSData.FromUrl(NSUrl.FromFilename(path)), mimeType, Path.GetFileName(path));
             mailer.Finished += (sender, e) => mailer.DismissViewControllerAsync(true);
             UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController(mailer, true, null);
         }
         else
         {
             FlashNotificationAsync("You do not have any mail accounts configured. Please configure one before attempting to send emails from Sensus.");
         }
     });
 }
Esempio n. 32
0
        void ShowFeedbackUi()
        {
            if (!MFMailComposeViewController.CanSendMail)
            {
                PresentWebViewController("http://monodeveloper.org/axcrypt-ios-feedback/");
                return;
            }

            FreeFeedbackViewController();
            feedbackMailViewController = new MFMailComposeViewController();
            feedbackMailViewController.SetToRecipients(new[] { "*****@*****.**" });
            feedbackMailViewController.SetSubject(String.Concat("Feedback on AxCrypt for iOS v", AppVersion));
            feedbackMailViewController.Finished += delegate {
                FreeFeedbackViewController();
            };

            appViewController.PresentViewController(feedbackMailViewController, true, null);
        }
 private void SendReport(object sender, EventArgs e)
 {
     if (MFMailComposeViewController.CanSendMail)
     {
         var mailController = new MFMailComposeViewController();
         mailController.SetToRecipients(new[] { "*****@*****.**" });
         mailController.SetSubject("User report");
         mailController.Finished += (object s, MFComposeResultEventArgs args) =>
         {
             args.Controller.DismissViewController(true, null);
         };
         PresentViewController(mailController, true, null);
     }
     else
     {
         ShowAlert(LocalizationKeys.SetupMail);
     }
 }
Esempio n. 34
0
        private void sendEmail(string message, UIViewController root)
        {
            try
            {
                if (MFMailComposeViewController.CanSendMail)
                {
                    var mailController = new MFMailComposeViewController();
                    mailController.SetToRecipients(new string[] { "*****@*****.**" });
                    mailController.SetSubject("Cloud Crash Report");
                    mailController.SetMessageBody(message, false);

                    try
                    {
                        var logFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "log.log");
                        if (File.Exists(logFile))
                        {
                            NSData logData = NSData.FromFile(logFile);
                            if (logData != null)
                            {
                                mailController.AddAttachmentData(logData, "text/plain", "log.txt");
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.Log("ERROR AppDelegate.sendMail: Unable to attach log file: " + ex);
                    }

                    mailController.Finished += (object s, MFComposeResultEventArgs args) =>
                    {
                        BeginInvokeOnMainThread(() => args.Controller.DismissViewController(true, null));
                        if (args.Result == MFMailComposeResult.Sent)
                        {
                            deleteCrashLogFile();
                        }
                    };

                    root.PresentViewController(mailController, true, null);
                }
            }
            catch
            {
            }
        }
Esempio n. 35
0
        private void SendEmail(string pathToCsvFile)
        {
            if (MFMailComposeViewController.CanSendMail)
            {
                MFMailComposeViewController mailController = new MFMailComposeViewController();
                mailController.SetToRecipients(new[] { "*****@*****.**" });
                mailController.SetCcRecipients(new [] { "*****@*****.**" });
                mailController.SetSubject("hfghfghfghfg");
                mailController.SetMessageBody("not html ody", false);
                NSData fileData = NSData.FromFile(pathToCsvFile);
                mailController.AddAttachmentData(fileData, "text/plain", "filedata.csv");


                mailController.Finished += (object s, MFComposeResultEventArgs args) =>
                {
                    Console.WriteLine(args.Result.ToString());
                    args.Controller.DismissViewController(true, null);
                };

                this.PresentViewController(mailController, true, null);
            }



            //var email = new Intent(Intent.ActionSend);
            //email.PutExtra(Intent.ExtraEmail, new string[]
            //{
            //        ResourceManager.GetString("send_email_to");
            //});
            //email.PutExtra(Android.Content.Intent.ExtraCc, new string[] {
            //        GetString(Resource.String.send_email_to_cc)
            //    });

            //email.PutExtra(Intent.ExtraSubject, GetString(Resource.String.send_email_subj));

            //var file = new Java.IO.File(pathToCsvFile);
            //email.PutExtra(Intent.ExtraStream, Android.Net.Uri.Parse("file:///" + pathToCsvFile));

            //file.SetReadable(true, false);

            //email.SetType("plain/text");
            //StartActivity(Intent.CreateChooser(email, "Send email..."));
        }
Esempio n. 36
0
 public override void SendEmailAsync(string toAddress, string subject, string message)
 {
     SensusContext.Current.MainThreadSynchronizer.ExecuteThreadSafe(() =>
     {
         if (MFMailComposeViewController.CanSendMail)
         {
             MFMailComposeViewController mailer = new MFMailComposeViewController();
             mailer.SetToRecipients(new string[] { toAddress });
             mailer.SetSubject(subject);
             mailer.SetMessageBody(message, false);
             mailer.Finished += (sender, e) => mailer.DismissViewControllerAsync(true);
             UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController(mailer, true, null);
         }
         else
         {
             FlashNotificationAsync("You do not have any mail accounts configured. Please configure one before attempting to send emails from Sensus.");
         }
     });
 }
Esempio n. 37
0
        public void SendEmail(IEmailMessage email)
        {
            if (email == null)
                throw new ArgumentNullException("email");

            if (CanSendEmail)
            {
                _mailController = new MFMailComposeViewController();
                _mailController.SetSubject(email.Subject);
                _mailController.SetMessageBody(email.Message, ((EmailMessage) email).IsHtml);
                _mailController.SetToRecipients(email.Recipients.ToArray());

                if (email.RecipientsCc.Count > 0)
                    _mailController.SetCcRecipients(email.RecipientsCc.ToArray());

                if (email.RecipientsBcc.Count > 0)
                    _mailController.SetBccRecipients(email.RecipientsBcc.ToArray());

                foreach (var attachment in email.Attachments.Cast<EmailAttachment>())
                {
                    _mailController.AddAttachmentData(NSData.FromStream(attachment.Content),
                        attachment.ContentType, attachment.FileName);
                }

                EventHandler<MFComposeResultEventArgs> handler = null;
                handler = (sender, e) =>
                {
                    _mailController.Finished -= handler;

                    var uiViewController = sender as UIViewController;
                    if (uiViewController == null)
                    {
                        throw new ArgumentException("sender");
                    }

                    uiViewController.DismissViewController(true, () => { });
                };

                _mailController.Finished += handler;

                _mailController.PresentUsingRootViewController();
            }
        }
        /// <summary>
        /// iOS Open the native email control
        /// </summary>
        public void ShowDraft(string subject, string body, string[] to, string[] cc, string[] bcc)
        {
            var mailer = new MFMailComposeViewController();

            mailer.SetMessageBody(body ?? string.Empty, false);
            mailer.SetSubject(subject ?? string.Empty);
            if (cc != null)
            {
                mailer.SetCcRecipients(cc);
            }
            if (bcc != null)
            {
                mailer.SetBccRecipients(bcc);
            }
            mailer.SetToRecipients(to);
            mailer.Finished += (s, e) => ((MFMailComposeViewController)s).DismissViewController(true, () => { });

            UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController(mailer, true, null);
        }
Esempio n. 39
0
        private bool SendEmail()
        {
            if (MFMailComposeViewController.CanSendMail)
            {
                var composeViewController = new MFMailComposeViewController
                {
                    MailComposeDelegate = new MailComposerDelegate()
                };
                composeViewController.SetToRecipients(new string[] { DomainConstants.EMAIL_CONTACT });
                composeViewController.SetSubject("Acciona Covid-19");
                composeViewController.SetMessageBody("", false);

                UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController(composeViewController, true, null);

                return(true);
            }

            return(false);
        }
        /* **************************************** SOCIAL SHARE METHODS *************************************** */



        void ShareOnEmail()
        {
            if (MFMailComposeViewController.CanSendMail)
            {
                // do mail operations here
                MFMailComposeViewController mailController;
                mailController = new MFMailComposeViewController();


                mailController.SetToRecipients(new string[] { "*****@*****.**" });
                mailController.SetSubject("mail test");
                mailController.SetMessageBody("this is a test", false);

                mailController.Finished += (object s, MFComposeResultEventArgs args) => {
                    Console.WriteLine(args.Result.ToString());
                    args.Controller.DismissViewController(true, null);
                };
            }
        }
Esempio n. 41
0
        public void ComposeMail(string fileName, string[] recipients, string subject, string messagebody, MemoryStream stream)
        {
            if (MFMailComposeViewController.CanSendMail)
            {
                var mailer = new MFMailComposeViewController();

                mailer.SetMessageBody(messagebody ?? string.Empty, false);
                mailer.SetSubject(subject ?? subject);
                mailer.Finished += (s, e) => ((MFMailComposeViewController)s).DismissViewController(true, () => { });


                string exception = string.Empty;
                string path      = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
                string filePath  = Path.Combine(path, fileName);
                try
                {
                    FileStream fileStream = File.Open(filePath, FileMode.Create);
                    stream.Position = 0;
                    stream.CopyTo(fileStream);
                    fileStream.Flush();
                    fileStream.Close();
                }
                catch (Exception e)
                {
                    exception = e.ToString();
                }
                finally
                {
                }


                mailer.AddAttachmentData(NSData.FromFile(filePath), GetMimeType(fileName), Path.GetFileName(fileName));



                UIViewController vc = UIApplication.SharedApplication.KeyWindow.RootViewController;
                while (vc.PresentedViewController != null)
                {
                    vc = vc.PresentedViewController;
                }
                vc.PresentViewController(mailer, true, null);
            }
        }
Esempio n. 42
0
 public void SendMail()
 {
     if (MFMailComposeViewController.CanSendMail)
     {
         mail = new MFMailComposeViewController();
         mail.SetSubject(Subject);
         mail.SetMessageBody(Body, false);
         mail.Finished += (sender, e) =>
         {
             var finished = OnFinished;
             if (finished != null)
                 finished(this, EventArgs.Empty);
             mail.Dispose();
             mail = null;
             controller.NavigationController.DismissModalViewControllerAnimated(true);
         };
         controller.NavigationController.PresentModalViewController(mail, true);
     }
 }
Esempio n. 43
0
        public void sendMail(string to)
        {
            MFMailComposeViewController _mail;

            if (MFMailComposeViewController.CanSendMail)
            {
                _mail = new MFMailComposeViewController();
                _mail.SetMessageBody("",
                                     false);
                _mail.SetSubject("");
                _mail.Finished += HandleMailFinished;
                _mail.SetToRecipients(new string [] { to });
                this.PresentModalViewController(_mail, true);
            }
            else
            {
                // handle not being able to send mail
            }
        }
Esempio n. 44
0
        public async Task LaunchMailto(CancellationToken ct, string subject = null, string body = null, string[] to = null, string[] cc = null, string[] bcc = null)
        {
#if !__MACCATALYST__  // catalyst https://github.com/xamarin/xamarin-macios/issues/13935
            if (!MFMailComposeViewController.CanSendMail)
            {
                return;
            }

            var mailController = new MFMailComposeViewController();

            mailController.SetToRecipients(to);
            mailController.SetSubject(subject);
            mailController.SetMessageBody(body, false);
            mailController.SetCcRecipients(cc);
            mailController.SetBccRecipients(bcc);

            var finished = new TaskCompletionSource <object>();
            var handler  = new EventHandler <MFComposeResultEventArgs>((snd, args) => finished.TrySetResult(args));

            try
            {
                mailController.Finished += handler;
                UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController(mailController, true, null);

                using (ct.Register(() => finished.TrySetCanceled()))
                {
                    await finished.Task;
                }
            }
            finally
            {
                await CoreDispatcher
                .Main
                .RunAsync(CoreDispatcherPriority.High, () =>
                {
                    mailController.Finished -= handler;
                    mailController.DismissViewController(true, null);
                })
                .AsTask(CancellationToken.None);
            }
#endif
        }
Esempio n. 45
0
		private void CreateMail(string html)
		{
			if (MFMailComposeViewController.CanSendMail) {
	            _mail = new MFMailComposeViewController ();
				_mail.NavigationBar.BarStyle = UIBarStyle.Black;
				_mail.Title = "Send e-post";
				_mail.SetSubject("Jaktrapport for " + jakt.Sted + " " + jakt.DatoFra.ToNorwegianDateAndYearString());
	            _mail.SetMessageBody (html, true);
	            _mail.Finished += HandleMailFinished;
				
				
				//Get e-mails:
				var selectedJegerIds = new List<int>();
				var jegerScreen = new JegerPickerScreen(jakt.JegerIds, screen => {
					selectedJegerIds = screen.jegerIds;
					//get email pr. jegerid
					if(selectedJegerIds.Count > 0){
						List<string> emails = new List<string>();
						foreach(var jegerId in selectedJegerIds){
							var jeger = JaktLoggApp.instance.JegerList.Where(j => j.ID == jegerId).FirstOrDefault();
							if(jeger.Email != "")
								emails.Add(jeger.Email);
							else
								MessageBox.Show("Kan ikke legge til e-post for " + jeger.Fornavn, "E-post adresse mangler i jegeroppsettet.");
						}
						if(emails.Count > 0)
							_mail.SetToRecipients(emails.ToArray());
						
					}
					this.PresentModalViewController (_mail, true);
				});
				jegerScreen.Title = "Velg mottakere";
				jegerScreen.Footer = "Jegerne du velger må ha registrert e-post";
				this.NavigationController.PushViewController(jegerScreen, true);

	            
	        } 
			else {
	        	MessageBox.Show("Beklager", "Denne enheten kan desverre ikke sende e-post");
	        }

		}
Esempio n. 46
0
        public void ComposeMail(string[] recipients, string subject, string messagebody = null, Action <bool> completed = null)
        {
            var controller = new MFMailComposeViewController();

            controller.SetToRecipients(recipients);
            controller.SetSubject(subject);
            if (!string.IsNullOrEmpty(messagebody))
            {
                controller.SetMessageBody(messagebody, false);
            }
            controller.Finished += (object sender, MFComposeResultEventArgs e) => {
                if (completed != null)
                {
                    completed(e.Result == MFMailComposeResult.Sent);
                }
                e.Controller.DismissViewController(true, null);
            };

            UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController(controller, true, null);
        }
Esempio n. 47
0
        public void Send_Email()  //Open email operation from VirtualDealershipAdviser application
        {
            if (MFMailComposeViewController.CanSendMail)
            {
                //If no issues open email application
                mailController = new MFMailComposeViewController();

                //mailController.SetToRecipients(new string[] { "default email 1,default email 2, etc. });  //Assign default emails
                mailController.SetSubject("Please take a look at this KPI");
                mailController.SetMessageBody(body_message, false);


                mailController.Finished += (object s, MFComposeResultEventArgs args) => {
                    args.Controller.DismissViewController(true, null);
                };

                PresentViewController(mailController, true, null);  //Transition to mail application
                PresentViewController(thankcontroller, true, null); //Display thank you alert
            }
        }
Esempio n. 48
0
        public override async Task ExecuteAsync()
        {
            await base.ExecuteAsync();

            if (string.IsNullOrWhiteSpace(Address))
            {
                return;
            }

            var fromVC = UIApplication.SharedApplication.Windows [0].RootViewController;

            var c = new MFMailComposeViewController();

            c.Finished += (sender, e) => c.DismissViewController(true, null);
            c.SetToRecipients(new [] { Address });
            c.SetSubject(Subject);
            c.SetMessageBody(BodyHtml, true);

            await fromVC.PresentViewControllerAsync(c, true);
        }
Esempio n. 49
0
        static Task PlatformComposeAsync(EmailMessage message)
        {
            // do this first so we can throw as early as possible
            var parentController = Platform.GetCurrentViewController();

            // create the controller
            var controller = new MFMailComposeViewController();

            if (!string.IsNullOrEmpty(message?.Body))
            {
                controller.SetMessageBody(message.Body, message?.BodyFormat == EmailBodyFormat.Html);
            }
            if (!string.IsNullOrEmpty(message?.Subject))
            {
                controller.SetSubject(message.Subject);
            }
            if (message?.To.Count > 0)
            {
                controller.SetToRecipients(message.To.ToArray());
            }
            if (message?.Cc.Count > 0)
            {
                controller.SetCcRecipients(message.Cc.ToArray());
            }
            if (message?.Bcc.Count > 0)
            {
                controller.SetBccRecipients(message.Bcc.ToArray());
            }

            // show the controller
            var tcs = new TaskCompletionSource <bool>();

            controller.Finished += (sender, e) =>
            {
                controller.DismissViewController(true, null);
                tcs.SetResult(e.Result == MFMailComposeResult.Sent);
            };
            parentController.PresentViewController(controller, true, null);

            return(tcs.Task);
        }
        void HandleShareOptionClicked(object sender, UIButtonEventArgs e)
        {
            UIActionSheet myActionSheet = sender as UIActionSheet;

            Console.WriteLine("Clicked on item {0}", e.ButtonIndex);
            if (e.ButtonIndex != myActionSheet.CancelButtonIndex)
            {
                string paperTitle   = paper.title;
                string urlTitle     = paper.url_title;
                string subject      = "White Paper Bible: " + paperTitle;
                string paperFullURL = "http://whitepaperbible.org/" + urlTitle;

                string messageCombined = subject + Environment.NewLine + paperFullURL;

                if (e.ButtonIndex == 1)
                {
                    //email
                    if (MFMailComposeViewController.CanSendMail)
                    {
                        MFMailComposeViewController _mail = new MFMailComposeViewController();
                        _mail.SetSubject(subject);
                        _mail.SetMessageBody(messageCombined, false);
                        _mail.Finished += HandleMailFinished;
                        this.PresentModalViewController(_mail, true);
                    }
                }
                else if (e.ButtonIndex == 2)
                {
                    TWTweetComposeViewController tweetComposer = new TWTweetComposeViewController();
                    tweetComposer.SetInitialText(paperTitle + " | " + paperFullURL);
                    this.PresentModalViewController(tweetComposer, true);
                }
                else if (e.ButtonIndex == 3)
                {
                    //facebook
                    string encodedURLString = HttpUtility.UrlEncode(paperFullURL);
                    string URLString        = @"http://www.facebook.com/sharer.php?u=" + encodedURLString;
                    UIApplication.SharedApplication.OpenUrl(NSUrl.FromString(URLString));
                }
            }
        }
Esempio n. 51
0
        void SendFeedback()
        {
            if (mailController != null)
            {
                mailController.Dispose();
                mailController = null;
            }

            Insights.Track("Tapped Feedback");
            if (!MFMailComposeViewController.CanSendMail)
            {
                Insights.Track("Feedback failed: No email");
                new AlertView(Strings.PleaseSendAnEmailTo, "*****@*****.**").Show(this);
                return;
            }
            mailController = new MFMailComposeViewController();
            mailController.SetToRecipients(new[] { "*****@*****.**" });
            var tintColor = UIApplication.SharedApplication.KeyWindow.TintColor;

            mailController.SetSubject(string.Format("Feedback: {0} - {1}", AppDelegate.AppName, versionNumber()));
            mailController.Finished += async(object s, MFComposeResultEventArgs args) =>
            {
                if (args.Result == MFMailComposeResult.Sent)
                {
                    new AlertView(Strings.ThankYou, Strings.YouShouldReceiveAReplyShortly_).Show(this);
                    Insights.Track("Feedback Sent");
                }
                else
                {
                    Insights.Track("Feedback failed", "Reason", args.Result.ToString());
                }
                await args.Controller.DismissViewControllerAsync(true);

                if (tintColor != null)
                {
                    UIApplication.SharedApplication.KeyWindow.TintColor = tintColor;
                }
            };
            UIApplication.SharedApplication.KeyWindow.TintColor = null;
            PresentViewController(mailController, true, null);
        }
Esempio n. 52
0
        private static async Task ComposeEmailWithMFAsync(EmailMessage message)
        {
            if (UIApplication.SharedApplication.KeyWindow?.RootViewController == null)
            {
                throw new InvalidOperationException("Root view controller is null, API called too early in the application lifecycle.");
            }

            var controller = new MFMailComposeViewController();

            if (!string.IsNullOrEmpty(message?.Body))
            {
                controller.SetMessageBody(message.Body, true);
            }

            if (!string.IsNullOrEmpty(message?.Subject))
            {
                controller.SetSubject(message.Subject);
            }

            if (message?.To?.Count > 0)
            {
                controller.SetToRecipients(
                    message.To.Select(r => r.Address).ToArray());
            }

            if (message?.CC?.Count > 0)
            {
                controller.SetCcRecipients(
                    message.CC.Select(cc => cc.Address).ToArray());
            }

            if (message?.Bcc?.Count > 0)
            {
                controller.SetBccRecipients(
                    message.Bcc.Select(bcc => bcc.Address).ToArray());
            }

            await UIApplication.SharedApplication.KeyWindow?.RootViewController.PresentViewControllerAsync(controller, true);

            await controller.DismissViewControllerAsync(true);
        }
Esempio n. 53
0
        public static void SendMail(UIViewController parent, string to, string subject, MailAttachment attachment, string body, NSAction onDone)
        {
            if (MFMailComposeViewController.CanSendMail)
            {
                mailCompose = new MFMailComposeViewController();

                mailCompose.SetSubject(subject);
                mailCompose.SetToRecipients(new string[] { to });
                if (attachment != null)
                {
                    NSData att = NSData.FromFile(attachment.Filename);
                    mailCompose.AddAttachmentData(att, attachment.FileType, attachment.EmailFilename);
                }
                mailCompose.SetMessageBody(body, false);
                mailCompose.Finished += delegate(object sender, MFComposeResultEventArgs e) {
                    mailCompose.DismissModalViewControllerAnimated(true);
                    onDone();
                };
                parent.PresentModalViewController(mailCompose, true);
            }
        }
        public void OpenFeedbackEmail()
        {
            MFMailComposeViewController mailController;

            if (MFMailComposeViewController.CanSendMail)
            {
                mailController = new MFMailComposeViewController();

                mailController.SetToRecipients(new string[] { "*****@*****.**" });
                mailController.SetSubject("Email Subject String");
                mailController.SetMessageBody("This text goes in the email body", false);

                mailController.Finished += (object s, MFComposeResultEventArgs args) =>
                {
                    args.Controller.DismissViewController(true, null);
                };

                var currentViewController = GetVisibleViewController();
                currentViewController.PresentViewController(mailController, true, null);
            }
        }
Esempio n. 55
0
        private void OnMailButtonClicked(object sender, EventArgs args)
        {
            if (!MFMailComposeViewController.CanSendMail)
            {
                Console.WriteLine("Can't send mail.");
                return;
            }

            _mailController = new MFMailComposeViewController();
            _mailController.SetToRecipients(new string[]{ _mail });
            _mailController.SetSubject("TouchInstinct Support");
            _mailController.SetMessageBody("Enter you message.", false);

            _mailController.Finished += (s, e) =>
            {
                Console.WriteLine(e.Result.ToString());
                e.Controller.DismissViewController(true, null);
            };

            PresentViewController(_mailController, true, null);
        }
Esempio n. 56
0
        void HandleSend(object sender, System.EventArgs eventArgs)
        {
            var mail = new MFMailComposeViewController();
            var body = string.Format("QR Code: {0}\r\nImages", ViewModel.BarcodeResult);

            mail.SetMessageBody(body, false);
            mail.SetSubject("Results");
            mail.SetToRecipients(new[] { "*****@*****.**" });
            int i = 0;

            foreach (var im in ViewModel.Images)
            {
                mail.AddAttachmentData(NSData.FromArray(im), "image/jpg", string.Format("im{0}.jpg", ++i));
            }
            if (ViewModel.Bytes != null)
            {
                mail.AddAttachmentData(NSData.FromArray(ViewModel.Bytes), "image/jpg", "combined.jpg");
            }
            mail.Finished += (s, e) => (s as UIViewController).DismissViewController(true, () => { });
            PresentViewController(mail, true, null);
        }
Esempio n. 57
0
 public void SendMail()
 {
     if (MFMailComposeViewController.CanSendMail)
     {
         mail = new MFMailComposeViewController();
         mail.SetSubject(Subject);
         mail.SetMessageBody(Body, false);
         mail.Finished += (sender, e) =>
         {
             var finished = OnFinished;
             if (finished != null)
             {
                 finished(this, EventArgs.Empty);
             }
             mail.Dispose();
             mail = null;
             controller.NavigationController.DismissModalViewControllerAnimated(true);
         };
         controller.NavigationController.PresentModalViewController(mail, true);
     }
 }
Esempio n. 58
0
        public void sendMail(string email)
        {
            MFMailComposeViewController mailController;

            if (MFMailComposeViewController.CanSendMail)
            {
                // do mail operations here
                mailController = new MFMailComposeViewController();
                mailController.SetToRecipients(new string[] { email });
                mailController.SetSubject("Adecco Nederland Branch Query");
                mailController.SetMessageBody("this is a test", false);

                mailController.Finished += (object s, MFComposeResultEventArgs args) =>
                {
                    Console.WriteLine(args.Result.ToString());
                    args.Controller.DismissViewController(true, null);
                };

                this.PresentViewController(mailController, true, null);
            }
        }
Esempio n. 59
0
        public void SendEmail(IEmailMessage email)
        {
            if (email == null)
            {
                throw new ArgumentNullException(nameof(email));
            }

            if (CanSendEmail)
            {
                MFMailComposeViewController _mailController;
                _mailController = new MFMailComposeViewController();
                _mailController.SetSubject(email.Subject);
                _mailController.SetMessageBody(email.Message, ((EmailMessage)email).IsHtml);
                _mailController.SetToRecipients(email.Recipients.ToArray());

                if (email.RecipientsCc.Count > 0)
                {
                    _mailController.SetCcRecipients(email.RecipientsCc.ToArray());
                }

                if (email.RecipientsBcc.Count > 0)
                {
                    _mailController.SetBccRecipients(email.RecipientsBcc.ToArray());
                }

                foreach (var attachment in email.Attachments.Cast <EmailAttachment>())
                {
                    if (attachment.File == null)
                    {
                        _mailController.AddAttachmentData(NSData.FromFile(attachment.FilePath), attachment.ContentType, attachment.FileName);
                    }
                    else
                    {
                        _mailController.AddAttachmentData(NSData.FromUrl(attachment.File), attachment.ContentType, attachment.FileName);
                    }
                }

                Settings.EmailPresenter.PresentMailComposeViewController(_mailController);
            }
        }
Esempio n. 60
0
        public void sendEmails(string To, string Subject, string Body, Page page)
        {
            MFMailComposeViewController mailController;

            if (MFMailComposeViewController.CanSendMail)
            {
                mailController = new MFMailComposeViewController();

                mailController.SetToRecipients(new string[] { To });
                mailController.SetSubject(Subject);
                mailController.SetMessageBody(Body, false);

                mailController.Finished += (object s, MFComposeResultEventArgs args) =>
                {
                    Console.WriteLine(args.Result.ToString());
                    args.Controller.DismissViewController(true, null);
                };

                UIViewController uivc = new UIViewController();
                uivc.PresentViewController(mailController, false, null);
            }
        }