locked
How to programmatically set a "To" field(recipient) in mail app using sharing data?

    Question

  • How to programmatically set a "To" field(recipient) in mail app using sharing data?
    Currently used Win8 Release Preview 8400, and I found that sharing only text or only images.

    Is any other way to share multiple contents? Is Win8 RTM supports all these?

     

    Sample code

    // Register the DataRequested event.

    DataRequested += ref new TypedEventHandler<DataTransferManager^, DataRequestedEventArgs^>(this, &Mainpage::OnDataRequested);

     

    // DataRequested handler

    void Mainpage::OnDataRequested(DataTransferManager^ sender, DataRequestedEventArgs^ e)

    {

           auto requestData = e->Request;

           requestData->Properties->Title = "Test";

           requestData->Properties->Description = "Description";

     

           requestData->SetText(L"Test message");

           requestData->SetStorageItems(dynamic_cast<IIterable<IStorageItem^>^>(storageItems));

    }

    Thursday, September 06, 2012 11:06 AM

Answers

  • The purpose of the share contract is to let the user choose to share to anybody through any share target. The app cannot control which share target or contact is used. If your goal is to send to a specific address rather than to provide data for the user to share as the user wants then you can't use the share contract; you may be better off launching a mailto: protocol or connecting to a specific web service.

    It is up to the share target to pick which ones it will use and how to use them. The base OS supports all of the types represented in the DataRequest plus custom types, but individual share targets will only support the ones which are relevant to them.

    --Rob

    Thursday, September 06, 2012 4:01 PM
    Owner

All replies

  • Hi all,

    How to programmatically set a "To" field(recipient) in mail app using sharing data?
    Currently used Win8 Release Preview 8400, and I found that sharing only text or only images. 
    Is any other way to share multiple contents? Is Win8 RTM supports all these?

    // Register the DataRequested event.
    DataRequested += ref new TypedEventHandler<DataTransferManager^, DataRequestedEventArgs^>(this, &Mainpage::OnDataRequested);
    
    // DataRequested handler
    void Mainpage::OnDataRequested(DataTransferManager^ sender, DataRequestedEventArgs^ e)
    {
    	auto requestData = e->Request;
    requestData->Properties->Title = "Test";
    	requestData->Properties->Description = "Description";
    
    requestData->SetText(L"Test message");
    requestData->SetStorageItems(dynamic_cast<IIterable<IStorageItem^>^>(storageItems));
    }


    Thanks,
    Anil.S

    Thursday, September 06, 2012 10:22 AM
  • The purpose of the share contract is to let the user choose to share to anybody through any share target. The app cannot control which share target or contact is used. If your goal is to send to a specific address rather than to provide data for the user to share as the user wants then you can't use the share contract; you may be better off launching a mailto: protocol or connecting to a specific web service.

    It is up to the share target to pick which ones it will use and how to use them. The base OS supports all of the types represented in the DataRequest plus custom types, but individual share targets will only support the ones which are relevant to them.

    --Rob

    Thursday, September 06, 2012 4:01 PM
    Owner
  • Rob, Thanks for your reply & I need to send attachment along with mail, so launching url "mailto" not possible i think. Please Help
    • Edited by AnilKumar.S Monday, September 10, 2012 10:49 AM Very Urgent
    Friday, September 07, 2012 3:27 AM