Home Arrow Icon Knowledge base Arrow Icon Global Arrow Icon Are there any specific NuGet packages required for the Email plugin in MvvmCross


Are there any specific NuGet packages required for the Email plugin in MvvmCross


To use the Email plugin in MvvmCross, you need to install the MvvmCross.Plugin.Email NuGet package. This package provides a cross-platform implementation for sending emails and is compatible with various .NET frameworks, including .NET Core, .NET Standard, and .NET Framework.

Key Details About MvvmCross.Plugin.Email

- Compatibility: The package is compatible with .NET Core 3.1 and higher, .NET Standard 2.0 and higher, and .NET Framework 4.6.1 and higher[1]. It also supports various platforms such as Xamarin.iOS, Xamarin.Android, Xamarin.Forms, Windows, and Mac.

- Installation: You can install the package using NuGet Package Manager in Visual Studio. For example, to install version 8.0.2, you can use the following command in the Package Manager Console:

powershell
  Install-Package MvvmCross.Plugin.Email -Version 8.0.2
  

Alternatively, you can use the .NET CLI:
bash
  dotnet add package MvvmCross.Plugin.Email --version 8.0.2
  

- Usage: The Email plugin uses dependency injection to provide an `IMvxComposeEmailTask` interface. You can resolve this interface to compose and send emails across different platforms. Here is a basic example of how to use it:

csharp
  var emailTask = Mvx.IoCProvider.Resolve();
  emailTask.ComposeEmail("
 <script language='JavaScript' type='text/javascript'>
 <!--
 var prefix = 'm&#97;&#105;lt&#111;:';
 var suffix = '';
 var attribs = '';
 var path = 'hr' + 'ef' + '=';
 var addy60958 = 'r&#101;c&#105;p&#105;&#101;nt' + '&#64;';
 addy60958 = addy60958 + '&#101;x&#97;mpl&#101;' + '&#46;' + 'c&#111;m';
 document.write( '<a ' + path + '\'' + prefix + addy60958 + suffix + '\'' + attribs + '>' );
 document.write( addy60958 );
 document.write( '<\/a>' );
 //-->
 </script><script language='JavaScript' type='text/javascript'>
 <!--
 document.write( '<span style=\'display: none;\'>' );
 //-->
 </script>This e-mail address is being protected from spambots. You need JavaScript enabled to view it
 <script language='JavaScript' type='text/javascript'>
 <!--
 document.write( '</' );
 document.write( 'span>' );
 //-->
 </script>", string.Empty, "Subject", "Body", false);
  

- Deprecation: Note that older versions of the Email plugin (like 5.4.2) are deprecated and no longer maintained. It is recommended to use the latest available version for new projects[4].

- Platform-Specific Implementations: While the plugin provides a unified API, its implementation varies by platform. For example, on Windows UWP and WPF, it uses simple 'mailto:' URL requests[2].

Additional Considerations

- Plugin Development: If you are developing custom plugins for MvvmCross, ensure that your plugin inherits from `IMvxPlugin` and is annotated with the `MvxPluginAttribute`. This simplifies plugin development and registration within the MvvmCross framework[10].

- Troubleshooting: If you encounter issues with plugin loading, ensure that all MvvmCross packages are updated to the same version. Sometimes, overriding the `LoadPlugins` method in platform-specific setup classes can resolve loading issues[6].

Citations:
[1] https://www.nuget.org/packages/MvvmCross.Plugin.Email/
[2] https://www.mvvmcross.com/documentation/plugins/email
[3] https://www.mvvmcross.com/documentation/getting-started/getting-started
[4] https://www.nuget.org/packages/MvvmCross.Plugin.Email/5.4.2
[5] https://www.mvvmcross.com/documentation/upgrading/upgrade-to-mvvmcross-40
[6] https://stackoverflow.com/q/33774785
[7] https://github.com/MvvmCross/MvvmCross-Samples
[8] https://stackoverflow.com/questions/20556090/which-settings-plugin-to-use-in-mvvmcross
[9] https://www.mvvmcross.com/documentation/getting-started/mvvmcross-packages
[10] https://www.mvvmcross.com/documentation/plugins/plugins-development