Sending an E-mail Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
Tyler
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 246
Joined: Fri Sep 03, 2004 12:37 am
Contact:

Sending an E-mail

Post by Tyler »

How can I programmatically make the system open up a new e-mail message to a specified address?

In other words, I want to achieve the same functionality as when you click an e-mail link on a web site, but from within my program.

Thanks for the help.
phlox81
wxWorld Domination!
wxWorld Domination!
Posts: 1387
Joined: Thu Aug 18, 2005 7:49 pm
Location: Germany
Contact:

Post by phlox81 »

Well, there many ways to get to Rome ;)

One would be, to do it over smtp.
Therefore, you would need a SMTP Server, or bring your own withyou.
Guess you have somewhere one, than, you only need a SMTP Class,
which does the sending for you. In Java, Java Mail API does this,
i don't know if wx offers something similary...
Tyler
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 246
Joined: Fri Sep 03, 2004 12:37 am
Contact:

Post by Tyler »

I want to achieve the same functionality as when you click an e-mail link on a web site, but from within my program. i.e. a new message opens up with the user's default e-mail program.

I don't want to do any sending at all. Just open a new mail message. This should be some permutation of wxExecute or ShellExecute.
Tyler
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 246
Joined: Fri Sep 03, 2004 12:37 am
Contact:

Post by Tyler »

Got it! Finally figured it out. Note this works on Windows only!

Code: Select all

void SendEmail(wxString addy) {
	
	wxString sendTo = "mailto:";
	sendTo += addy;

	ShellExecute(NULL,"open", sendTo.c_str(), "", "", 0);
}

Last edited by Tyler on Sun Aug 28, 2005 1:47 pm, edited 1 time in total.
ssigala
Earned some good credits
Earned some good credits
Posts: 109
Joined: Fri Sep 03, 2004 9:30 am
Location: Brescia, Italy

Post by ssigala »

Tyler wrote:I want to achieve the same functionality as when you click an e-mail link on a web site, but from within my program. i.e. a new message opens up with the user's default e-mail program.
In other words, you want the same behaviour of a browser, when you click on a URL like: mailto:[email protected]

If the wxHTML widget handles this type of URL, maybe a little investigation into the wx sources will show the answer.

Edit: ok, I was too slow typing :)
Sandro Sigala - Kynosoft, Brescia
RJP Computing
Experienced Solver
Experienced Solver
Posts: 75
Joined: Sat Dec 10, 2005 10:38 pm
Location: Michigan, USA
Contact:

Post by RJP Computing »

Is there a way to do this correctly for Linux and Windows. ShellExecute is only available on Windows I think. Is there a file type for the mime type manager in Linux and Windows for email?

Thanks.
- Ryan
RJP Computing
wxPack - Precompiled wxWidgets package.

Ubuntu 9.04 x86_64/WinXP, AMD Athlon x2 3000+, 4000MB RAM, AC 97 Audio, nVidia GeForce 9400GS 1GB
travfar
Earned some good credits
Earned some good credits
Posts: 132
Joined: Mon Apr 04, 2005 12:54 am
Location: California
Contact:

Post by travfar »

Hi,

Get the default browser. wxGetDefaultBrowser or something and then open mailto:[email protected]

that should work
I see said the blind man to the deaf girl who was mute.

Visit my project at: http://vwp.sourceforge.net

wx version:2.6.2 and 2.6.3 on linux
OS's:Windows XP, Gentoo is the best!!!!!!
compiler:Codeblocks(MingW32) and gcc on linux
RJP Computing
Experienced Solver
Experienced Solver
Posts: 75
Joined: Sat Dec 10, 2005 10:38 pm
Location: Michigan, USA
Contact:

Post by RJP Computing »

Well I can't seem to find anything on wxGetDefaultBrowser function. Second it will open the browser to a blank page before opening the email. This seems hacky. I am looking for the same functionality as Windows 'ShellExecute' mailto:[email protected]. In Windows it doesn't open the browser, just the email window.

Is there a cross platform version of ShellExecute?
- Ryan
RJP Computing
wxPack - Precompiled wxWidgets package.

Ubuntu 9.04 x86_64/WinXP, AMD Athlon x2 3000+, 4000MB RAM, AC 97 Audio, nVidia GeForce 9400GS 1GB
RJP Computing
Experienced Solver
Experienced Solver
Posts: 75
Joined: Sat Dec 10, 2005 10:38 pm
Location: Michigan, USA
Contact:

Post by RJP Computing »

Are there any other suggestions? I would like to be able to do this in Linux as professional as it can be done in Windows.
- Ryan
RJP Computing
wxPack - Precompiled wxWidgets package.

Ubuntu 9.04 x86_64/WinXP, AMD Athlon x2 3000+, 4000MB RAM, AC 97 Audio, nVidia GeForce 9400GS 1GB
User avatar
Ryan Norton
wxWorld Domination!
wxWorld Domination!
Posts: 1319
Joined: Mon Aug 30, 2004 6:01 pm

Post by Ryan Norton »

RJP Computing wrote:Well I can't seem to find anything on wxGetDefaultBrowser function. Second it will open the browser to a blank page before opening the email. This seems hacky. I am looking for the same functionality as Windows 'ShellExecute' mailto:[email protected]. In Windows it doesn't open the browser, just the email window.

Is there a cross platform version of ShellExecute?
I think he means wxLaunchDefaultBrowser....
[Mostly retired moderator, still check in to clean up some stuff]
RJP Computing
Experienced Solver
Experienced Solver
Posts: 75
Joined: Sat Dec 10, 2005 10:38 pm
Location: Michigan, USA
Contact:

Post by RJP Computing »

Ryan Norton wrote:I think he means wxLaunchDefaultBrowser....
I actually tried this and it doesn't work either. Any other sugestions.

Is there a default file extension for email on linux?
Last edited by RJP Computing on Thu Jan 26, 2006 1:34 pm, edited 1 time in total.
- Ryan
RJP Computing
wxPack - Precompiled wxWidgets package.

Ubuntu 9.04 x86_64/WinXP, AMD Athlon x2 3000+, 4000MB RAM, AC 97 Audio, nVidia GeForce 9400GS 1GB
User avatar
Ryan Norton
wxWorld Domination!
wxWorld Domination!
Posts: 1319
Joined: Mon Aug 30, 2004 6:01 pm

Post by Ryan Norton »

RJP Computing wrote:
Ryan Norton wrote:I think he means wxLaunchDefaultBrowser....
I actually tried this and it doesn't work either. Any other sugestions.

Is there a default file extension for email on linux?
either .eml or .mbox - I'd try using wxMimeTypesManager to get the default application's path then launch it with wxExecute
[Mostly retired moderator, still check in to clean up some stuff]
james.chengguangwang
Knows some wx things
Knows some wx things
Posts: 38
Joined: Wed Aug 02, 2006 4:59 am

Post by james.chengguangwang »

wxHyperlinkCtrl can do it well
Post Reply