Question

How can I get the body of an email into a memo field? I am getting an error.

I am wanting to draw in the body of the email into a memo field.

Error # 1943 MESSAGE: Member ACTIVEINSPECTOR does not evaluate to an object

USE CMCONTROL IN 0
USE CMEMAILS IN 0

local array MyFiles[1,5]
    nFilesFound = ADIR( MyFiles, ALLTRIM(cmcontrol.cpath) + '*.*')
    xx = 0
for i = 1 to nFilesFound
    xx = xx + 1
    WAIT WINDOW NOWAIT 'FortenStar® Count-O-Matic'+CHR(13)+CHR(13)+'Email Record Count: '+ ALLTRIM(STR(xx))
    ***********************************************************************************
    *** HOW CAN I MAKE THIS WORK?
    ***********************************************************************************     
    msgfile=ALLTRIM(cmcontrol.cpath) + ALLTRIM(cmemails.csubject)
    o = CreateObject("Outlook.Application")
    emailmsg = o.ActiveInspector.CurrentItem
    memofiledvariable = emailmsg.body
    ***********************************************************************************
    ***********************************************************************************
    ***********************************************************************************     
    insert into cmemails (cprimary, csubject, ddate, dtime, cattribs, mbody) values (generateGuid(26), MyFiles[ i, 1], MyFiles[ i, 3], MyFiles[ i, 4], MyFiles[ i, 5], memofiledvariable)
endfor
USE IN SELECT('CMEMAILS')
USE IN SELECT('CMCONTROL')
Was it helpful?

Solution

You cannot access an open instance of Outlook by using CREATEOBJECT in FoxPro. You need to use GETOBJECT, and then you need to refer to the specifics you're using.

Some other suggestions:

  1. Don't use single-letter variable names, even if they're not in the short list where FoxPro complains.
  2. Test that o is an object and in a good state before doing anything with it.
  3. Don't use AcitveInspector or its office-kin unless you're looking for something the user is currently looking at. In an example like this, you should be searching the API for how to filter each email item by itself.
  4. While i'm not 100% familiar on Outlook's internal mechanism, if you've got the user's email in a directory of files ALREADY, you really should just see if you can filter that instead. MIME parsers aren't hard to come by if it's in native format, and if it's XML the DOM is easier than VBA.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top