|
I'm using MSVC++ 6.0 in windows 2000 and I've compiled and ran CMapi. It works fine, however the send command take many seconds to return (approximately 20). I've stepped into the send function and traced the problem to the following code:
if ( if (Resolve(sName, &lpTempRecip))
{
//Resolve worked, put the resolved name back into the sName
sName = lpTempRecip->lpszName;
//Don't forget to free up the memory MAPI allocated for us
m_lpfnMAPIFreeBuffer(lpTempRecip);
}
It is the Resolve(sName, &lpTempRecip) line that takes so long to return. It also throws many "First-chance exception in cmapi.exe (KERNEL32.DLL): 0x000006BA: (no name)." errors.
Any ideas?
|
|
|
|
|
As I replied to other queries:
There are no guarantees on when delivery / time to process a request will occur / take. This is completely up to the app which is acting as the MAPI service provider e.g. Outlook Express or Outlook will decide on how and / or when to send the mails.
To avoid resolve calls being made simply set bResolve to FALSE in calls to the CMapiSession::Send method.
P.S. If you want more control over the delivery then I would suggest you look into either Extended MAPI or SMTP
|
|
|
|
|
Hello,
Can you tell me if CMapiSession::Send() blocks, or if it does its work in a thread somewhere and returns immediately? The reason I'm asking is that I'm creating a CMapiSession object and two CMapiMessage objects in a worker thread, and when I call CMapiSession::Send(), it sometimes sends both messages, and sometimes only sends the first one. The second message either doesn't get created at all (in the mail client), or ends up sitting in the outbox of the mail client (in this case, Outlook Express).
If CMapiSession::Send() is using a thread somewhere, and not blocking, then I'd understand why I'm only getting one message some of the time: my worker thread is probably completing before Send() is done with the second message. If this is the case, can you tell me if there is a way to know when Send() is done, so I can tell my thread to wait for it?
Thanks!
|
|
|
|
|
There are no guarantees on when delivery will occur. This is completely up to the app which is acting as the MAPI service provider e.g. Outlook Express or Outlook will decide on how and / or when to send the mails.
Sorry,
P.S. If you want more control over the delivery then I would suggest you look into either Extended MAPI or SMTP.
Regards,
|
|
|
|
|
Looks like just what I need! However, does this work when the user has a weird email client installed such as Eudora or Ccmail or some other thing like that?
Thanks!
swine
Check out Aephid Photokeeper, the powerful digital
photo album solution at www.aephid.com.
|
|
|
|
|
It will work with any program which is simple MAPI compliant. Last time I used ccMail (v7) it had just addedd support for MAPI. As for Eudora, you will need to contact their tech support to find out that answer.
|
|
|
|
|
Whenever i try to use this program, the outlook express dialog box appears and warn that some external program wants to send mail, do you want to continue?? When i press yes button, another dialog box appears which shows the mail send progress control. I want to get rid of both these dialog boxes. I got rid of first one from Outlook express properties. But unable to get rid of second one. Please tell me how ???
|
|
|
|
|
When I run my programme, the outlook express pop up a warning dialog. However receipts' e-mail adresses don't display in the dialog.
Xilin
|
|
|
|
|
Outlook and Outlook Express brings up a dialog when any program tries to send an unattended email using simple MAPI. There is pretty not much you can do for this. Instead I would recommend you look into alternatives such as CDO for Windows 2000 or using SMTP directly.
|
|
|
|
|
in Outlook
Tools/options under security tab. unselect
the check box
warn me when other applications try to send email as me.
this should disable the warnning box. the progress box takes care of itself. just look away and you wont see it
Regards
Sam
|
|
|
|
|
If the program is run in the user’s machine, How can I set the option by codes?
I think I will have to use CDO or other method to implement it.
Liu Xilin
|
|
|
|
|
What options are you talking about. MAPI is not a redistributable, so you will have to prereq some stuff and fail gracefully if MAPI is not installed. Also you should allow the end user to specify a profile to use just like the sample app does in the download.
|
|
|
|
|
I mean the outlook/outlook express doesn’t bring up a warning dialog when an e-mail is sent. When I run your sample codes in my desktop, I can change my outlook setting (Options->Security->Warning me when other try to send mail as me Unselect the check box) to avoid it. If the program is run in the end users’ machines, how can I ensure that the warning dialog doesn’t appear their machine?
Liu Xilin
|
|
|
|
|
This is actually a shortcoming of the implementation. Besides this issue, this class is wonderful.
You can fix this by adding a new data member to CMapiMessage:
CStringArray m_Addresses;
In Send() before the first recipient address setup loop add the following:
CString szTemp;
message.m_Addresses.RemoveAll();
And then in each TO, CC and BCC loop, make the following changes (don't copy verbatim, but add the new szTemp and m_Addresses and lpszAddress code):
for (int i=0; i<nToSize; i++)
{
MapiRecipDesc& recip = mapiMessage.lpRecips[nRecipIndex];
ZeroMemory(&recip, sizeof(MapiRecipDesc));
recip.ulRecipClass = MAPI_TO;
CString& sName = message.m_To.ElementAt(i);
szTemp = _T("SMTP:") + sName;
int iAddrIdx = message.m_Addresses.Add(szTemp);
CString& sAddr= message.m_Addresses.ElementAt(iAddrIdx);
lpMapiRecipDesc lpTempRecip;
if (Resolve(sName, &lpTempRecip))
{
sName = lpTempRecip->lpszName;
m_lpfnMAPIFreeBuffer(lpTempRecip);
}
recip.lpszName = T2A((LPTSTR) (LPCTSTR) sName);
recip.lpszAddress = T2A((LPTSTR) (LPCTSTR)sAddr);
++nRecipIndex;
}
That's it... now, Outlook (or your MAPI client) will display the dialog and instead of a recipient list that looks like ";;" etc, it will display the lpszAddress strings
-andrew
|
|
|
|
|
I do now follow what your changes are meant to address. if you want to send to an explicit SMTP address, then just use the "SMTP:address" syntax. What's the need for the additional code?
|
|
|
|
|
You can probably leave the SMTP part of my changes out.. but the changes I added prevent blank recipients from being listed by Outlook Express' dialog which asks "Another application is trying to send email. Do you want to send to this people?"
It shows a list that looks like ";;" for three recipients.
After filling in the lpszAddress fields, it displays the recipients as it should.
That's what the user who originally started this topic was concerned about (and I didn't want that displayed from my app either)
Thanks for the great class!
|
|
|
|
|
Ok, Understood. I have just reproduced the same problem on my machine here. I will look into providing a comprehensive fix to this over the weekend.
|
|
|
|
|
Ok, Just to let you know that I have released an update on my web site (www.naughter.com) which addresses this issue.
|
|
|
|
|
After the improvement, the class is cool.
|
|
|
|
|
When I try to build/compile the code I get the following error:
LINK : fatal error LNK1104: cannot open file "mfc42ud.lib"
I have that file on my computer along with all the other happy little mfc libs, any ideas on what the problem might be?
|
|
|
|
|
You are trying to build the Unicode Debug configuration and do not have the necessary libs installed (can be done thro a custom setup of VC). If you are not interested in Unicode, then just build the "Win32 Debug" or "Win32 Release" configuration (using the Build toolbar).
|
|
|
|
|
For the source codes compared for Unicode, you will need this lib file and some other lib files. If you fully install Visual Studio, there should be 33 files under MFC\Lib folder. If you install it by typical option, some file(including mfc42ud.lib) won't be installed in your machine. Therefore, I suggest you re-install Visual Studio or copy these files from other machines.
Liu Xilin
Senior Software Engineer
|
|
|
|
|
Hi,
I have written a application which sends mail.It works
fine.Now i want the user to enter the recepient mail id.
If i set lpszName="";
then
m_lpfnMAPISendMail(MAPISession, 0, &msg, MAPI_DIALOG , 0);
function returns 25.
Here is my receipent struct:
recip.ulReserved = 0;
recip.ulRecipClass = MAPI_TO;
recip.lpszName = "";
recip.lpszAddress = NULL;
recip.ulEIDSize = 0;
recip.lpEntryID = NULL;
// Message Structure
msg.ulReserved = 0;
msg.lpszSubject = subject;
msg.lpszNoteText = note;
msg.lpszMessageType = NULL;
msg.lpszDateReceived = NULL;
msg.lpszConversationID = NULL;
msg.flFlags = 0;
msg.lpOriginator = NULL;
msg.nRecipCount = 1;
msg.lpRecips = &recip;
Is there anyway to specify the
recepient mail id at run time?
Thanks
|
|
|
|
|
I don't see why you need to do all this when my class looks after all this for you. Just add your recipients to the CMapiMessage member variables such as m_To.
|
|
|
|
|
Thanks for the reply..
I got my problem fixed.
|
|
|
|