none
can not save programmatically made edited in HTMLBody of .oft file RRS feed

  • Question

  • using vba in ms-access 2010 i am opening a .oft file do some FIND and Replace and subsequently try to move the edited mail item to the outbox, however the FIND and replace result is not stored

    (The find and replace action only works if i send the item immediately, however my customer wants the intermediate step via his outbox)

        

     Set MyMail = MyOutlook.CreateItemFromTemplate(OftFile)
        s1 = MyMail.HTMLBody
        s2 = Replace(s1, "!Date!", Format(Date, "dd mmmm yyyy"), 1, , vbTextCompare)
        s3 = Replace(s2, "!mdw_phone!", CStr(mdw_telnr), 1, , vbTextCompare)
        s4 = Replace(s3, "!mdw_employee!", CStr(mdw_naam), 1, , vbTextCompare)
        s5 = Replace(s4, "!mdw_company!", CStr(mdw_bedrijf), 1, , vbTextCompare)
        MyMail.HTMLBody = s5

        MyMail.To = sMailTo
        MyMail.Subject = "Verzoek tot het maken van een afspraak"
        MyMail.Send  'THIS WORKS OK

    HOWEVER

    Set MAPIFolder = MyOutlook.Session.GetDefaultFolder(olFolderOutbox)

    mymail.move  MAPIFolder  'REPLACE CHANGES ARE LOST

    my qyestion: do i have to changes persimmision s somewhere

    please dont discuss why i am doing it this way

    Wednesday, October 15, 2014 1:10 PM

All replies

  • Hello Peter,

    Did you try to call the Save method before moving items?

    Why do you need to move items programmatically? They are dropped to outbox by default.

    Wednesday, October 15, 2014 1:20 PM