VFP and Outlook Automation

I would like to implement the following scenerio but can not seem to put all the pieces together. I

I have figured out from VFP how create and display a new email but after the user completes the email then clicks send in outlook I would also like to have the option to save this email in .msg format.

I am thinking that I need some sort of unique id that I can use to locate the email and then use the saveas automation function the email with the saveas function.

Any help would be greatly appreciated

Stuart



Answer this question

VFP and Outlook Automation

  • KAAU

    I think what I am looking for is some guidance on the use of the additem event which is fired when the mail message is placed into the sent item folder.
  • Landon Parks

    Stuart,

    Outllook items have storeID and unique EntryID properties (and GetItemFromID method). Below sample is for appointment item but would apply to other items as well:

    Local array aAppts[3]
    For ix = 1 to 3
    aAppts[m.ix] = CreateEntry(m.ix)
    endfor

    For ix = 1 to 3
    oAppt = FindEntry( aAppts[m.ix] )
    oAppt.Subject, oAppt.Start, oAppt.End
    endfor


    Function CreateEntry(tnDatePlus)
    oOutlookObj = CREATEOBJECT("Outlook.Application")
    oNamespace = oOutlookObj.GetNamespace("MAPI")
    lofold = onamespace.GetdefaultFolder(9)
    loAppt = loFold.Items.Add()
    loAppt.Subject = "test"+Transform(m.tnDatePlus)
    loAppt.Start = Datetime() + m.tnDatePlus * 86400
    loAppt.End = Datetime() + m.tnDatePlus * 86400 + 3600
    loAppt.Save
    return loAppt.EntryID


    Function FindEntry(tcId)
    oOutlookObj = CREATEOBJECT("Outlook.Application")
    oNamespace = oOutlookObj.GetNamespace("MAPI")
    lofold = onamespace.GetdefaultFolder(9)
    oItem = onamespace.GetItemFromID(m.tcID, loFold.StoreID)
    Return oItem


  • VFP and Outlook Automation