Linking Input to an email output
-
I am building a rather simple dialog program that receives input, however, I am having trouble linking this generated output to be transmitted in email form through outlook explorer. I am still pretty much a beginner programer in C++, so any help would be appreciated. Thanks B-rock B-Rock
-
I am building a rather simple dialog program that receives input, however, I am having trouble linking this generated output to be transmitted in email form through outlook explorer. I am still pretty much a beginner programer in C++, so any help would be appreciated. Thanks B-rock B-Rock
I'm getting very frustrated with trying to send email from my computer programmatically. From what I've been able to find out, there are two choices: - use MAPI: problem: It pops up dialog boxes requiring user input when it is unable to send messages or when various errors happen. Therefore it is not useful to me since I want to run the program on a computer that isn't being looked at by a human. - use SMTP: problem: You need a computer that you can connect to on port 25 and say HELO\r\nMail From: a@b.c\r\nRCPT To: x@y.z\r\ndata\r\nfirstline\r\nlastline\r\n.\r\nQUIT\r\n or whatever. In any case I don't have a computer that I can send this through so I can't do this either. But check out the code below for an example of doing MAPI. You have to put a line of code each of mapi init and uninit and include mapi.h. The functions i call at the end here just display the appropriate error message according to a switch statement using strings taken from the msdn docs. hope it helps. /* CMfcserverDlg::Mail(CString subject, CString text) { LPMAPISENDMAIL lpfnMAPISendMail = (LPMAPISENDMAIL) GetProcAddress (m_mapiModule,"MAPISendMail"); LPMAPILOGON lpfnMAPILogon = (LPMAPILOGON) GetProcAddress (m_mapiModule,"MAPILogon"); LPMAPILOGOFF lpfnMAPILogoff = (LPMAPILOGOFF) GetProcAddress (m_mapiModule,"MAPILogoff"); LHANDLE lhSession = 0; char subject[] = "this is the subject"; char message_text[] = "automated\r\nhello\r\nthis is the message text\r\nblah\r\nblah\r\nblah\r\ngoodbye"; char str_originator_name[] = "alexander the originator"; char str_recip_name[] = "alexander the recipient"; char str_originator_address[] = "snowman@north.pole"; char str_recip_address[] = "SMTP:agriffing@hotmail.com"; MapiRecipDesc originator; originator.ulReserved = 0; originator.ulRecipClass = MAPI_ORIG; originator.lpszName = str_originator_name; originator.lpszAddress = str_originator_address; originator.ulEIDSize = 0; originator.lpEntryID = 0; MapiRecipDesc recip; recip.ulReserved = 0; recip.ulRecipClass = MAPI_TO; recip.lpszName = str_recip_name; recip.lpszAddress = str_recip_address; recip.ulEIDSize = 0; recip.lpEntryID = 0; MapiMessage msg; msg.ulReserved = 0; msg.lpszSubject = subject; msg.lpszNoteText = message_text; msg.lpszDateReceived = 0; msg.lpszConversationID = 0; msg.flFlags = 0; msg.lpOriginator = &originator; msg.nRecipCount = 1; msg.lpRecips = &recip; msg.nFileCount = 0; msg.lpFiles = 0; ULONG ret; ret = lpfnMAPILogon(0, 0, 0, 0, 0, &lhS
-
I am building a rather simple dialog program that receives input, however, I am having trouble linking this generated output to be transmitted in email form through outlook explorer. I am still pretty much a beginner programer in C++, so any help would be appreciated. Thanks B-rock B-Rock
If you want to use Outlook Express or whatever it is, that is your default email client, try this. Use ShellExecute and open "mailto:aaa@aaa.com" replace aaa@aaa.com with your target email address I hope I got your question correct. Nish