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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

E-mail from Visual FoxPro to Outlook Express 1

Status
Not open for further replies.

michel392

Programmer
Dec 17, 2001
54
BR
I have a VFP application which has inserted in it the helpful routine below, provided in this Forum by craigsboyd (Craig Boyd, thanks again !)

I tested the same application in 6 computers (all running Windows 98SE and with Outlook Express 6 SP1, and with the same directory name) and got the following result: in 4 of the computers the application works fine (it sends e-mail and an attachment to the Outlook Express Outbox), but in the other 2 computers the application doesn't send the e-mail to the Outlook Express Outbox and shows the customized error message, saying the e-mail cannot be sent ("Problem sending email!").

I did a lot of things in the 2 computers (the ones which I need the application to work) in which the routine doesn't work: reinstalled the Outlook Express 6, installed some update files downloaded from Microsoft, almost a hundred reinitialization in both machines during a whole week, but I haven't got the application to send e-mail !

How to make the Outlook Express to do this job ? How to know if a computer is ready for that application ?

Thanks,

Michel


---------------------------------------------------------
Routine provided by Craig Boyd (craigsboyd) in this forum
---------------------------------------------------------
*!* Sample Use of SendViaMAPI
DIMENSION aryAttachments(2)
aryAttachments(1) = "C:\test1.txt"
aryAttachments(2) = "C:\test2.txt"
IF SendViaMAPI("me@myhost.com", "someone@theirhost.com", "My Subject Line", "My Email Body", @aryAttachments)
MESSAGEBOX("Email sent successfully!")
ELSE
MESSAGEBOX("Problem sending email!")
ENDIF


****************************************************
FUNCTION SendViaMAPI(tcFrom, tcTo, tcSubject, tcBody, taFiles)
****************************************************
ON ERROR RETURN(.F.)
LOCAL loSession, loMessages
loSession = CREATEOBJECT( "MSMAPI.MAPISession" )
loSession.Signon()
IF (loSession.SessionID > 0)
loMessages = CREATEOBJECT( "MSMAPI.MAPIMessages" )
loMessages.SessionID = loSession.SessionID
ENDIF
WITH loMessages
.Compose()
.RecipDisplayName = tcTo
.RecipType = 1
.ResolveName()
.MsgSubject = tcSubject
.MsgNoteText = tcBody
IF PCOUNT() > 4
FOR lnCountAttachments = 1 TO ALEN(taFiles)
.AttachmentIndex = .AttachmentCount
.AttachmentName = JUSTFNAME(taFiles(lnCountAttachments))
.AttachmentPosition = .AttachmentIndex
.AttachmentPathName = taFiles(lnCountAttachments)
ENDFOR
ENDIF
.SEND(.F.) && send in .T. to not send email automatically but instead see it in outlook
ENDWITH
loSession.Signoff()
STORE .NULL. to loSession, loMessages
RELEASE loSession, loMessages
RETURN .T.
ENDFUNC
 
Make the line...

ON ERROR RETURN(.F.)

...and change it to...

ON ERROR && or whatever your usual error handling routine is

...this should tell you where it is failing and give you a little better idea of what is going on.

boyd.gif

SweetPotato Software Website
My Blog
 
After doing what Craig suggested, the following error appears:

"Program error
Class definition MSMAPI.MAPISESSION is not found"

What have I to do in order to solve this problem ?

Thank you,

Michel

 
I simply copied the MSMAPI32.OCX and MSMAPI32.DEP files from a computer (in which the routine provided by Craig works fine) to the C:\WINDOWS\SYSTEM directory at the computer which the routine doesn't work (and these files did not exist on that computer).

After that, I executed the routine and the result is that it continues to give the "Class definition MAPI.MAPISESSION is not found" error.

What to do to register the file in the computer ?

Thanks,

Michel
 

Hello Marcia:

I executed the command you provided above and the MSMAPI32.OCX was succesfully registered (the MSMAPI32.OCX and MSMAPI32.DEP files are in the C:\WINDOWS\SYSTEM directory).

But when I tried to executed the application (with the routine provided by Craig Boyd, above) the following error appears:

"OLE Error code 0x80040111: Apropriate licence for this class not found."

What am I missing ?

Thank you,

Michel

 
michel392,

You have to put the mapisession and mapimessage controls on a form in your project or you must subclass them as olecontrols in a class library in your project. If you don't do this, you will get the error you are seeing here... Basically MSMAPI requires a development time license (what you get with VFP) to use these controls when you create them or add them to a container in code. To workaround this, you must do one of the two things I wrote about above, this will create a scenario where only the run-time license for the controls is needed, which is the situation you will have run into when you are using the controls on the user's computer.

boyd.gif

SweetPotato Software Website
My Blog
 

Following Craig's advice (above) I created a new form in my project and just dropped on it the Mapisession and Mapimessage Active X controls. The form has just the two mentioned controls, nothing more. After that, I created a new executable file of the project.

When I executed the program I got the same error:
"OLE Error code 0x80040111: Apropriate licence for this class not found."

Is there anything more to do ?

Thanks,

Michel
 
michel392,

sub-class the controls as OLEControls in a vcx for your project. Then change the createobject lines of code in your email code to reference these new subclasses, basically something like...

Set Library to MyLib.vcx
loSession = CREATEOBJECT( "MyMapiSession" )

...if you are going to use a form instead, then you will need to use the controls from the form. Either the form will be visible to the user or can be used invisible... but the option I gave you above is the easiest way to do this. Sorry if I wasn't clear enough in my earlier post.

boyd.gif

SweetPotato Software Website
My Blog
 
Hi Michel.

Is there anything more to do ?

Yes. Check out the knowledge base - PSS ID Number: 192693 for an explanation:

BUG: License Error with ActiveX Control Added at Run-Time

This article was previously published under Q192693

SYMPTOMS

If you create an application that uses an ActiveX control that you add at run-time with syntax similar to the following:

Code:
THISFORM.AddObject("myctrl","olecontrol","mscomctllib.listviewctrl.2")

Then you build this application into an executable file, create a distribution with the Setup Wizard, and install your application on other computers, when you attempt to run code similar to the preceding code you receive an error like the following:

Program Error
OLE error code 0x80040112: Appropriate license for this class not found.

CAUSE

A distribution created with the Visual FoxPro Setup Wizard only allows a run-time license, while the AddObject method requires a design time license.

RESOLUTION
Add the control you want to use into a class that is saved in a Visual Class library or into a class created with the DEFINE CLASS command. Next, add an instance of the class at run-time instead of adding the control. Please see the MORE INFORMATION section for details.

Marcia G. Akins
 
Hi Marcia, I went to Microsoft.com Knowledge Base article # 192693 , and followed instruction in the MORE INFORMATION section for details, but using MSMAPI32 controls in my program. I continue to get "license error"...

I thought I could add (it seems so normal) the MAPI Session and MAPI Messages controls in my project (in the tab Classes), and just build the executable file and put the .EXE in any machine to run without any problem with the licensing subject !

Craig, sorry I don't understand your explanation above (I am not a VFP expert like you and Marcia ...) Your explanation above, about using sub-class, is cited in the article referred by Marcia, as an alternative solution. And it seems to be the simpler alternative (CREATE CLASS, ..., etc). I think that if I have a more detailed explanation I can understand how to solve this big problem.

Thank you all for your patience.

Michel




 
I thought I could add (it seems so normal) the MAPI Session and MAPI Messages controls in my project (in the tab Classes), and just build the executable file and put the .EXE in any machine to run without any problem with the licensing subject !

Well, activeX control need to be present and registered on the machine where they will be used, so it requires a little more than that. Your installation program should handle installing the activeX control on the user's machine and register it.

I went to Microsoft.com Knowledge Base article # 192693 , and followed instruction in the MORE INFORMATION section for details, but using MSMAPI32 controls in my program. I continue to get "license error"...

I am fresh out of ideas. You may want to search the MSDN library for "MSMAPI32" and "license error" and see if you can come up with anything else.





Marcia G. Akins
 
I haven't understood your explanation above (I am not a VFP expert like you and Marcia ...) Your explanation above, about using sub-class, is cited in the article referred by Marcia, as an alternative solution. And it seems to be the simpler alternative (CREATE CLASS, ..., etc). I think that if I have a more detailed explanation I can understand how to solve this big problem.

Thank you all for your patience.

Michel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top