public void AddPictureAttachments(MFMailComposeViewController mailContr, bool items) { var documentsDirectory = Environment.GetFolderPath (Environment.SpecialFolder.Personal); IList<LagerObject> storeting = AppDelegate.dao.LoadBigItems(); foreach(LagerObject lobj in storeting){ if (!string.IsNullOrEmpty (lobj.imageFileName)) { string jpg = lobj.Name + ".jpg"; string filename = System.IO.Path.Combine (documentsDirectory, lobj.imageFileName); UIImage image = UIImage.FromFile (filename); NSData imagedata = image.AsJPEG (); mailContr.AddAttachmentData (imagedata, "image/jpeg", jpg); } } if(items){ IList<Item> itemsList = AppDelegate.dao.GetAllItems(); foreach(Item it in itemsList){ if (!string.IsNullOrEmpty (it.ImageFileName)) { string jpg = it.Name + ".jpg"; string filename = System.IO.Path.Combine (documentsDirectory, it.ImageFileName); UIImage image = UIImage.FromFile (filename); NSData imagedata = image.AsJPEG (); mailContr.AddAttachmentData (imagedata, "image/jpeg", jpg); } } } }
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; }
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; }; }
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); }; } }
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 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 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); } }
public override void ViewDidLoad () { base.ViewDidLoad (); tv.BecomeFirstResponder (); toolbar.Items[0].Clicked += (o, s) => { string text = tv.Text; NSData pdfData = CreatePDF (text, 500f, 700f); if (MFMailComposeViewController.CanSendMail) { _mail = new MFMailComposeViewController (); _mail.SetMessageBody (tv.Text, false); _mail.AddAttachmentData (pdfData, "text/x-pdf", "test.pdf"); _mail.Finished += HandleMailFinished; this.PresentModalViewController (_mail, true); } else { UIAlertView alert = new UIAlertView ("App", "Could not send mail.", null, "OK", null); alert.Show (); } }; toolbar.Items[1].Clicked += (o, s) => { _pdf = new PDFViewController (tv.Text); this.PresentModalViewController (_pdf, true); }; }
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 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); }
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 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); }
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); }
private Element Generate(StudentGuideModel item) { var root=new RootElement(item.Title); var section=new Section(item.Title); root.Add (section); if (item.Phone!="") { var phoneStyle = new StyledStringElement("Contact Number",item.Phone) { BackgroundColor=UIColor.FromRGB(71,165,209), TextColor=UIColor.White, DetailColor=UIColor.White, }; phoneStyle.Tapped+= delegate { UIAlertView popup = new UIAlertView("Alert","Do you wish to send a text or diall a number?",null,"Cancel","Text","Call"); popup.Show(); popup.Dismissed += delegate(object sender, UIButtonEventArgs e) { if (e.ButtonIndex==1) { MFMessageComposeViewController msg = new MFMessageComposeViewController(); msg.Recipients=new string[] {item.Phone}; this.NavigationController.PresentViewController(msg,true,null); } else if (e.ButtonIndex==2) { AppDelegate.getControl.calling(item.Phone); }; }; }; section.Add(phoneStyle); }; if (item.Email!="") { var style = new StyledStringElement("Contact Email",item.Email) { BackgroundColor=UIColor.FromRGB(71,165,209), TextColor=UIColor.White, DetailColor=UIColor.White, }; style.Tapped += delegate { MFMailComposeViewController email = new MFMailComposeViewController(); email.SetToRecipients(new string[] {item.Email}); this.NavigationController.PresentViewController(email,true,null); }; section.Add (style); } if (item.Address!="") { section.Add(new StyledMultilineElement(item.Address) { BackgroundColor=UIColor.FromRGB(71,165,209), TextColor=UIColor.White, DetailColor=UIColor.White, }); } if (item.Description!="") { section.Add (new StyledMultilineElement(item.Description) { BackgroundColor=UIColor.FromRGB(71,165,209), TextColor=UIColor.White, DetailColor=UIColor.White, Alignment=UITextAlignment.Center, }); } return root; }
public override void ViewDidLoad() { base.ViewDidLoad (); _mailController = new MFMailComposeViewController(); this.PresentViewController(_mailController,true,null); // Perform any additional setup after loading the view, typically from a nib. }
private void SendMessage(object sender, EventArgs e) { if (MFMailComposeViewController.CanSendMail) { var mailController = new MFMailComposeViewController (); mailController.SetToRecipients (new string[] { "*****@*****.**" }); mailController.Finished += (finishSender, finishE) => { finishE.Controller.DismissViewController (true, null); }; this.PresentViewController (mailController, true, null); } }
public void AddQRPictureAttachment(MFMailComposeViewController mailContr, LagerObject input) { if (this.IncludeQr()) { if (input != null) { UIImage image = AppDelegate.key.MakeQr (input); NSData imagedata = image.AsPNG (); mailContr.AddAttachmentData (imagedata, "image/png", "QR.png"); } } }
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); }
public void AddPictureAttachment(MFMailComposeViewController mailContr, Item input) { var documentsDirectory = Environment.GetFolderPath (Environment.SpecialFolder.Personal); if (!string.IsNullOrEmpty (input.ImageFileName)) { string jpg = input.Name + ".jpg"; string filename = System.IO.Path.Combine (documentsDirectory, input.ImageFileName); UIImage image = UIImage.FromFile (filename); NSData imagedata = image.AsJPEG (); mailContr.AddAttachmentData (imagedata, "image/jpeg", jpg); } }
void OnEmailSelected(string emailAddress) { if (MFMailComposeViewController.CanSendMail) { var composer = new MFMailComposeViewController (); composer.SetToRecipients (new string[] { emailAddress }); composer.Finished += (sender, e) => DismissViewController (true, null); PresentViewController (composer, true, null); } else { new UIAlertView ("Oops", "Email is not available", null, "Ok").Show (); } }
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; }
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 override void ViewDidLoad() { base.ViewDidLoad (); _mailComposeViewController = new MFMailComposeViewController(); _mailComposeViewController.Finished += (object sender, MFComposeResultEventArgs e) => {}; _mailComposeViewController.View.Frame = new RectangleF(0,0,this.View.Bounds.Width, this.View.Bounds.Height); this.PresentViewController(_mailComposeViewController,false,null); // Perform any additional setup after loading the view, typically from a nib. }
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, () => { }); }; }
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; }
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 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; } }
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); }
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("Setup your mail please"); } }
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 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 { } }
public void PresentMailComposeViewController(MFMailComposeViewController mailController) { void handler(object sender, MFComposeResultEventArgs e) { mailController.Finished -= handler; var uiViewController = sender as UIViewController; if (uiViewController == null) { throw new ArgumentException("sender"); } uiViewController.DismissViewController(true, () => { }); } mailController.Finished += handler; mailController.PresentUsingRootViewController(); }
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); } }
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...")); }
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 } }
public void TextShadowOffset_7443() { if (!MFMailComposeViewController.CanSendMail) { Assert.Inconclusive("Not configured to send emails"); } #if XAMCORE_3_0 var cancelAttributes = new UIStringAttributes(); #else var cancelAttributes = new UITextAttributes(); cancelAttributes.TextShadowOffset = new UIOffset(0, -1); #endif UIBarButtonItem.AppearanceWhenContainedIn(typeof(UISearchBar)).SetTitleTextAttributes(cancelAttributes, UIControlState.Disabled); using (var mail = new MFMailComposeViewController()) { // we're happy the .ctor did not crash (only on iOS6) because the dictionary had a null key (typo) Assert.That(mail.Handle, Is.Not.EqualTo(IntPtr.Zero)); } }
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."); } }); }
/* **************************************** 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); }; } }
/// <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); }
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); }
public override void ViewDidLoad() { base.ViewDidLoad(); txttitulo.Text = tituloDocumento; if (File.Exists(urlDocumento)) { var bounds = UIScreen.MainScreen.Bounds; loadPop = new LoadingOverlay(bounds, "Obteniendo Archivo ..."); this.Add(loadPop); webViewDocs.LoadRequest(new NSUrlRequest(new NSUrl(urlDocumento, false))); webViewDocs.ScalesPageToFit = true; } else { funciones.MessageBox("Aviso", "El archivo " + urlDocumento + " no existe"); } webViewDocs.LoadFinished += delegate { loadPop.Hide(); }; if (MFMailComposeViewController.CanSendMail) { mailCtrl = new MFMailComposeViewController(); mailCtrl.Finished += (object sender, MFComposeResultEventArgs e) => { Console.WriteLine(e.Result.ToString()); e.Controller.DismissViewController(true, null); }; btnMail.TouchUpInside += sendMail; } else { btnMail.TouchUpInside += delegate { funciones.MessageBox("Error", "No se puede mandar mail"); }; } }
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 }
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); }
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 } }
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); }
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)); } } }
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); }
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); }
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); }
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); } }
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); }
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); } }
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); } }
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); } }
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); } }
public EnterpriseSupportViewController(IAlertDialogFactory alertDialogFactory) { this.WhenAnyValue(x => x.ViewModel.SubmitFeedbackCommand) .Switch() .Subscribe(_ => { var ctrl = new MFMailComposeViewController(); ctrl.SetSubject("CodeHub Support"); ctrl.SetToRecipients(new [] { "*****@*****.**" }); ctrl.Finished += (sender, e) => DismissViewController(true, () => { if (e.Result == MFMailComposeResult.Sent) { alertDialogFactory.Alert("Sent!", "Thanks for your feedback!"); } }); PresentViewController(ctrl, true, null); }); Appearing .Select(_ => NavigationController) .Where(x => x != null) .Subscribe(x => x.NavigationBar.ShadowImage = new UIImage()); }
public virtual Task ComposeEmail(IEmailMessage emailMessage) { if (!CanComposeEmail) { throw new FeatureNotAvailableException(); } var mailer = new MFMailComposeViewController(); mailer.SetToRecipients(emailMessage.To.ToArray()); mailer.SetCcRecipients(emailMessage.Cc.ToArray()); mailer.SetBccRecipients(emailMessage.Bcc.ToArray()); mailer.SetSubject(emailMessage.Subject); mailer.SetMessageBody(emailMessage.Body, emailMessage.IsHTML); mailer.Finished += (s, e) => ((MFMailComposeViewController)s).DismissViewController(true, () => { }); UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController(mailer, true, null); return(Task.FromResult(true)); }