Wisej.NET Hybrid
HomeNewsSupportVideos
  • Start
    • Introduction
    • Getting Started
    • Going Native with Wisej.NET Hybrid
    • Features
    • API
      • General
        • DeviceInfoBase
        • Device
        • DeviceException
        • DeviceInfo
        • DeviceEvent
        • DeviceException
        • HybridResourcesAttribute
      • Shortcuts
        • DeviceAppActions
        • DeviceAppActionsInfo
        • DeviceAppInfo
        • AppAction
      • Navigation
        • DeviceAppLinks
        • DeviceBrowser
        • DeviceLauncher
        • DeviceNavigation
        • DeviceWindows
        • DeviceWindowsInfo
        • AppLinkEntry
        • BrowserLaunchMode
        • BrowserLaunchOptions
        • BrowserTitleMode
      • Authentication
        • DeviceAuthenticator
        • IWebAuthenticatorResponseDecoder
        • WebAuthenticatorOptions
        • WebAuthenticatorResult
      • UI
        • DeviceBackground
        • DeviceBorder
        • DeviceBottomBar
        • DeviceColors
        • DeviceMenuBar
        • DevicePopups
        • DeviceStatusBar
        • DeviceTabBar
        • DeviceTheme
        • DeviceToolbar
        • MenuItemClickedEventArgs
        • MenuItem
        • MenuItemType
        • AppTheme
        • StatusBarTextColor
        • TabBarItem
        • TabSelectedEventArgs
        • AppTheme
        • ToolbarItem
        • ToolbarItemClickedEventArgs
        • ToolbarItemType
      • Hardware
        • DeviceBatteryInfo
        • DeviceFlashlight
        • BatteryPowerSource
        • BatteryState
        • EnergySaverStatus
        • EnergySaverStatusChangedEventArgs
      • Sharing
        • DeviceClipboard
        • DeviceSharing
      • Communication
        • DeviceContacts
        • DeviceEmail
        • DeviceEmailInfo
        • DeviceSms
        • DeviceSmsInfo
        • Contact
        • EmailMessage
        • SmsMessage
      • Network
        • DeviceNetworkingInfo
        • ConnectionProfile
        • ConnectivityChangedEventArgs
        • NetworkAccess
      • Display
        • DeviceDisplay
        • DeviceScreen
        • DisplayInfo
        • DisplayInfo
        • DisplayInfoChangedEventArgs
        • DisplayOrientation
        • DisplayRotation
        • Orientation
      • Storage
        • DeviceFileSystem
        • DevicePreferences
        • DeviceResources
        • DeviceSecureStorage
        • FileSystemInfo
      • Location
        • DeviceGeolocation
        • DeviceMap
        • AltitudeReferenceSystem
        • DistanceUnits
        • GeolocationAccuracy
        • GeolocationRequest
        • Location
        • Placemark
        • MapLaunchOptions
        • NavigationMode
      • Vibration
        • DeviceHapticFeedback
        • DeviceHapticFeedbackInfo
        • DeviceVibration
      • License
        • DeviceLicenseInfo
      • System
        • DeviceLifecycle
        • DeviceSystemInfo
        • DeviceVersioningInfo
        • AppPackagingModel
        • DeviceIdiom
        • DevicePlatform
        • DeviceType
      • Notifications
        • DeviceLocalNotification
        • DeviceLocalNotificationInfo
      • Logs
        • DeviceLogs
      • Media
        • DeviceMedia
      • Permissions
        • DevicePermissions
        • PermissionStatus
        • PermissionType
      • Sensors
        • DeviceSensorInfo
        • DeviceSensors
        • AccelerometerChangedEventArgs
        • AccelerometerData
        • BarometerChangedEventArgs
        • BarometerData
        • CompassChangedEventArgs
        • CompassData
        • GyroscopeChangedEventArgs
        • GyroscopeData
        • MagnetometerChangedEventArgs
        • MagnetometerData
        • OrientationSensorChangedEventArgs
        • OrientationSensorData
        • SensorChangedEventArgs
        • SensorType
      • Shell
        • DeviceFlyout
        • DeviceTitleBar
        • FlyoutBehavior
        • FlyoutHeaderBehavior
        • FlyoutItem
        • FlyoutItemSelectedEventArgs
      • Speech
        • DeviceSpeech
        • Locale
        • SpeechOptions
      • Converters
        • UnitConverters
    • Architecture
    • Troubleshooting
  • Development
    • Basics
    • Email
    • Haptic Feedback
    • Invoke .NET MAUI Code
    • Invoke Platform Code
    • Launch External Apps
    • License Activation
    • Local Application
    • MacOS Desktop Development
    • Multiple Windows (Desktop)
    • Network Events
    • Notifications
    • Open the Map App
    • Remote Application
    • Shortcuts (App Actions)
    • SVG Images & Icon Packs
    • Unit Converters
    • Updating the App
    • Vibration
  • Android
    • Soft Keyboard
  • Images
    • App Icons
    • Splash Screen
  • Debugging
    • Debugging Overview
    • Dev Tunnels
    • Android
    • iOS
    • Windows
  • REST Web Services
    • Detect network connectivity
    • REST with HttpClient
    • Use platform-specific network features
  • Storage
    • Compare Storage Options
    • Store Data locally with SQLite
  • Extensions
    • Overview
    • Document Scanner
    • Remote Push Notifications
  • Advanced
    • Custom Handler
    • iOS Build Mechanics
    • Multi-Targeting (Hybrid Local)
  • Samples
    • Wisej.NET Features
    • Examples on GitHub
  • Deployment
    • Deployment Overview
    • Deployment Guide
  • Application Profiling
    • Android
    • iOS / macOS
    • Windows
