SDL2 - Open Email Address In Email Client With Subject - Windows/Linux - No Using 2.0.14?

Hi,

On Windows and Linux how can we
open an email address in email client with a subject line?
(we are not using SDL 2.0.14)

Let me know, thanks!

Jesse

On Windows and Linux how can we
open an email address in email client with a subject line?
(we are not using SDL 2.0.14)

Consider upgrading! :slight_smile:

On Linux, try something like:

system(“xdg-open
mailto:donotreply@example.com?subject=helllllooooooooo…”);

(with appropriate shell escaping and error checking.)

On Windows, it’s probably ShellExecute() with a similar mailto: URL, but
I haven’t tried it.

–ryan.

Hi.

Thanks!
How would I detect if using Windows or Linux?

Jesse

Have below but it does not compile?:

ifdef __unix__
system(“xdg-open mailto:Admin@FallenAngelSoftware.com?subject=Possible Employment Opportunity”);
#elifdef _WIN32 || WIN32
// ???
#endif

It’s #ifdef with a # in the front

also, #elifdef doesn’t exist, try #elif defined(_WIN32) (no need to check WIN32)

One of these days you should learn C :stuck_out_tongue:

Ok, have below but it does not compile?:
(also need Windows command)

        #ifdef __unix__
            system(“xdg-open mailto:Admin@FallenAngelSoftware.com?subject=Possible Employment Opportunity”);
        #elif defined(_WIN32)
            // ???
        #endif

it might help if you posted the compiler error message

Errors-01

Looks like the character that looks like a " is really a and thus invalid. Try replacing it with a proper ".

compiles, but does not open email client on Linux?:

        #ifdef __unix__
            system("xdg-open mailto:Admin@FallenAngelSoftware.com?subject=Possible Employment Opportunity");
        #elif defined(_WIN32)
            // ???
        #endif

I think the argument to xdg-open must be put into quotes, because it contains spaces.
Like system( "xdg-open 'mailto:Admin@FallenAngelSoftware.com?subject=Possible Employment Opportunity'" );

Ok, that works on Linux, what is the Windows equivalent?

Also, Google might help.

Have below, does not compile on Windows 10 CodeBlocks:

        #ifdef __unix__
            system( "xdg-open 'mailto:Admin@FallenAngelSoftware.com?subject=Possible Employment Opportunity'" );
        #elif defined(_WIN32)
            #include <windows.h>
            #include <shellapi.h>
            ShellExecute(NULL, "open", "mailto:Admin@FallenAngelSoftware.com ? subject=Possible Employment Opportunity", NULL , NULL, SW_SHOWNORMAL);
        #endif

Where can I view the source code to “SDL_OpenURL()” ?

You can find the different implementations for the platforms here

There is a folder for each platform that has support, and a SDL_sysurl.c (or .m or whatever) that implements it there.

Thanks for the link…

We went ahead and used “SDL_OpenURL()” on Windows(requires SDL2 v2.0.14).
Below is the code: