Home > Blockchain >  Why is Xamarin inserting ' ' signs instead of spaces when sending Emails using the Xamarin
Why is Xamarin inserting ' ' signs instead of spaces when sending Emails using the Xamarin

Time:11-23

I am using the code snippet below from here and getting ' ' signs instead of spaces in my Outlook email app. All other text is correct. I do not think I am doing anything fancy with the strings, but I am using string interpolation.

`

public async Task SendEmail(string subject, string body, List<string> recipients)
    {
        try
        {
            var message = new EmailMessage
            {
                Subject = @"{StoreName} Needs a Payer",
                Body = @"It needs a separate payer...",
                To = recipients,
                //Cc = ccRecipients,
                //Bcc = bccRecipients
            };
            await Email.ComposeAsync(message);
        }
        catch (FeatureNotSupportedException fbsEx)
        {
            // Email is not supported on this device
        }
        catch (Exception ex)
        {
            // Some other exception occurred
        }
    }

`

This is a .NET Xamarin iOS app. What can I do to make sure spaces are used and not ' ' signs ?

EDIT 1: I tried changing the BodyFormat property and got the following results: Setting the BodyFormat to Text does not change the behavior. Still get signs instead of spaces, BUT if I use a iOS Mail application, the spaces are fine. If I set it to BodyFormat HTML, the Outlook application just crashes, but the iOS Mail application is fine.

CodePudding user response:

This is an outlook issue in iOS app only. to fix it use instead of space and it will work fine with all mail clients.

CodePudding user response:

We can use Uri.EscapeDataString method to encode the string and then can pass in body and subject.

  • Related