Powered by GitBook
On this page
  • Get started
  • Android
  • iOS / Mac Catalyst
  • Using Email
  • File attachments
  • Platform Differences
  • Android
  • iOS
  • Windows
  • Source
  1. Development

Email

PreviousBasicsNextHaptic Feedback

Last updated 1 year ago

This article describes how you can use Wisej.NET Hybrid to open the default email app. When the email app is loaded, it can be set to create a new email with the specified recipients, subject, and body.

Get started

To access the email functionality, the following platform specific setup is required.

Android

If your project's Target Android version is set to Android 11 (R API 30) or higher, you must update your Android Manifest with queries that use Android's .

In the Platforms/Android/AndroidManifest.xml file, add the following queries/intent nodes in the manifest node:

<queries>
  <intent>
    <action android:name="android.intent.action.SENDTO" />
    <data android:scheme="mailto" />
  </intent>
</queries>

iOS / Mac Catalyst

Apple requires that you define the schemes you want to use. Add the LSApplicationQueriesSchemes key and schemes to the Platforms/iOS/Info.plist and Platforms/MacCatalyst/Info.plist files:

<key>LSApplicationQueriesSchemes</key>
<array>
  <string>mailto</string>
</array>

Using Email

The Email functionality works by providing the email information as an argument to the Compose method. In this example, the EmailMessage type is used to represent the email information:

if (Device.Info.Email.IsComposeSupported)
{

    string subject = "Hello friends!";
    string body = "It was great to see you last weekend.";
    string[] recipients = new[] { "john@contoso.com", "jane@contoso.com" };

    var message = new EmailMessage
    {
        Subject = subject,
        Body = body,
        BodyFormat = EmailBodyFormat.PlainText,
        To = new List<string>(recipients)
    };

    Device.Email.Compose(message);
}

File attachments

When creating the email provided to the email client, you can add file attachments. The file type (MIME) is automatically detected, so you don't need to specify it. Some mail clients may restrict the types of files you send, or possibly prevent attachments altogether.

Use the EmailMessage.Attachments collection to manage the files attached to an email.

The following example demonstrates adding an image file to the email attachments.

if (Device.Info.Email.IsComposeSupported)
{
    string subject = "Hello friends!";
    string body = "It was great to see you last weekend. I've attached a photo of our adventures together.";
    string[] recipients = new[] { "john@contoso.com", "jane@contoso.com" };

    var message = new EmailMessage
    {
        Subject = subject,
        Body = body,
        BodyFormat = EmailBodyFormat.PlainText,
        To = new List<string>(recipients)
    };

    string picturePath = Path.Combine(FileSystem.CacheDirectory, "memories.jpg");

    message.Attachments.Add(new EmailAttachment(picturePath));

    Device.Email.Compose(message);
}

Platform Differences

Android

Not all email clients for Android support EmailBodyFormat.Html, since there is no way to detect this, we recommend using EmailBodyFormat.PlainText when sending emails.

iOS

Both EmailBodyFormat.Html and EmailBodyFormat.PlainText are supported.

To use the email API on iOS, you must run it on a physical device. Otherwise, an exception is thrown.

Windows

Only supports EmailBodyFormat.PlainText as the EmailMessage.BodyFormat. Attempting to send an Html email throws the exception: FeatureNotSupportedException.

Not all email clients support sending attachments.

Source

package visibility requirements
LogoEmail - .NET MAUIMicrosoftLearn