0

I'm develop a windows store app using winRT C++. 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.

Some programmer dude
  • 400,186
  • 35
  • 402
  • 621

2 Answers2

2

There is no way to do that in 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.

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. 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).

Peter Torr - MSFT
  • 11,824
  • 3
  • 18
  • 51
0

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. I would recommend also keeping sharing as an option in case your users want to send the content using Facebook or Twitter instead.