启动“新电子邮件"使用c ++的Mac OS X上的窗口 [英] Launch "new email" window on Mac OS X with c++
问题描述
我可以触发我的Mac从我的C ++程序中打开默认的邮件客户端新消息"窗口.它应该像mailto链接一样工作.程序运行时,应打开一个新消息"窗口,其中包含消息正文,主题行和已填写的收件人.我不需要包含附件.我知道Stack Overflow已经解决了这个问题. 具有我所需功能的mailto链接如下所示:
Can I trigger my Mac to open the default mail client "new message" window from my C++ program. It should work just like a mailto link does. When the program runs it should open a "new message" window with a message body, a subject line, and a recipient already filled in. I DON'T need to include an attachment. I know there are some answers already on Stack Overflow addressing that question. A mailto link with the functionality I need looks something like this:
"mailto:bob@domain.com?subject=look at this website&body=Hi,I found this website."
如果无法在C ++中直接使用mailto,是否还有其他方法可以满足我的需求?
If it is not possible to use mailto directly in C++, is there some other way of doing what I am looking for?
谢谢您的帮助!
推荐答案
这个简单的代码可以满足我的需要!它使用给定的收件人地址,主题和邮件正文启动默认的邮件客户端窗口. 电子邮件",主题"和"bodyMessage"都是在完整程序代码中声明的字符串变量.此代码段不包含其声明.
This simple code does what I need! It launches the default mail client window with a given recipient address, subject, and message body. "email", "subject", and "bodyMessage" are all string variables declared in my complete program code. This snippet doesn't include their declarations.
string mailTo = "mailto:" + email + "?subject=" + subject + "\\&body=" + bodyMessage;
string command = "open " + mailTo;
system(command.c_str());
有关使用打开"命令的这篇帖子有帮助.
This post on using the "open" command helped.
这篇关于启动“新电子邮件"使用c ++的Mac OS X上的窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!