none
Visual FoxPro MSMapi session.signoff() causes error

    Question

  • OS: Windows 7 Professional 64-bit

    I have a Purchase Order application, written in VFP50, that allows a user to automatically generate an email, using their default email client, and edit the email prior to sending out to a vendor. This is the code that creates the email:

    local lSession,lMessages
    lSession = createobject("MSMAPI.MAPISession")
    lSession.Signon()
    if (lSession.SessionID >0)
        lMessages = createobject("MSMAPI.MAPIMessages")
        lMessages.SessionID=lSession.SessionID
    endif
    with lMessages
        .Compose()
        if len(csupemail)>0
            .RecipIndex=1
            .RecipAddress=csupemail
            .RecipType=1
        endif
        .RecipIndex=2
        .RecipAddress='xxxxxxxxx@xxxxxx.com'
        .RecipType=3
        .AttachmentPathName=attachfile
        .MsgSubject="Purchase Order "+trim(csearch)
        .MsgNoteText=cmessage
        .Send(.T.)
    endwith
    lSession.Signoff()

    This has worked for many years with no problem under Windows XP. I am testing the application on a new Windows 7 64-bit machine. The application runs fine except for this one part which produces an unspecified Windows error and terminates VFP. The Signoff() command appears to be the culprit. I can type the following three commands into the VFP command window, and watch the signoff() command cause the problem (there is NO error under XP):

    lSession = createobject("MSMAPI.MAPISession")
    lSession.Signon()
    lSession.Signoff()

    I have spent several days searching for a solution before posting here. Any help would be greatly appreciated.

    Thanks
    Sunday, February 19, 2012 9:02 PM

Answers

All replies