locked
Share Contract In Windows App Using Winjs RRS feed

  • Question

  • Hi,

    First of all is there any way to attach a audio file from my application  to mail application while using mailto: link.

    I am trying to share an audio which is recorded in my application to mail app.

    But it is getting shared as a BitMap file.

    How i can share a audio file from my appdata to mail app.

    Below is the code that i am using to share audio file.

    var dataTransferManager = Windows.ApplicationModel.DataTransfer.DataTransferManager.getForCurrentView();
                dataTransferManager.addEventListener("datarequested", shareTextHandler);
    
    
    
    function onDeferredAudioRequested(request) {
        try {
    //audioFile represents the recorded audio which is retrieved using getFileAsync() 
            if (audioFile) {
                // This is to make sure deferral works even in synchronous case
                var deferral = request.getDeferral();
                var audioStreamRef= Windows.Storage.Streams.RandomAccessStreamReference.createFromFile(audioFile);
                request.setData(audioStreamRef);
                deferral.complete();
            }
        } catch (exc) {
            // Error handling goes here.
        }
    }
    
    function shareTextHandler(e) {
        var request = e.request;
        request.data.properties.title = "Share Text Example";
        request.data.properties.description = "A demonstration that shows how to share.";
        request.data.setText("Hello World!");
        request.data.properties.fileTypes.replaceAll(["m4a"]);
        request.data.setDataProvider(Windows.ApplicationModel.DataTransfer.StandardDataFormats.bitmap, onDeferredAudioRequested);
    
    }
    

    But the above code is sharing the '.m4a' file as a bitmap file.

    Any Solution.

    Thursday, March 13, 2014 3:34 PM

Answers

  • No, you cannot attach files with a mailto: link (probably: it actually depends on the user's selected mail client).

    Your code snippet is sharing as a bitmap because you're telling it you're sharing a bitmap when you pass StandardDataFormats.bitmap.

    There is no primary audio type, but you can share the audio file as a file with request.data.setStorageItems([audioFile]);

    See How to share files for more details.

    --Rob

    • Marked as answer by JERRY MANALIL Friday, March 14, 2014 5:59 AM
    Friday, March 14, 2014 4:05 AM
    Moderator

All replies

  • No, you cannot attach files with a mailto: link (probably: it actually depends on the user's selected mail client).

    Your code snippet is sharing as a bitmap because you're telling it you're sharing a bitmap when you pass StandardDataFormats.bitmap.

    There is no primary audio type, but you can share the audio file as a file with request.data.setStorageItems([audioFile]);

    See How to share files for more details.

    --Rob

    • Marked as answer by JERRY MANALIL Friday, March 14, 2014 5:59 AM
    Friday, March 14, 2014 4:05 AM
    Moderator
  • Hi,

    Thanks for your reply.

    Its worked well.

    Is there any way to share the 'to' address with mail app from my application.

    Friday, March 14, 2014 6:05 AM
  • No. Where to share is the user's choice. The user may not choose to share via mail.
    Friday, March 14, 2014 12:04 PM
    Moderator