问题描述
使用以下代码从通用应用程序发送附件无法正常工作,为什么?
将emailMessage设为新的EmailMessage( )
emailMessage。[收件人] .Add(新的EmailRecipient( [email protected]))
emailMessage.Subject =测试
emailMessage.Body = Hello World
Dim localAppFolder = Windows.Storage.ApplicationData.Current.LocalFolder
Dim文件=等待localAppFolder.CreateFileAsync( SomeFile.txt,Windows.Storage.CreationCollisionOption.ReplaceExisting)
等待Windows .Storage.FileIO.WriteTextAsync(file, aaaa)
Dim fileRef = RandomAccessStreamReference.CreateFromFile(file)
emailMessage.Attachments.Add(New EmailAttachment(file.Name,fileRef))
等待EmailManager.ShowComposeNewEmailAsync(emailMessage)
收件人,主题和正文在Outlook中显示正常,但附件为丢失:
如果以前选择了Desktop Outlook应用作为mailto协议的默认应用程序,则必须更改mailto:协议关联的默认应用程序在控制面板中。
以前,仅适用于Windows Phone运行时应用程序。而且它不是文档中的最新内容,因为它不包含win 10支持。
在Windows 10移动版上,它运行良好,没有任何问题。但是在Windows桌面上,您必须选择一个商店应用。
Sending an attachment from a universal app with the following code is not working, why?
Dim emailMessage As New EmailMessage()
emailMessage.[To].Add(New EmailRecipient("[email protected]"))
emailMessage.Subject = "Test"
emailMessage.Body = "Hello World"
Dim localAppFolder = Windows.Storage.ApplicationData.Current.LocalFolder
Dim file = Await localAppFolder.CreateFileAsync("SomeFile.txt", Windows.Storage.CreationCollisionOption.ReplaceExisting)
Await Windows.Storage.FileIO.WriteTextAsync(file, "aaaa")
Dim fileRef = RandomAccessStreamReference.CreateFromFile(file)
emailMessage.Attachments.Add(New EmailAttachment(file.Name, fileRef))
Await EmailManager.ShowComposeNewEmailAsync(emailMessage)
To, subject and body show fine in Outlook, but the attachment is missing: Outlook screenshot
I believe it is because the Outlook is a Desktop app. As I understood, the EmailManager.ShowComposeNewEmailAsync
uses mailto: protocal to launch mail client app and use share to provide the email content.
If you choose the mail store app when the select default app dialog launches, you will be able to see the attachment as following:
If you have previously chosen Desktop Outlook app as the default as for mailto protocol, you have to change the default app for the mailto: protocol association in control panel .
Previously, the ShowComposeNewEmailAsync only works for windows phone runtime app. And it is not up-to-date in the document, because it doesn't include the win 10 support.
On Windows 10 mobile, it works well without any problem. But on Windows Desktop, you have to choose a store app.
这篇关于通过UWP EmailManager发送电子邮件附件不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!