Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending e-mail via MAPI to Outlook 4

Status
Not open for further replies.

SitesMasstec

Programmer
Sep 26, 2010
526
Brasil
Hi colleagues!

I had been using a Visual FoxPro 9 application (with MAPI commands) which sends e-mails automaticaly to the Outlook Express. Operating system was Windows XP. It is working well for years.

Now, I installed the same Visual FoxPro 9 application in a computer with Windows 7 Ultimate, , and the mail application is Outlook (not Outlook Express), which I configured accordingly, to receive mails from the Visual FoxPro 9 application.

But my Visual FoxPro 9 application presents error when it try to send mails to Outlook:
"Application is trying to access e-mail address information stored in Outlook..."
Even if I allow, the messages do not go to the Outlook outbox to be sent.

Do you have any solution?

Thank you.
SitesMasstec
 
Hi Mike!

I used your advice contained in the above link. But the error "Application is trying to access e-mail address information stored in Outlook..." do not desappeared. It appears again.

I am using Outlook 2007.

Thank you.
SitesMasstec

 
Hello colleagues!

Let me explain that I am using Windows 7 Ultimate with Outlook 2007. The solution proposed by Mike has not solved the problem. I've done researchs for days (and nights) but without a solution.

I simply cannot understand this: if I have any e-mail program (Outlook, Outlook Express, Eudora, etc), and if it is defined as the Default mail program, why the VFP program I wrote, to "send e-mails to the Out box of the default mail program" is not able to put my messages there??

Or MAPI is only for use with Outlook Express?

Is there another simpler approach to solve the problem, instead of using MAPI ?

Thank you,
SitesMasstec



 
MAPI is the general solution, yet the full Outlook version is done secure by default and not allowing programmatic usage without the user confirming/allowing it, as you learned especially in case there is no antivirus software installed. So in short MS decided against the MAPI promise to generally allow programmatic mailing and decided for safety of users against becoming a spam sender or against viruses spreading with all their address book contacts.

>Even if I allow, the messages do not go to the Outlook outbox to be sent.
I can't reproduce that right now, last time I was configured that way an allow allowed sending mails.

If your main concern is sending mail and not also having it in the users outbox, there are many ways to send mails directly via SMTP protocol. This is partly a reasoning against the security concern. A virus developer would not automate a mail client, if he can send mails without user notice and without appearing in an outbox. There are commercial libraries removing these security prompts and I rather recommend against them. Get used to this security and ask users that want that mail feature via Outlook to allow sending.

Bye, Olaf.
 
There are two different things going on with what you are saying. Employing the default email client, and programmatically sending emails.
You can most likely tell the default client to start an email using an HTML link with "sendto:". That should create a new email from your default email client, but that won't necessarily allow you to send it, just create it. And like Olaf says, email client makers have disabled the automation of the send functionality because of spammers.
Sending an email programmatically is a whole different process. You have to connect to an email server using telnet or VFP or whatever, use SMTP commands, and let its mechanism do the work. Which means you have to connect, possibly authenticate, feed the body, subject, header, attachments, destination and so on to the server and let it send the email. Your default email client does all of that.


-Dave Summers-
[cheers]
Even more Fox stuff at:
 
I agree with Dave,

though there are ways to get to the default mapi mail client without specifying outlook.application via mapi.ocx or dlls and most probably that's what SitesMasstec already used. The mail API also includes sending, also reading contacts, outbox or inbox and more. Actually security prompts should also be concerned about reading contacts, as they can be used as recipients in further code sending mails via a known/hacked or simply self owned smpt server. You normally only need to be able to handle the default mapi mail client, if you want your actions to be transparent to the user in there, eg having sent items or draft mails saved or whatever your software offers to do in their mail client for them.

It's also no crime to send mails without further traces. Any order form in a shop site may submit a mail to the shop owner directly via mailto action, but that's not at all state of the art. Web forms rather submit your order to a server side api. That's also a reason you get a order confirmation to your mailbox from the shop instead of vice versa having an order to them in your sent items. Orders coming in to them first are stored into their sites database and then processed via data flow to furhter order processing code, not via mails. Order processing code then eg sends an order confirmation in the first place, etc.

Bye, Olaf.
 
Hi SitesMasstec,

I am a Visual Foxpro programmer since 1997. I have realized the automation of email clients via MAPI and VBA as well.

This works well with the following email clients:

- MAPI & VBA: Outlook 97 / 2000 / 2003 / 2010 / 2013
- MAPI: Outlook Express
- MAPI: Mozilla Thunderbird

But with one exception:

- Outlook 2007 !!! MAPI & VBA does not work completely correct !!!

I was looking for a solution by google, by forums, by MSDN, etc. - not only for a few hours - but rather for many days !!!

I have installed many service packs for Office 2007 and Outlook 2007 !!!

No solution !!!

I gave it up - my conclusion is: Outlook 2007 is unfortunately very buggy / faulty

