Coder Social home page Coder Social logo

Comments (5)

MikeYeager avatar MikeYeager commented on September 1, 2024

I see in the docs that this is only supported on Android and iOS, though CanSendEmailAttachments is returning true.

from xamarin.plugins.

cjlotz avatar cjlotz commented on September 1, 2024

Hi Mike. Sorry for the delayed response. Had a quick look at the source code again. Attachments are supported for UWP apps but not through using that specific EmailMessageBuilder.WithAttachment overload. There wasn't a consistent cross-platform API that allowed me to add attachments across the different platforms from a PCL using a filePath and contentType (currently only iOS and Android can work with this). UWP for instance requires an IStorageFile. If you want to therefore send attachments using UWP you how to use the UWP specific WithAttachment overload mentioned in the exception (i.e EmailMessageBuilder.WithAttachment(Windows.Storage.IStorageFile file). As this is a platform specific API, if will not be visible in the PCL project but only in the UWP project itself.

from xamarin.plugins.

MikeYeager avatar MikeYeager commented on September 1, 2024

Thank you Carel. It now makes sense why that overload didn't show up in my PCL project.

from xamarin.plugins.

ghlouwho avatar ghlouwho commented on September 1, 2024

VS 2015, using Xamarin PCL, when testing the UWP project, got the error message "API not supported on platform. ", then added the following code to the UWP project...

public void SendWindowsEmail( StorageFile storageFile)
{
StorageFile sFile;
try
{
/*sFile = Task.Factory.StartNew(() => StorageFile.GetFileFromPathAsync(storageFile.Path).AsTask())
.Unwrap()
.GetAwaiter()
.GetResult();
*/

            var emailTask = MessagingPlugin.EmailMessenger;

            if (!MyGlobals.canSendAttachments) //send email without an attachment
            {
                // Send simple e-mail to single receiver without attachments, CC, or BCC.
                emailTask.SendEmail("change@@me-noattachment", "Survey Check", MyGlobals.textInfo);
            }
            else //send email with attachment
            {
                var email = new EmailMessageBuilder()
                    .To("change@@me-withattachment")
                    .Subject("Survey Check Image")
                    .Body(MyGlobals.textInfo)
                    .WithAttachment(storageFile)
                    .Build();

                emailTask.SendEmail(email);           
            }
        }
        catch (Exception ex)
        { 
        System.Diagnostics.Debug.WriteLine("ex.Message: " + ex.Message); 
        }

}

The code builds, I run in debug and see that the 'storageFile' is pointing to the file in "C:\Users\louis\AppData\Local\Packages\dc4933a4-aecd-4798-b9d0-c4a67b72bfc8_tesrwss0qs3kr\LocalState ". I verify (through windows file explorer), that the file (.png) exists, and I can click on and view the image). Email comes up, but without the attachment. It does not matter if I use the 'storageFile', or the commented out 'sFile', as the attachment...the file is never attached to the email. What is going on?

from xamarin.plugins.

ghlouwho avatar ghlouwho commented on September 1, 2024

I am finding postings online that indicate that there are no problems with Windows 10 phone, but there are problems with Windows 10 desktop. I am using desktop.

from xamarin.plugins.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.