?
Solved

Address in CMapi doesn't send

Posted on 2010-03-29
7
Medium Priority
?
296 Views
Last Modified: 2013-12-17
I am using CMapi to send a bulk email using MFC.  In my To string, I use a semi-colon to separate addresses and this has been working fine.  However, I have recently added two new email addresses in my list, which for some reason prevent ANY of the recipients from receiving the email if they were included in the same string.

I have done some investigation into the possible reasons for this, and have so far deduced the following.  If I send the same bulk email manually using Outlook, there is no problem.  Also, when I run the same program from another site there is no issue (which leads me to believe it may be something to do with the outgoing mail server).  I can send emails to other addresses with the same domain name, so the domain is not a problem.  Neither are there any characters used in either of these emails which are in others that do work.

I do know that both of these problem-email addresses have mail forwarded to them from other (older) addresses if that helps.  When I use their old addresses, it doesn’t work either.

Any suggestions would be greatly appreciated.
0
Comment
Question by:reidy_boy
  • 4
  • 3
7 Comments
 
LVL 33

Accepted Solution

by:
pgnatyuk earned 800 total points
ID: 28982474
You know that the simplest way to send an email is ShellExecute:
ShellExecute(NULL, L"open",
            L"mailto:someone@somewhere.com\
             ?Subject=Hello, world\
             &body=The email sent from ShellExecute",
            L"", L"", SW_SHOWNORMAL );

Win32 MAPI allows to send emails and it's all explained here:
Sending Email with MAPI
http://www.experts-exchange.com/articles/Programming/System/Windows__Programming/Sending-Email-with-MAPI.html
I prefer this way with Win32.

CMapi is a wrapper for this Simple MAPI.

So all recipients should be added into array. CStringArray?

Here is an example with CMapi (if you need):
http://www.codeguru.com/cpp/i-n/internet/email/article.php/c3371

0
 
LVL 1

Author Comment

by:reidy_boy
ID: 29075571
Hi pgnatyuk, this doesn't solve the problem.  When I run this code it creates and opens the email but doesn't send it.  It needs to be automated.

I studied your article which contains a method similar to what I am doing, but the same thing happens.  It would be very useful if I could send emails silently (i.e. without Outlook being open) but when I try this code it leaves the email in the Outbox until I open Outlook?
0
 
LVL 33

Expert Comment

by:pgnatyuk
ID: 29076122
I use MAPI, not CMapi. And this article contains the real code that sends email.
There is even a comment how to send an to few recipients.
I'm talking about this article: www.experts-exchange.com/A_1820.html
Take an example from this article and test. Then, as a next step, we'll add one more element to
MapiRecipDesc recipient[1] = { 0 };
recipient[0].ulRecipClass = MAPI_TO;
recipient[0].lpszAddress = szTo;
recipient[0].lpszName = szName;

0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
LVL 1

Author Comment

by:reidy_boy
ID: 29080876
I am using the last example in this article, with NULL as the forth parameter to pMAPISendMail in order to run it in silent mode.  I run this code with Outlook closed and nothing happens.  When I open Outlook the email is there in my Outbox.
0
 
LVL 33

Expert Comment

by:pgnatyuk
ID: 29084304
Outlook should be running. Or you need to login before the sending - MAPILogon. How I remember, the last example does it. So modify this part for two or more recipients:
MapiRecipDesc recipient[1] = { 0 };
recipient[0].ulRecipClass = MAPI_TO;
recipient[0].lpszAddress = szTo;
recipient[0].lpszName = szName;

0
 
LVL 33

Expert Comment

by:pgnatyuk
ID: 29084843
There is a newer function MAPILogonEx that supports profiles:
http://msdn.microsoft.com/en-us/library/cc815545.aspx
0
 
LVL 1

Author Closing Comment

by:reidy_boy
ID: 31709839
I think I have got to the cause of this now.  We are fortunate to be a big enough organisation so I can cross check.  The client doesn't need to be running as long as it's Exchange Server 2007, but not 2003.  As for your code, this also works fine and the recipients who weren't getting emails before are receiving them now.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Ready to get certified? Check out some courses that help you prepare for third-party exams.
Steps to fix error: “Couldn’t mount the database that you specified. Specified database: HU-DB; Error code: An Active Manager operation fail”
In this video we show how to create an Address List in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Organization >> Ad…
The video tutorial explains the basics of the Exchange server Database Availability groups. The components of this video include: 1. Automatic Failover 2. Failover Clustering 3. Active Manager

593 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