简体   繁体   English

如何将文件共享到特定的电子邮件地址

[英]How to Share File to specific email address

I'm develop a windows store app using winRT C++. 我正在使用WinRT C ++开发Windows商店应用程序。 I can share a file through email but it cannot specific a receiver email address. 我可以通过电子邮件共享文件,但不能指定收件人的电子邮件地址。 Bellow is a part of my code to sharing a file:- 贝娄是我共享文件的代码的一部分:-

DataRequest^ request = e->Request;
request->Data->Properties->Title = "Testing";
request->Data->Properties->Description = "Email With Attachment";

DataRequestDeferral^ deferral = request->GetDeferral();
create_task(Windows::ApplicationModel::Package::Current->InstalledLocation->GetFileAsync("testing.pdf")).then([this, request, deferral](task<StorageFile^> getFileTask)
{
    try
    {
        auto pdfFile = getFileTask.get();
        auto storageItems = ref new Platform::Collections::Vector<IStorageItem^>();
        storageItems->Append(pdfFile);
        request->Data->SetStorageItems(storageItems);
        deferral->Complete();
    }
    catch (Exception^ ex)
    {
        // Calling FailWithDisplayText() also calls Complete on the deferral.
        request->FailWithDisplayText(ex->Message);
    }
});

How can I send the attachment file to a specific email receiver without fill in the email address manually. 如何将附件文件发送到特定的电子邮件收件人,而无需手动填写电子邮件地址。

There is no way to do that in Windows 8; 在Windows 8中无法做到这一点。 you can either share the file (as in the code above) or you can send an e-mail to an explicit address (using LaunchUriAsync with a mailto: URI) but you cannot do both. 您可以共享文件(如上面的代码中所述),也可以将电子邮件发送到显式地址(使用LaunchUriAsyncmailto: URI),但是您不能两者都做。

Note that Share Target apps can ask the system to remember recent / frequent targets , so if the user has e-mailed bob@foo.com recently then that might appear as a direct option in the Share Picker. 请注意,“共享目标”应用程序可能会要求系统记住最近/经常使用的目标 ,因此,如果用户最近通过电子邮件发送了bob@foo.com,则它可能会作为“共享选择器”中的直接选项出现。 The built-in mail app uses this feature. 内置邮件应用程序使用此功能。

Another low-fi option is to copy the e-mail address to the clipboard and ask the user to simply paste it in when the e-mail app launches (or copy the file to the clipboard and use the mailto: approach). 另一个低保真的选择是将电子邮件地址复制到剪贴板,并要求用户在启动电子邮件应用程序时简单地将其粘贴(或将文件复制到剪贴板并使用mailto:方法)。

It sounds like all you want to do is create a new email message with a specific recipient. 听起来您要做的就是与特定收件人一起创建新的电子邮件。 The easiest way to do this is to use the EmailManager.ShowComposeNewEmailAsync API. 最简单的方法是使用EmailManager.ShowComposeNewEmailAsync API。 I would recommend also keeping sharing as an option in case your users want to send the content using Facebook or Twitter instead. 如果您的用户希望使用Facebook或Twitter发送内容,我还建议保留共享作为一种选择。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM