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

Automation not working 1

Status
Not open for further replies.

keepingbusy

Programmer
Apr 9, 2000
1,470
GB

For sometime we have used the following coding to send automated emails from VFP9
Code:
oOutlook = Createobject('Outlook.Application')
oNameSpace = oOutlook.getnamespace('MAPI')
oOutbox = oNameSpace.GetDefaultFolder(4)
oItems = oOutbox.Items
oMailItem = oItems.Add(0)
oMailItem.To = "name@myemail.com"
oMailItem.Subject = "test email subject"
oMailItem.Body = "Email body text"
oMailItem.Send
We have moved our software to another computer that has Outlook 2003 installed and when running a test we get the following error from line 1:
Class definition OUTLOOK.APPLICATION is not found
Any suggestions why this isn't working on one computer (standalone with Windows XP) and working another identical computer?

Thank you guys

Lee
 
How about doing it in a way, that would continue working, when the version independant ProgID get's working again?

Code:
#Define ccOutlookProgID "{0006F03A-0000-0000-C000-000000000046}"

Local loOutlook
Try 
  loOutlook = GetObject(,"Outlook.Application")
Catch
   Try 
     loOutlook = GetObject(,"Outlook.Application.11")
   Catch
      Try 
        loOutlook = CreateObject("Outlook.Application")
      Catch
         Try 
           loOutlook = CreateObject("Outlook.Application.11")
         Catch
            Try 
               loOutlook = CreateObjectEx(ccOutlookProgID,"")
            Catch
               loOutlook = .Null.
            EndTry
         EndTry
      EndTry
   EndTry
EndTry

If IsNull(loOutlook)
   MessageBox("Unable to create an Outlook instance!")
EndIf

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top