Sign in to follow this  
Followers 0
mjolnirmarkiv

Few questions about OutlookEx UDF

13 posts in this topic

 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!

Share this post


Link to post
Share on other sites



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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Thanks, water!

It's HTML.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

To process an HTML body you have to read and write property "HTMLBody".

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

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!

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

This (untested) change should permanently delete an item. Could you give it a try?

; #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 by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

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))

Share this post


Link to post
Share on other sites

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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#11 ·  Posted (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 by mjolnirmarkiv

Share this post


Link to post
Share on other sites

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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Works great!

Will be added to the next version of the UDF.
Thanks a lot!


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0