![]() |
#1 |
Junior Member
![]() Posts: 5
Karma: 10
Join Date: Apr 2012
Device: kindle touch
|
A problem: call calibre-smtp.exe by CreateProcess in C++
Hello, everyone ,
I am a newer to calibre. Recently I want to send a email by call calibre-smtp.exe using CreateProcess() function in C++. The result is the CreateProcess() function return success, but maybe calibre-smtp.exe does not work, And nothing happend. so I donot call CreateProcess(), and changed to system() function, I doesnot work too. But I run the calibre-smtp.exe and its param in cmd line (OS: windows7 64bit), it worked fine and email can be send successfully. The cmd line is: "C:\Program Files (x86)\Calibre2\calibre-smtp.exe" -e SSL -r smtp.qq.com -u myuserid -p mypassword --port 465 -v -s "Email_title" xx@qq.com yy@foxmail.com "mailBody" what is the matter? Do anyone know it? ![]() |
![]() |
![]() |
![]() |
#2 |
Junior Member
![]() Posts: 5
Karma: 10
Join Date: Apr 2012
Device: kindle touch
|
Can someone give me a idea about this problem?
Can someone give me a idea about this problem?
|
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 13,367
Karma: 78877538
Join Date: Nov 2007
Location: Toronto
Device: Libra H2O, Libra Colour
|
Maybe if you post the code you are using, or a portion of it so people can see exactly what you are doing.
|
![]() |
![]() |
![]() |
#4 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 13,367
Karma: 78877538
Join Date: Nov 2007
Location: Toronto
Device: Libra H2O, Libra Colour
|
For what it's worth.... this worked for me. Sorry I am NOT a c++ programmer; just found some examples on the web and modified them.
Spoiler:
|
![]() |
![]() |
![]() |
#5 |
Junior Member
![]() Posts: 5
Karma: 10
Join Date: Apr 2012
Device: kindle touch
|
Blow is my full test source code:
Blow is my full test source code:
#include "stdafx.h" #include "Windows.h" #include "Winbase.h" int main(int argc, char* argv[]) { STARTUPINFO startinfo; PROCESS_INFORMATION processinfo; memset(&startinfo, 0, sizeof(STARTUPINFO)); startinfo.cb = sizeof(STARTUPINFO); startinfo.lpReserved = NULL; memset(&processinfo, 0, sizeof(PROCESS_INFORMATION)); const char* psExeName = "C:\\Program Files (x86)\\Calibre2\\calibre-smtp.exe"; char szCmdLine[4096]; strcpy(szCmdLine, "C:\\Program Files (x86)\\Calibre2\\calibre-smtp.exe -e SSL -r smtp.qq.com -u myuserid -p mypwd --port 465 -v -s \"Email_title\" from@qq.com to@foxmail.com \"mailBody\""); const char* psCurrDir = "C:\\Program Files (x86)\\Calibre2"; if(CreateProcess(psExeName, szCmdLine, NULL, NULL, FALSE, CREATE_NO_WINDOW|DETACHED_PROCESS, NULL, psCurrDir, &startinfo, &processinfo)==0) { printf("Create process failed.\n"); return -1; } printf("Create process ok.\n"); return 0; } ==== This code can work, and print "Create process ok", but No mail has been sent. |
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Junior Member
![]() Posts: 5
Karma: 10
Join Date: Apr 2012
Device: kindle touch
|
Thanks
thanks to PeterT, his code does worked ok. I found my bug is that DETACHED_PROCESS flag is not necessary. And thanks everyone.
![]() |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
calibre-parallel.exe twice? | sideburnt | Calibre | 12 | 03-24-2012 08:51 PM |
Help! Need calibre installer in .exe, not .msi | jkoerner | Recipes | 0 | 08-18-2011 07:28 PM |
kobo reader stops calibre.exe | remaus | Devices | 3 | 07-11-2011 10:11 PM |
calibre-parallel.exe crashes on book import | domee | Calibre | 2 | 07-06-2011 08:06 AM |
Unhandled exception in calibre.exe (python26.dll) | jusmee | Calibre | 0 | 12-14-2009 12:53 AM |