mjolnirmarkiv Posted December 1, 2013 Share Posted December 1, 2013 Hello there! I have a few of questions about OutlookEx UDF. Hope you could help me. What I'm trying to do here is to create an item from OFT-file and replace few placholders in the template with key infromation I need. The problem is, whenever I get body with _OL_ItemGet, naturally, I lose all the formating of original OFT. If there's any way to preserve formating of the template? $oOutlook = _OL_Open () $Item = _OL_ItemCreate ($oOutlook, $olMailItem, "", @ScriptDir & "\Template.oft") $body = _OL_ItemGet ($oOutlook, $Item, Default, "Body") $new_body = StringReplace ($body[1][1], "#filename", "Template.xlsx") _OL_ItemModify ($oOutlook, $Item, Default, "Body=" & $new_body) _OL_ItemDisplay ($oOutlook, $Item) And a couple more non-essential questions: 1) Is there any way to open OFT and do whatever I want and NOT to create an item in Outlook (which immdeately goes into my Drafts folder)? I.e. same behaviour as if I'd have opened OFT in Outlook manually (it won't go to Drafts folder, at least not right away). 2) If no, is there's any way to permanently delete an item? _OL_ItemDelete sotres them in Deleted Items folder and doens't have any flags as far as I know to change that. Thanks in advance! Link to comment Share on other sites More sharing options...
water Posted December 1, 2013 Share Posted December 1, 2013 1) What kind of mail do you create Text, HTML or RFT? 2) I haven't found a way (yet) to delete an item permanently by setting a flag. Call _OL_ItemDelete twice. The first call moves the item to the trash folder and returns the items object. Pas this return value to a second call of _OL_ItemDelete to remove the item from the trash folder. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
mjolnirmarkiv Posted December 1, 2013 Author Share Posted December 1, 2013 Thanks, water! It's HTML. Link to comment Share on other sites More sharing options...
Solution water Posted December 1, 2013 Solution Share Posted December 1, 2013 (edited) To process an HTML body you have to read and write property "HTMLBody". Edited December 1, 2013 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
water Posted December 1, 2013 Share Posted December 1, 2013 And yes, I will add a flag to _OL_ItemDelete to remove the item from the trash folder as well. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
mjolnirmarkiv Posted December 1, 2013 Author Share Posted December 1, 2013 Thanks again, water, I've actually read the similar thread before posting: '?do=embed' frameborder='0' data-embedContent>> but reading HTMLBody didn't work for me for some reason, now I realized there was smth wrong with the template, I've recreated it and it worked nicely! Link to comment Share on other sites More sharing options...
water Posted December 1, 2013 Share Posted December 1, 2013 (edited) This (untested) change should permanently delete an item. Could you give it a try? expandcollapse popup; #FUNCTION# ==================================================================================================================== ; Name ..........: _OL_ItemDelete ; Description ...: Deletes an item (contact, appointment ...) using the specified EntryID and StoreID. ; Syntax.........: _OL_ItemDelete($oOL, $sEntryId[, $sStoreID = Default[, $bPermanent = False]]) ; Parameters ....: $oOL - Outlook object returned by a preceding call to _OL_Open() ; $vItem - EntryID or object of the item to delete ; $sStoreID - Optional: StoreID where the EntryID is stored (default = the users mailbox) ; $bPermanent - Optional: If set to True the item is deleted from the trash folder as well (default = False) ; Return values .: Success - Item object ; Failure - Returns 0 and sets @error: ; |1 - No item has been specified ; |2 - Item could not be found. EntryID might be wrong ; |3 - Item could not be deleted. Please see @extended for more information ; |4 - Item could not be deleted from the trash folder. Please see @extended for more information ; Author ........: water ; Modified ......: ; Remarks .......: To cancel a meeting you have to set property "MeetingStatus" to $olMeetingCanceled and send the meeting again ; Related .......: ; Link ..........: ; Example .......: Yes ; =============================================================================================================================== Func _OL_ItemDelete($oOL, $vItem, $sStoreID = Default) If Not IsObj($vItem) Then If StringStripWS($vItem, 3) = "" Then Return SetError(1, 0, 0) $vItem = $oOL.Session.GetItemFromID($vItem, $sStoreID) If @error Then Return SetError(2, @error, 0) EndIf $vItem.Delete If @error Then Return SetError(3, @error, 0) If $bPermanent = True Then $vItem.Delete If @error Then Return SetError(4, @error, 0) EndIf Return $vItem EndFunc ;==>_OL_ItemDelete Edited December 1, 2013 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
water Posted December 2, 2013 Share Posted December 2, 2013 I just tested and the posted solution to permanently delete items doesn't work on Outlook 2010. None of the solutions found on the web work for me. The EntryID of the item is changed (don't know why) and the object is dropped :by Outlook Looks like the only solution for users is to move the item to the trash folder, then delete the item from the trash folder My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
mjolnirmarkiv Posted December 4, 2013 Author Share Posted December 4, 2013 Nope, doesn't work for me (using Outlook 2007). In fact deleting it twice doesn't work for me either, unless I'm doing smth wrong? _OL_ItemDelete($outlook, _OL_ItemDelete($outlook, $item)) Link to comment Share on other sites More sharing options...
water Posted December 4, 2013 Share Posted December 4, 2013 I have been playing with the move and double delete approach. None of them works with Outlook 2010. So at the moment I have no solution to permanently delete an item My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
mjolnirmarkiv Posted January 28, 2014 Author Share Posted January 28, 2014 (edited) Accidentally found a way to permanently delete in Outlook 2010 (here I'm deleting from Drafts): $source_folder = _OL_FolderAccess ($outlook, "", $olFolderDrafts) $target_folder = _OL_FolderAccess ($outlook, "", $olFolderDeletedItems) $moved_item = _OL_ItemMove ($outlook, $item, $source_folder[3], $target_folder[1]) _OL_ItemDelete ($outlook, $moved_item.EntryID) $item is object, deletion only works only if I get $moved_item.EntryID, doesn't work with object. Edited January 28, 2014 by mjolnirmarkiv Link to comment Share on other sites More sharing options...
water Posted January 28, 2014 Share Posted January 28, 2014 Sounds great! Will test and if I get the same result I will add it to the ItemDelete function. Thanks! My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
water Posted February 1, 2014 Share Posted February 1, 2014 Works great! Will be added to the next version of the UDF. Thanks a lot! My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now