Click here to Skip to main content
15,897,315 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: XML writer using MSXML class Pin
amit.code11-Jan-09 19:26
amit.code11-Jan-09 19:26 
AnswerRe: XML writer using MSXML class Pin
Stuart Dootson11-Jan-09 21:13
professionalStuart Dootson11-Jan-09 21:13 
QuestionProblem with MAPISendMail without outlook running Pin
harishkj11-Jan-09 18:05
harishkj11-Jan-09 18:05 
AnswerRe: Problem with MAPISendMail without outlook running Pin
Stuart Dootson11-Jan-09 23:31
professionalStuart Dootson11-Jan-09 23:31 
AnswerRe: Problem with MAPISendMail without outlook running Pin
Stuart Dootson11-Jan-09 23:34
professionalStuart Dootson11-Jan-09 23:34 
GeneralRe: Problem with MAPISendMail without outlook running Pin
Harish_kj12-Jan-09 1:07
Harish_kj12-Jan-09 1:07 
GeneralRe: Problem with MAPISendMail without outlook running Pin
Harish_kj12-Jan-09 1:32
Harish_kj12-Jan-09 1:32 
GeneralRe: Problem with MAPISendMail without outlook running Pin
Stuart Dootson12-Jan-09 3:57
professionalStuart Dootson12-Jan-09 3:57 
Here's the code I've used (note - I've #included mapi.h before this) - obviously, my e-mail address isn't "my e-mail address". This works whether Outlook is running or not. If Outlook isn't running, I get a dialog that prompts me to choose the Outlook profile to use.

This would seem to be because the MAPILogon returns MAPI_E_LOGON_FAILURE whether or not Outlook is running when MAPI_NEW_SESSION is set. This is because a) when Outlook is running, it can't create a new session, and b) when Outlook isn't running, it doesn't know what profile to open (I have no default profile). The MAPISendMail will logon, as the flags allow it to display the logon UI.

Changing the MAPILogon flag to MAPI_LOGON_UI allows the logon UI to be displayed and so we can logon if Outlook isn't running. ANd if Outlook is running, we can logon because we've said we're willing to share an existing session.
   HRESULT hr;
   if (SUCCEEDED(hr = OleInitialize(NULL)) && SUCCEEDED(hr = MAPIInitialize(NULL)))
   {
      MapiRecipDesc mapiCurrentSender;
      MapiRecipDesc lppNewRecips;
      lppNewRecips.lpszAddress = "SMTP:<span style="font-style: italic;">my e-mail address</span>";
      lppNewRecips.lpszName = "Stu";
      lppNewRecips.ulRecipClass = MAPI_TO;
      lppNewRecips.ulEIDSize = NULL;
      lppNewRecips.ulReserved = 0;

      mapiCurrentSender.lpEntryID = NULL;
      mapiCurrentSender.lpszAddress = "SMTP:<span style="font-style: italic;">my e-mail address</span>";
      mapiCurrentSender.lpszName = "Stu";
      mapiCurrentSender.ulRecipClass = MAPI_ORIG;
      mapiCurrentSender.ulEIDSize = NULL;
      mapiCurrentSender.ulReserved = 0;

      MapiMessage message = 
      { 
         0,                      // ULONG ulReserved
            "Hello",            // LPTSTR lpszSubject
            "Hello",            // LPTSTR lpszNoteText
            0,                      // LPTSTR lpszMessageType
            "2009/01/12 09:01", // LPTSTR lpszDateReceived
            0,                      // LPTSTR lpszConversationID
            0,                      // FLAGS flFlags
            &mapiCurrentSender,     // lpMapiRecipDesc lpOriginator
            1,                      // ULONG nRecipCount
            &lppNewRecips,          // lpMapiRecipDesc lpRecips
            0,                      // ULONG nFileCount
            0                       // lpMapiFileDesc lpFiles
      };

      HINSTANCE hlibMAPI = 0;
      hlibMAPI = LoadLibrary(_T("MAPI32.dll"));
      LPMAPILOGON MAPILogon;
      LHANDLE session = 0;    
      MAPILogon = (LPMAPILOGON) GetProcAddress (hlibMAPI, "MAPILogon");
      ULONG errLogon = MAPILogon(0,0,0,MAPI_NEW_SESSION,0,&session);

      LPMAPISENDMAIL lpfnMAPISendMail;    
      lpfnMAPISendMail = (LPMAPISENDMAIL) GetProcAddress (hlibMAPI, "MAPISendMail");
      ULONG errSend = (*lpfnMAPISendMail)(session, 0, &message, MAPI_LOGON_UI, 0L);
   }




GeneralRe: Problem with MAPISendMail without outlook running Pin
Harish_kj12-Jan-09 17:54
Harish_kj12-Jan-09 17:54 
GeneralRe: Problem with MAPISendMail without outlook running Pin
Stuart Dootson12-Jan-09 21:32
professionalStuart Dootson12-Jan-09 21:32 
GeneralRe: Problem with MAPISendMail without outlook running Pin
Harish_kj13-Jan-09 2:22
Harish_kj13-Jan-09 2:22 
GeneralRe: Problem with MAPISendMail without outlook running Pin
Stuart Dootson13-Jan-09 21:27
professionalStuart Dootson13-Jan-09 21:27 
GeneralRe: Problem with MAPISendMail without outlook running Pin
bolis30-Nov-10 2:06
bolis30-Nov-10 2:06 
Questionpointer and address ? Pin
dec8211-Jan-09 15:04
dec8211-Jan-09 15:04 
GeneralRe: pointer and address ? Pin
Luc Pattyn11-Jan-09 15:29
sitebuilderLuc Pattyn11-Jan-09 15:29 
GeneralRe: pointer and address ? Pin
Hamid_RT11-Jan-09 19:55
Hamid_RT11-Jan-09 19:55 
GeneralRe: pointer and address ? Pin
Luc Pattyn12-Jan-09 2:12
sitebuilderLuc Pattyn12-Jan-09 2:12 
Question[C] IRC client check if he is still operative Pin
ogn0s11-Jan-09 10:59
ogn0s11-Jan-09 10:59 
AnswerRe: [C] IRC client check if he is still operative Pin
Code-o-mat11-Jan-09 11:47
Code-o-mat11-Jan-09 11:47 
GeneralRe: [C] IRC client check if he is still operative Pin
ogn0s11-Jan-09 13:11
ogn0s11-Jan-09 13:11 
GeneralRe: [C] IRC client check if he is still operative Pin
ogn0s11-Jan-09 13:35
ogn0s11-Jan-09 13:35 
GeneralRe: [C] IRC client check if he is still operative Pin
Code-o-mat11-Jan-09 22:15
Code-o-mat11-Jan-09 22:15 
GeneralRe: [C] IRC client check if he is still operative Pin
ogn0s12-Jan-09 9:05
ogn0s12-Jan-09 9:05 
QuestionCSlider that works backwards Pin
Chris Hills11-Jan-09 10:20
Chris Hills11-Jan-09 10:20 
AnswerRe: CSlider that works backwards Pin
Graham Bradshaw11-Jan-09 11:52
Graham Bradshaw11-Jan-09 11:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.