当前位置: 首页>>代码示例>>C#>>正文


C# IEmailService.ShowDraft方法代码示例

本文整理汇总了C#中IEmailService.ShowDraft方法的典型用法代码示例。如果您正苦于以下问题:C# IEmailService.ShowDraft方法的具体用法?C# IEmailService.ShowDraft怎么用?C# IEmailService.ShowDraft使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IEmailService的用法示例。


在下文中一共展示了IEmailService.ShowDraft方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: EmailPage

		/// <summary>
		/// Initializes a new instance of the <see cref="EmailPage"/> class.
		/// </summary>
		public EmailPage()
		{
			Padding = new Thickness(0, Device.OnPlatform(20, 0, 0), 0, 0);

			_emailService = Resolver.Resolve<IEmailService>();

			SetupCamera();

			Status = "Ready";

			var stack = new StackLayout();

			if (_emailService == null || !_emailService.CanSend)
			{
				stack.Children.Add(new Label
				{
					TextColor = Color.Red,
					Text = "No Email support",
				});
			}
			else
			{
				var buttonTakePicture = new Button
				{
					Text = "Take Picture",
				};

				var buttonSendEmail = new Button
				{
					Text = "Send Email",
				};

				var buttonSendEmailWithAttachment = new Button
				{
					Text = "Send Email with Attachment",
					IsEnabled = false,
				};

				buttonTakePicture.Clicked += async (sender, args) =>
				{
					await TakePicture();

					buttonSendEmailWithAttachment.IsEnabled = !string.IsNullOrEmpty(_path);
				};

				buttonSendEmail.Clicked += (sender, args) => _emailService.ShowDraft(
									"Test Subject",
									"Test Body",
									true,
									string.Empty,
									Enumerable.Empty<string>());

				buttonSendEmailWithAttachment.Clicked += (sender, args) =>
				{
					if (string.IsNullOrEmpty(_path))
					{
						DisplayAlert("Error", "You must first take a pictures.", null, "OK");
					}
					else
					{
						_emailService.ShowDraft(
							"Test Subject",
							"Test Body",
							true,
							string.Empty,
							new List<string> { _path });
					}
				};

				var labelStatus = new Label
				{
					Text = string.Empty,
					VerticalOptions = LayoutOptions.EndAndExpand,
					HorizontalOptions = LayoutOptions.StartAndExpand
				};

				labelStatus.SetBinding(Label.TextProperty, new Binding(Status));

				stack.Children.Add(buttonTakePicture);
				stack.Children.Add(buttonSendEmail);
				stack.Children.Add(buttonSendEmailWithAttachment);
				stack.Children.Add(labelStatus);
			}

			Content = stack;
		}
开发者ID:nrogoff,项目名称:Xamarin-Forms-Labs,代码行数:89,代码来源:EmailPage.cs


注:本文中的IEmailService.ShowDraft方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。