我想通过我的UWP 10应用发送电子邮件。这是我使用的代码,但我什么也没得到,项目崩溃了(我也不知道在xaml页面放什么)
private async void SendEmailButton_Click(object sender, RoutedEventArgs e)
{
EmailMessage emailMessage = new EmailMessage();
emailMessage.To.Add(new EmailRecipient("***@***.com"));
string messageBody = "Hello World";
emailMessage.Body = messageBody;
await EmailManager.ShowComposeNewEmailAsync(emailMessage);
}
PS:我不需要在我的电子邮件中发送附件 我在调试器中得到的内容
' EmailTest1.exe' (CoreCLR:DefaultDomain):已加载' C:\ data \ Programs \ WindowsApps \ Microsoft.NET.CoreRuntime.1.0_1.0.23430.0_x86__8wekyb3d8bbwe \ mscorlib.ni.dll'。无法找到或打开PDB文件。 ' EmailTest1.exe' (CoreCLR:CoreCLR_UWP_Domain):已加载' C:\ Data \ SharedData \ PhoneTools \ AppxLayouts \ dc12aef2-b53e-4795-a606-9afcd5298032VS.Debug_x86.X \ entrypoint \ EmailTest1.exe'。符号已加载。 ' EmailTest1.exe' (CoreCLR:CoreCLR_UWP_Domain):已加载' C:\ Data \ SharedData \ PhoneTools \ AppxLayouts \ dc12aef2-b53e-4795-a606-9afcd5298032VS.Debug_x86.X \ System.Runtime.dll'。无法找到或打开PDB文件。 ' EmailTest1.exe' (CoreCLR:CoreCLR_UWP_Domain):已加载' C:\ Data \ SharedData \ PhoneTools \ AppxLayouts \ dc12aef2-b53e-4795-a606-9afcd5298032VS.Debug_x86.X \ WinMetadata \ Windows.winmd'。模块没有符号。 ' EmailTest1.exe' (CoreCLR:CoreCLR_UWP_Domain):已加载' C:\ Data \ SharedData \ PhoneTools \ AppxLayouts \ dc12aef2-b53e-4795-a606-9afcd5298032VS.Debug_x86.X \ System.Runtime.InteropServices.WindowsRuntime.dll'。无法找到或打开PDB文件。 ' EmailTest1.exe' (CoreCLR:CoreCLR_UWP_Domain):已加载' C:\ Data \ SharedData \ PhoneTools \ AppxLayouts \ dc12aef2-b53e-4795-a606-9afcd5298032VS.Debug_x86.X \ Microsoft.ApplicationInsights.Extensibility.Windows.dll'。无法找到或打开PDB文件。 ' EmailTest1.exe' (CoreCLR:CoreCLR_UWP_Domain):已加载' C:\ Data \ SharedData \ PhoneTools \ AppxLayouts \ dc12aef2-b53e-4795-a606-9afcd5298032VS.Debug_x86.X \ System.Threading.Tasks.dll'。无法找到或打开PDB文件。 ' EmailTest1.exe' (CoreCLR:CoreCLR_UWP_Domain):已加载' C:\ Data \ SharedData \ PhoneTo.X \ Microsoft.ApplicationInsights.dll'。无法找到或打开PDB文件。 ' EmailTest1.exe' (CoreCLR:CoreCLR_UWP_Domain):已加载' C:\ Data \ SharedData \ PhoneTools \ AppxLayouts \ dc12aef2-b53e-4795-a606-9afcd5298032VS.Debug_x86.X \ System.Runtime.WindowsRuntime.dll'。无法找到或打开PDB文件。 ' EmailTest1.exe' (CoreCLR:CoreCLR_UWP_Domain):已加载' C:\ Data \ SharedData \ PhoneTools \ AppxLayouts \ dc12aef2-b53e-4795-a606-9afcd5298032VS.Debug_x86.X \ System.Diagnostics.Debug.dll'。无法找到或打开PDB文件。 ' EmailTest1.exe' (CoreCLR:CoreCLR_UWP_Domain):已加载' C:\ Data \ SharedData \ PhoneTools \ AppxLayouts \ dc12aef2-b53e-4795-a606-9afcd5298032VS.Debug_x86.X \ System.Runtime.WindowsRuntime.UI.Xaml.dll' 。无法找到或打开PDB文件。 ' EmailTest1.exe' (CoreCLR:CoreCLR_UWP_Domain):已加载' C:\ Data \ SharedData \ PhoneTools \ AppxLayouts \ dc12aef2-b53e-4795-a606-9afcd5298032VS.Debug_x86.X \ System.Collections.dll'。无法找到或打开PDB文件。 ' EmailTest1.exe' (CoreCLR:CoreCLR_UWP_Domain):已加载' C:\ Data \ SharedData \ PhoneTools \ AppxLayouts \ dc12aef2-b53e-4795-a606-9afcd5298032VS.Debug_x86.X \ System.Private.Uri.dll'。无法找到或打开PDB文件。 ' EmailTest1.exe' (CoreCLR:CoreCLR_UWP_Domain):已加载' C:\ Data \ SharedData \ PhoneTools \ AppxLayouts \ dc12aef2-b53e-4795-a606-9afcd5298032VS.Debug_x86.X \ Microsoft.ApplicationInsights.PersistenceChannel.dll'。无法找到或打开PDB文件。 ' EmailTest1.exe' (CoreCLR:CoreCLR_UWP_Domain):已加载' C:\ Data \ SharedData \ PhoneTools \ AppxLayouts \ dc12aef2-b53e-4795-a606-9afcd5298032VS.Debug_x86.X \ System.Threading.dll'。无法找到或打开PDB文件。 ' EmailTest1.exe' (CoreCLR:CoreCLR_UWP_Domain):已加载' C:\ Data \ SharedData \ PhoneTools \ AppxLayouts \ dc12aef2-b53e-4795-a606-9afcd5298032VS.Debug_x86.X \ System.Diagnostics.Tracing.dll'。模块没有符号。 ' EmailTest1.exe' (CoreCLR:CoreCLR_UWP_Domain):已加载' C:\ Data \ SharedData \ PhoneTools \ AppxLayouts \ dc12aef2-b53e-4795-a606-9afcd5298032VS.Debug_x86.X \ System.Linq.dll'。无法找到或打开PDB文件。 ' EmailTest1.exe' (CoreCLR:CoreCLR_UWP_Domain):已加载' C:\ Data \ SharedData \ PhoneTools \ AppxLayouts \ dc12aef2-b53e-4795-a606-9afcd5298032VS.Debug_x86.X \ System.IO.dll'。无法找到或打开PDB文件。 ' EmailTest1.exe' (CoreCLR:CoreCLR_UWP_Domain):已加载' C:\ Data \ SharedData \ PhoneTools \ AppxLayouts \ dc12aef2-b53e-4795-a606-9afcd5298032VS.Debug_x86.X \ System.Globalization.dll'。模块没有符号。 ' EmailTest1.exe' (CoreCLR:CoreCLR_UWP_Domain):已加载' C:\ Data \ SharedData \ PhoneTools \ AppxLayouts \ dc12aef2-b53e-4795-a606-9afcd5298032VS.Debug_x86.X \ System.Runtime.Extensions.dll'。无法找到或打开PDB文件。 ' EmailTest1.exe' (CoreCLR:CoreCLR_UWP_Domain):已加载' C:\ Data \ SharedData \ PhoneTools \ AppxLayouts \ dc12aef2-b53e-4795-a606-9afcd5298032VS.Debug_x86.X \ System.Reflection.dll'。模块没有符号。 ' EmailTest1.exe' (CoreCLR:CoreCLR_UWP_Domain):已加载' C:\ Data \ SharedData \ PhoneTools \ AppxLayouts \ dc12aef2-b53e-4795-a606-9afcd5298032VS.Debug_x86.X \ System.Reflection.Extensions.dll'。模块没有符号。 线程0xd84已退出,代码为0(0x0)。 线程0xc6c已退出,代码为0(0x0)。
谢谢你
答案 0 :(得分:1)
private async void SendEmailButton_Click(object sender, RoutedEventArgs e)
{
EmailMessage emailMessage = new EmailMessage();
emailMessage.To.Add(new EmailRecipient("***@***.com"));
string messageBody = "Hello World";
emailMessage.Body = messageBody;
await EmailManager.ShowComposeNewEmailAsync(emailMessage);
}
以上内容仅适用于Windows 8.1应用程序,它已从Win 10 Universal SDK中删除, 要从您的应用程序发送Windows 10中的电子邮件,您可以直接连接到手机上的Outlook应用程序。要这样做你必须使用 在你的sendemail_click事件中写这样的
DataTransferManager dataTransferManager = DataTransferManager.GetForCurrentView();
dataTransferManager.DataRequested+=DataRequested;
DataTransferManager.ShowShareUI();
private void DataRequested(DataTransferManager sender,DataRequestedEventArgs e)
{
DataRequest request = e.Request;
request.Data.Properties.Title = "Share Text Example";
request.Data.Properties.Description = "An example of how to share text.";
request.Data.SetText("Hello World!");
}