Mac Outlook and message with url encoded body

In a Mac/Windows project for a customer, we have a function to compose an email to be sent to the administrators. We create the body of the message, call encodeURLComponent, make it part of a mailto: url which we then show.

This works fine on their Windows clients. But, when they do it on a Mac, using Outlook 2013 for Mac as their mail client, the email is received with all the url encodings in place - e.g., all spaces substituted by “%20”

Instead of this from a Windows client:

[code]USER INSTRUCTIONS: Please provide your manager’s name, and any additional information.

Dear Administrators:
[/code]

we get this when a Mac is used:

USER%20INSTRUCTIONS%3A%20Please%20provide%20your%20manager%27s%20name%2C%20and%20any%20additional%20information.%0A------------------------------------------%0A%0A%0ADear%20Administrators%3A

Does anybody have an idea what would be causing this, and if there is a Outlook for Mac preference that might resolve the problem?

Code?

[quote=196890:@Peter Truskier]we get this when a Mac is used:

[/quote]

It simply is an URL encoded line.
For some reason, DecodeURLComponent was not applied. Check your code.

I checked, it does decode fine on my Mac.

Oh, one thing. I’m pretty sure you need to use CR+LF for your line endings, even on the Mac.

AHA! Now that is something worth trying. I’m currently just using “endOfLine,” which would be different on Mac and Windows. I’ll modify the project, deeply, and see what happens.

[quote=196927:@Michel Bujardet]It simply is an URL encoded line.
For some reason, DecodeURLComponent was not applied. Check your code.

I checked, it does decode fine on my Mac.[/quote]
I realize that. It’s not our app that decodes it. We build a URL, and pass it to the mail client with showURL :

[code]dim s, mailAddr , BodyStr, subjStr as string

BodyStr = EncodeURLComponent(bodyStr)
//Dynamically define the string values
s = “mailto:” + mailAddr + “?subject=” + subjStr + “&body=” + BodyStr
showURL(s)[/code]

I’ve used the same code successfully in other Mac projects, but always using Maill.app as the client. I’m hoping that Outlook for Mac is expecting the CRLF as Kem suggests.

Thanks!

bodyStr = EncodeURLComponent( ReplaceLineEndings( bodyStr, EndOfLine.Windows ) )

[quote=196941:@Kem Tekinay] bodyStr = EncodeURLComponent( ReplaceLineEndings( bodyStr, EndOfLine.Windows ) ) [/quote]
Yep. Just did that. Now, to build, deploy, and finally to get one of their Mac users to try it tomorrow.

Thanks, Kem!

The old Microsoft Exchange client in Windows 95 used to do the same thing. Kept the URL encoded data passed to it from the browser no matter what we did.

I wish you luck with this. Our “solution” was to switch mail clients. Lucky for us it was an internal only need.

It sounds like I might need it. :stuck_out_tongue_winking_eye:

I’ll report back here the next time a Mac user submits an email with the code modified per Kem’s suggestion…

Thanks to all for the input!

Outlook USED TO be scriptable via applescript
Is it still ?
That might be an alternative on the Mac

Both Outlook 2011 and 2015 are scriptable. I’m not in front of my computer right now so a quick Google gave me http://stackoverflow.com/questions/9521897/create-new-outgoing-message-with-applescript-in-microsoft-outlook .

That’s a thought. If the CR/LF gambit doesn’t work, I might try that. Thanks for the idea, Norman and Beatrix!

The Outlook Applescript support is excellent, I can highly recommend it. Also something I always mention in response to Microsoft bashers.