locked
How to set 'to' email address and body text by mail app using charm

    Question

  • I have implemented share image file using mail app select from charm, it is perfectly working now, but i cant set to email address and body content to the mail app. There is any way to set to email address and body text.

        DataTransferManager dataTransferManager = DataTransferManager.GetForCurrentView();
                if (_dataTransferManagerHandler != null)
                    dataTransferManager.DataRequested -= _dataTransferManagerHandler;
    
                _dataTransferManagerHandler = ShareImageHandler;
                dataTransferManager.DataRequested += _dataTransferManagerHandler;

                        DataRequest requestData = e.Request;
                        //requestData.Data.SetDataProvider(StandardDataFormats.Bitmap, new DataProviderHandler(this.OnDeferredImageRequestedHandler));
    
                        requestData.Data.Properties.Title = ShareMailTitle;
                        requestData.Data.Properties.Description = ShareMailDescription;
    
                        DataRequestDeferral deferral = requestData.GetDeferral();
    
                        StorageFile filetoShare = SavedSimulationImage;
                        List<IStorageItem> imageItems = new List<IStorageItem>();
                        imageItems.Add(filetoShare);
                        requestData.Data.SetStorageItems(imageItems);
    
                        StorageFile thumbnailImage = await ResizeBitmapImage(SavedSimulationImage, 112, 112);
                        RandomAccessStreamReference imageStreamRef_thumb = RandomAccessStreamReference.CreateFromFile(thumbnailImage);
                        RandomAccessStreamReference imageStreamRef = RandomAccessStreamReference.CreateFromFile(filetoShare);
                        requestData.Data.Properties.Thumbnail = imageStreamRef_thumb;
                        requestData.Data.SetBitmap(imageStreamRef);
    
                        deferral.Complete();
    

    This is the code i have used to share an image, here how can i set body content and to email address.

    Friday, April 11, 2014 6:50 AM

Answers

  • You can share more than just images (see http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh871368.aspx) but you can't set the TO: email address programmatically in the Share contract.  This is by-design.  The only way to launch an email with this information already populated is to use a mailto: link to open the default mail app.

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Friday, April 11, 2014 1:34 PM
    Moderator