Comments (5)
I see in the docs that this is only supported on Android and iOS, though CanSendEmailAttachments is returning true.
from xamarin.plugins.
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.
Thank you Carel. It now makes sense why that overload didn't show up in my PCL project.
from xamarin.plugins.
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.
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)
- Multiple extension numbers HOT 1
- Package Xamarin.Android.Support.Core.Utils 27.0.2 is not compatible with monoandroid71 (MonoAndroid,Version=v7.1). Package Xamarin.Android.Support.Core.Utils 27.0.2 supports: monoandroid81 (MonoAndroid,Version=v8.1) HOT 1
- a-href's don't show up as links in the GMail app
- Intent Exception When Using SmsMessenger or Dialer
- Cannot attach a memorystream pdf file to mail for Android
- Is it possible to get the status result of a send operation? HOT 4
- Can't select a photo with the native (iOS) sms app - button does nothing
- SendEmail and wait
- Cannot add attachment on iOS HOT 1
- if(callTask.CanMakePhoneCall) is always False
- Add netstandard2.0 target framework
- SendEmail(IEmailMessage) doesn't work HOT 1
- when trying to open default mail app is hidden under status bar and not responsive on iPhone XR and XS
- What should happen when message in sent in background ? HOT 1
- Cant set CrossMessaging.Current.Settings().Phone.AutoDial = true; HOT 1
- xamarin Error by permission.CALL_PHONE (but it have CALL_PHONE) (android 10) HOT 2
- SendSmsInBackground exception HOT 2
- CanMakePhoneCall always false on Android 11
- Send sms to several contacts at the same time
- It doesn't work in .net MAUI
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xamarin.plugins.