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
 
Hello Olaf!

Well, I will change code to * .ResolveName(), so it will not be executed and no error will appear.

But what about if in the trap the error routine I put the command:
IF ERROR() = 1429
RETURN
ENDIF

Will it be the same (for the error 1429 -- 'The Automation server is transmitting an error to Visual FoxPro') ?

Thanks,
SitesMasstec
 
Well, if you do something like that you suppress any OLE error. error 1429 is not so special, all OLE errors throw this VFP error number.
You shouldn't do something like that.

Bye, Olaf.
 
Ok, Olaf, I did not suppressed the error, I used...

in the trap error routine:

IF ERROR() >= 1427 AND ERROR() <= 1429
? "E-mail invalid"
[highlight #FCE94F] RETURN .F.[/highlight]
ENDIF


And the main program will show for the user: "Problem with sending e-mail to ... " and will not put the e-mail with error in the Outbox

Thanks,
SitesMasstec
 
Why would someone insist on using a tool that causes so much problem. There are so many other options.


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Hello Mike!

I need to use a tool that sends messages with attachments to the Outbox of an e-mail program, so that, after sending the messages, they can be found in the Sent box.

As far as I know, SMTP just sends the messages but doesn't save the mails in any box. And I need the messages saved.

Thank you,
SitesMasstec
 
OK, then you're not suppressing the error, but doing so for error numbers 1427-1429 is much too general.
Those eror numbers can also happen, when any other OLE error happens with any other OLE class.

If you want to handle error specific to this line you use TRY CATCH here:

Code:
TRY
 .ResolveName()
Catch
  ? "Couldn't resolve name"
EndTry

Besides you can really say the resolving of names failed instead of displaying a general email error. And again said: You only need this, if you'd like to let tcTo be a real name of a person resolved to the mail address, which then is resolved by a lookup in the address book of the mail client.

> I need the messages saved
As I already said about this feature: You may save the mails you send in your own application for users to refer back to them and know what they sent.

Bye, Olaf.
 
In regard of error handling, the ideal place to catch errors of MSMAPI.MAPISESSION and MSMAPI.MAPIMESSAGES is within their Error event. But since you can't change these classes, the first step to introduce Error event code is subclassing these OLE classes with VFPs general OLEControl Class:

vfpmapi1_rtwum0.png


vfpmapi2_zv2yfa.png


Then use the myMAPISession in your code or drag it into your form. Of course repeat this , creatiung myMAPIMessages with the Microsoft MAPI Messages Control.

You can actually also use the Ole class from the second dialog directly on your form and then add code to Error, but you'll need to do that again and again for every usage of the Mapisession control. And if you use the control in code you use it as is.

Don't try to cover specific errors via catching certain error numbers in the general error handler, that's not the best idea at least for any OLE errors, because you cover really all OLE errors, also of totally different OLE classes, controls or automation servers and say they are mail errors. You can use general catching of certain error numbers, where they generally apply to every occurrence of that error number, but the OLE errors happen with a wide variety of OCXes and DLLs - well, all of them.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top