Best regards, Stefan
 
Hello!

The research done by Stefan proved useful for me: Thunderbird is running well integrated with MAPI.

Thank you,

SitesMasstec

 
Hi colleagues!

I followed the advide of Stefan above and, as I had told, it worked fine:

Under Windows 7 - Home Premium - my VFP program sent e-mails to the Outbox of the Thunderbird mail program.

And I thought the problem was solved... until yesterday, when I installed the same program to send e-mails to the Outbox of Thunderbird mail program, in another computer running Windows 7 Ultimate edition!

I did everything I had done in my computer running Windows 7 Home Premium (I ran the application program and Thinderbird as Administrator, registered OCX files, etc), even one thing more: accessing the Windows Firewall and adding a new rule: Unlock 587 door for sending e-mails.

What more am I missing with Windows 7 Ultimate edition ?

Thank you,
SitesMasstec
 
Also, what OCX are we talking about? msmapi32.ocx?
Did you register it with C:\Windows\SysWow64\regsvr32.exe?

Bye, Olaf.

 
Hi Olaf!

Yes, Thunderbird is correctly configured to send/receive mails, but the Windows do NOT have the \SysWow64 folder! (It has \System and \System32 folders) MSMAPI32.OCX is registered with C:\Windows\System32\regsvr32.exe

Windows 7 Ultimate is in 32 bits mode.

Thank you,
SitesMasstec


 
Huh, a real 32bit only system? Sure this is a 32bit CPU?

Ok, besides that doubt: What code? What error?

Bye, Olaf.
 

Well, the "My Computer", "Properties", shows Windows 7 32 bits.

My application catches the error and shows a customized message "Problem sending e-mails" for the application not able to put the e-mail in the Thunderbird Outbox.

Thanks,
SitesMasstec
 
We can't mend code we don't know just knowing there is any error.
It's OK that you keep an error message from your users,m but not from yourself or developers, that should be able to help you.

It's impossible to address a problem, if it's unknown what detail fails.
So please, again, provide your mail code and the error happening.

Bye, Olaf.
 
Hi SitesMasstec,

i suggest to check the programm assignments in the control panel.

Take a look at the following screen shot (i have a german windows):

Assignment_settings_ugdkua.jpg


Important to check the last setting, MAPI !!!

If You want to use Thunderbird, make this settings for Tunderbird instead of Outlook :)

Best regards, Stefan
 
Well, Thunderburd has to be the standard mail client (in the same manner as browsers nag you to want to be the standard browser of your system).

Without knowing your code and error it's quite impossible to tell what stage of your mail creation and sending fails. Whether it's already creating a mapi session or mail item or sending it. So you better introduce the capability to log errors for your own inspection, even if it means nothing to your users, even if it means nothing to you, we can't mend code not even knowing which line errors. And you also won't help yourself going forward, if you never inspect error messages.

Bye, Olaf.

 
OK, I can contribute some english screenshots, though of Windows 8.1:

First of all, go to Control panel. That should have "Default Programs":
defaultprograms_ns3trt.png


The problem may be, Thunderbird is not your default mail client on that machine, it's not so much OS related. But as I said previously Browsers nag you to be standard/default browser. Mail clients are not nagging for that, so typically the first mail client software installed will be the mapi default client.

choose_qy5r7n.png

Click on "Set your default programs" here. This takes a while but then lists software candidate for being some default of something (not only mail or internet) are listed left. What Stefan shows is what you get, if you pick Outlook from there. You should be able to pick Thunderbird, I show you what you get, if you pick Windows Mail:

WindowsMail_b8dozq.png

You see I can pick two options here. This varies, but Thunderbird should also offer some option to be default mail client. Ideally the option is listed under MAPI. So MS Mail does not seem to be a mapi compliant mail client. Indeed I never heard of automating MS Mail since that replace Outlook Express.

Anyway, see what you get, when you go that way to set up defaults and pick Thunderbird.

The point about MAPI is, that you actually shouldn't care about what mail client is used to act on your MAPI session login and commands. Whatever mail client set up as the default/standard and MAPI compliant Mail client should act on it. But it is, as Stefan said in his overview.

You don't need to give up on Thunderbird on that machine, as you might get this fixed. There is no better more general way than MAPI anyway. What worked better, but also varies with the security settings is automating Outlook (desktop version) directly, not through MAPI. That's a route you can only go, if you have a customer installing Outlook on all clients in an automatable way.

The only option aside direct automation and MAPI is sending mails via SMTP or IMAP protocol directly, meaning no storage of a mail inside an outbox or sent items, as already mentioned at my post from 22 Feb 16 22:06:
myself said:
If your main concern is sending mail and not also having it in the users outbox (remark: or later sent items), there are many ways to send mails directly via SMTP protocol.

That would involve knowing a mail server and credentials to login to it, all the config usually known to and configured with the mail client. But you may send all mails via own account connecting to eg your own site smtp or imap mail server.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top