Solved

simple MAPI question

Posted on 2000-03-13
5
365 Views
Last Modified: 2008-02-26
I Use simple MAPI to send email,but
when I run MAPISendMail and outlook close the mail goes to the outbox and don't being sent until I open Outlook.
Is there some way to send it immediately?
0
Comment
Question by:peter_sh
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 4

Expert Comment

by:inpras
ID: 2615644
And how RU trying to send it?
Pl put some code here....
0
 
LVL 1

Expert Comment

by:ntdragon
ID: 2616230
tell us what are you using and give us some code
0
 
LVL 14

Expert Comment

by:AlexVirochovsky
ID: 2617155
Outlook must start immidiatly after
setting mail in outbox.
1. Test you profile
2. Try use MAPI_FORCE_DOWNLOAD mode in MAPILogon function

0
 

Author Comment

by:peter_sh
ID: 2622472
this is the code :

bool send_mail(char * DefaultProfile,char *fromDisplayName,
                     char *fromAddress,int recipients, char ** toDisplayName,char **toAddress,
                     char * subject , char * text,int attachments,char ** attachmentFullPath,char ** attachmentFilename )
{
            // Send a mail message containing a file and prompt for
            // recipients, subject, and note text.

            ULONG err;
            MapiFileDesc **attachmentArray  = (MapiFileDesc **)malloc(sizeof(MapiFileDesc *)*attachments);
            for (int index = 0; index < attachments ; index ++)
            {
                  MapiFileDesc attachment = {0,         // ulReserved, must be 0
                                                   0,         // no flags; this is a data file
                                                   (ULONG)-1, // position not specified
                                                   attachmentFullPath[index],  // pathname
                                                   attachmentFilename[index] ,      // original filename
                                                   NULL};               // MapiFileTagExt unused
                  attachmentArray[index] = &attachment;
            }      
            char ident_sr[20] = "sender";
            char ident_rec[20] = "reciever";
            char from[MAX_PATH] = "SMTP:";
            strcat(from,fromAddress);
            MapiRecipDesc sender = {0,                  // ulReserved, must be 0
                                                MAPI_ORIG, //Indicates the original sender of the message.  
                                                fromDisplayName, //Pointer to the display name
                                                from,  // address
                                                20,            // size of opaque entry identifier
                                                ident_sr};                        // opaque entry identifier
            MapiRecipDesc **recievers = (MapiRecipDesc**)malloc(sizeof(MapiRecipDesc*)*recipients);
            char to[MAX_PATH];
            for ( index = 0 ; index < recipients ; index ++ )
            {
                  strcpy(to,"SMTP:");
                  strcat(to,toAddress[index]);
                  MapiRecipDesc reciever = {0,                  // ulReserved, must be 0
                                                      MAPI_TO,            //Indicates the original sender of the message.  
                                                      toDisplayName[index], //Pointer to the display name
                                                      to,  // address
                                                      20,            // size of opaque entry identifier
                                                      ident_rec};                        // opaque entry identifier
                  recievers[index] = &reciever;
            }
            MapiMessage note = {0,            // reserved, must be 0
                                          subject,         //  subject
                                          text ,         //  note text
                                          NULL,         // NULL = interpersonal message
                                          NULL,         // no date; MAPISendMail ignores it
                                          NULL,         // no conversation ID
                                          MAPI_RECEIPT_REQUESTED  , // no flags, MAPISendMail ignores it
                                          &sender,         // originator
                                          recipients,            //  recipients
                                          *recievers ,         // recipients array
                                          attachments,            // attachment
                                          *attachmentArray}; // the attachment structure
 
      
            
            HINSTANCE hlibMAPI = LoadLibrary ( "MAPI32.DLL" );
          LPMAPISENDMAIL m_MAPISendMail = (LPMAPISENDMAIL)GetProcAddress(hlibMAPI,
                                                       "MAPISendMail");

            LHANDLE m_lhSession;
            LPMAPILOGON m_MAPILogon = (LPMAPILOGON)GetProcAddress(hlibMAPI,
                                                                 "MAPILogon");
       // Call the function through the function pointer.
         err = m_MAPILogon ( 0L, // Handle to parent window or 0.
                                 DefaultProfile,//"Microsoft Outlook", // Default profile name to use for MAPI session.
                               NULL, // Profile password for MAPI session.
                               MAPI_FORCE_DOWNLOAD  , // Various session settings. Can be 0
                               0L, // Reserved.  Must be 0L.
                               &m_lhSession ); // Handle to Simple MAPI session.

            err = m_MAPISendMail (m_lhSession,          // use implicit session.
                                          0L,          // ulUIParam; 0 is always valid
                                          &note,       // the message being sent
                                          0L,//MAPI_LOGON_UI  , // allow the user to edit the message
                                          0L                        // reserved; must be 0
                                           );          
            if (err != SUCCESS_SUCCESS )
            {
                  MessageBox(NULL,"Unable to send the message",NULL,MB_OK);
                  return false;
            }

            return true;
}
0
 
LVL 14

Accepted Solution

by:
AlexVirochovsky earned 100 total points
ID: 2637380
Hi, i tesyed you code, very good, but i have some comments:
1. Main error: you need make MAPILogoff
in end of programm: without this Outlook don't start.
2. Best begin:  test, if MAPI installed
3. Better use ResolveNames API for
using Address Book.

All this you can fine in
http://support.microsoft.com/support/kb/articles/q171/0/96.asp

Good Luck. Alex
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to copy an image file into clipboard C/C++? 1 220
Beginner to Unreal Engine 4 5 107
Outlook 13 85
Indy 10 not Receiving UDP broadcast 3 43
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question