Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

simple MAPI question

Posted on 2000-03-13
5
Medium Priority
?
373 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 400 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

604 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