water Posted April 14, 2021 Author Share Posted April 14, 2021 Version 1.6.4.0 of the UDF has been released. Please test before using in production! For download please see my signature. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
Davegbuf Posted February 28, 2022 Share Posted February 28, 2022 I just found out about the UDF a few weeks ago and started using it an a new project. It is exactly what I need and so far so good. I had a little bit of a hard time at first when develping my script and I am wondering if anyone else has run accross the same issue ... As I develop my scripts, I often run them from the Scite editor to see how they are comming along. I noticed that when I use the _OutlookEX UDF and I run the script from the SciTe editor when Outlook is closed then it works fine; but if Outlook is open then I get errors trying to create a connection to Outlook (@error = 1 and @extended = -2147221164). On the other hand, if I compile the script to an EXE then it doesnt matter if Outlook is open or closed because it works fine. Not a big deal because I close Outlook while developing my scripts but it would be convenient to be able to view my email client while I am also developing my scripts. Also, once in a while an instance of Outlook.exe stay open in the background causing the next run to fail even though I use the _OL_Close() function withthe force close option. I am running MS Office 365 on Windows 10 21H2 if that matters at all. Is this just a bug? Is it just me? Your thoughts are welcome. Link to comment Share on other sites More sharing options...
water Posted March 1, 2022 Author Share Posted March 1, 2022 @extended -2147221164 stands for: Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG) Means: The Outlook class is not registered for the user running the script. This could happen if you use #RequireAdmin in your script you us ethe Windows Task Scheduler to run the task Maybe this problem is described here? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
noellarkin Posted October 3, 2022 Share Posted October 3, 2022 expandcollapse popupFunc _GetEmail($sender, $to, $mft, $subject, $regexp, $unread = True) Local $ReturnValue = 0 Local $OutlookSync = _OUTLOOK_Sync() If $OutlookSync Then Local $Mailbox = "C:\Users\" & @UserName & "\Documents\Outlook Files\" & $mft & ".pst" Local $UnreadFilter = "" Select Case $unread = True $UnreadFilter = "[UnRead]=True" Case $unread = False $UnreadFilter = "[UnRead]=False" EndSelect Local $SenderFilter = " And [SenderEmailAddress]='" & $sender & "'" Local $ToFilter = " And [To] = '" & $to & "'" Local $EMailFilters = $UnreadFilter & $SenderFilter & $ToFilter Local $EmailBody = 0 Local $Found = 0 Local $Items = 0 Local $CheckRepeat = 0 $PST = _OL_PSTAccess($GV_OUTLOOKOBJECT, $Mailbox, "") While $CheckRepeat <= 10 $Items = _OL_ItemFind($GV_OUTLOOKOBJECT, $PST, $olMail, $EMailFilters, "Subject", $subject, "SenderEmailAddress, To, ReceivedByName, Subject, Body, CreationTime", "[CreationTime],True", 1) ; _ArrayDisplay($Items) If IsArray($Items) Then Local $Rows = UBound($Items, $UBOUND_ROWS) If $Rows >= 2 Then $EmailBody = $Items[1][4] ; MsgBox(0,"",$EmailBody) $Found = StringRegExp($EmailBody, $regexp, 1) ;MsgBox(0,"",$Found[0]) ;_ArrayDisplay($Found) If IsArray($Found) Then $ReturnValue = $Found[0] EndIf ExitLoop Else Sleep(10) EndIf Else Sleep(10) EndIf $CheckRepeat += 1 Local $Sync = _OUTLOOK_Sync() If $Sync Then Sleep($GC_MINTIME * 12) Else _LogAppend($FunctionName & " Sync:" & $Sync) EndIf WEnd Else _LogAppend($FunctionName & " OutlookSync:" & $OutlookSync) EndIf Return $ReturnValue EndFunc So I wrote this function, it seems to be working well, except in some cases when I want $regexp to query the source code of the Email (not Outlook's plaintext conversion, but the HTML source). Is there any way to force _OL_ItemFind to get the full HTML source of the body and not just the text? Link to comment Share on other sites More sharing options...
water Posted October 3, 2022 Author Share Posted October 3, 2022 Use property HTMLBody. noellarkin 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
noellarkin Posted October 6, 2022 Share Posted October 6, 2022 On 10/3/2022 at 2:05 AM, water said: Use property HTMLBody. Thank you! Link to comment Share on other sites More sharing options...
HurleyShanabarger Posted March 22, 2023 Share Posted March 22, 2023 (edited) Is it possible to create a message and add a signature to that message? Okay, it seems that creating a mail with "BodyFormat=" & $olFormatHTML will empty out the mailbody. This seems to work: _OL_ItemModify($oOutlook, $oMail, Default, "BodyFormat=" & $olFormatHTML, $sgBody & $oMail.HTMLBody) Edited March 22, 2023 by HurleyShanabarger Link to comment Share on other sites More sharing options...
water Posted March 23, 2023 Author Share Posted March 23, 2023 The solution to this problem is described in the wiki: https://www.autoitscript.com/wiki/OutlookEX_UDF_-_Mail_Item#Send_a_mail_or_reply_to_a_mail_with_a_signature My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
orbs Posted March 23, 2023 Share Posted March 23, 2023 how can i work with Outlook Favorites list and Folders tree (in the navigation pane)? i want to get the selected item from the Favorites list, retrieve its target path, and expand the Folders tree to that path. with this UDF i can work with folders and mail items, but i can't figure out how to work with the navigation pane. i tried to look at VBA for the favorites list, but i found only a command to add a folder to the favorites list, and nothing more... Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff Link to comment Share on other sites More sharing options...
water Posted March 23, 2023 Author Share Posted March 23, 2023 Did you have a look at the OutlookEXGUI UDF? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
orbs Posted March 24, 2023 Share Posted March 24, 2023 hmm, i wasn't aware there was a separate UDF for Outlook GUI. with _OL_NavigationFolderGet($oOutlook, $olModuleMail) i was able to get a list of the favorites, and by looping the array i can detect which of them is selected. one concern is, i don't know how fast that would work with dozens of favorites, so is there a way to access the selected one directly? next, i tried to figure out how to expand the folders list to the path i read from the selected favorite item. i thought _OL_SelectionSet would get me there, but i can't figure it out. it expects "Object of the item to be selected" as a parameter, and i don't know what to provide as such. i tried to provide the target path of the selected favorite item, but that returns 0 with @error=1, meaning it is invalid. Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff Link to comment Share on other sites More sharing options...
water Posted March 24, 2023 Author Share Posted March 24, 2023 Is this what you are looking for or at least very similar so it just needs to be modified a bit? BTW: I no longer have access to an Outlook installation so giving support is now a bit harder than before. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
orbs Posted March 24, 2023 Share Posted March 24, 2023 (edited) what i want is to expand the folders tree to highlight a specific folder, selected from favorites. i found that in VBA, it works by setting the CurrentFolder property of an Explorer object. i followed this thread, and it works if i mimic the environment used there, but i can't follow the logic to customize it. i don't understand what is an "Explorer" object in Outlook or how to access and use it. 36 minutes ago, water said: I no longer have access to an Outlook installation congratulations :-) i'm using Thunderbird for personal use. it makes it very easy to handle multiple accounts, and of course... tabbed interface! almost forgot how fun that is since Lotus Notes :-) P.S. i also found this thread, which seems to solve exactly that, but it throws errors on me and i'm stumped. Edited March 24, 2023 by orbs Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff Link to comment Share on other sites More sharing options...
water Posted March 24, 2023 Author Share Posted March 24, 2023 In an Explorer Outlook displays multiple items where you can select from (e.g the content of a folder). In an Inspector Outlook displays a single item (e.g. a mail item). How did you translate the VBA code? Can you please post your AutoIt script? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
orbs Posted March 25, 2023 Share Posted March 25, 2023 (edited) so i guess i need the "Explorer" of the folders tree? i did not translate the VBA code, i simply run it directly from Outlook, but there's something wrong with it, all i get is some array index out of bound error. however, when i run the macro FindFolder() quoted hereunder, it uses InputBox to ask me the folder name, and if that exists, it successfully expands the folders tree to the desired folder. expandcollapse popupPrivate m_Folder As Outlook.MAPIFolder Private m_Find As String Private m_Wildcard As Boolean 'Find a folder by name - case sensitive Public Sub FindFolder() Dim Name$ Dim Folders As Outlook.Folders Set m_Folder = Nothing m_Find = "" m_Wildcard = False Name = InputBox("Find Name:", "Search Folder") If Len(Trim$(Name)) = 0 Then Exit Sub m_Find = Name m_Find = LCase$(m_Find) m_Find = Replace(m_Find, "%", "*") m_Wildcard = (InStr(m_Find, "*")) Set Folders = Application.Session.Folders LoopFolders Folders If Not m_Folder Is Nothing Then If MsgBox("Activate Folder: " & vbCrLf & m_Folder.FolderPath, vbQuestion Or vbYesNo) = vbYes Then Set Application.ActiveExplorer.CurrentFolder = m_Folder End If Else MsgBox "Not Found", vbInformation End If End Sub 'used by the search to loop through Private Sub LoopFolders(Folders As Outlook.Folders) Dim F As Outlook.MAPIFolder Dim Found As Boolean For Each F In Folders If m_Wildcard Then Found = (LCase$(F.Name) Like m_Find) Else Found = (LCase$(F.Name) = m_Find) End If If Found Then Set m_Folder = F Exit For Else LoopFolders F.Folders If Not m_Folder Is Nothing Then Exit For End If Next End Sub the above code uses a loop to search for a folder similar to the keyword input. that seems unnecessary if i already knew the exact target path. what i already made is a simple AutoIt script that detects the target path of the selected favorite folder (it remains resident in the background and responds to Ctrl+Enter): ; based on te example of _OL_NavigationFolderGet #include <OutlookEX_GUI.au3> #include <Array.au3> HotKeySet('^{Enter}', 'main') Global $oOutlook = _OL_Open() If @error <> 0 Then Exit MsgBox($MB_ICONERROR, 'Error!', 'Error creating a connection to Outlook.' & @CRLF & ' @error = ' & @error & ', @extended = ' & @extended) While True Sleep(10) WEnd _OL_Close($oOutlook) Func main() Local $aGroups = _OL_NavigationFolderGet($oOutlook, $olModuleMail) If @error <> 0 Then Exit MsgBox($MB_ICONERROR, 'Error!', '@error = ' & @error & ', @extended = ' & @extended) ;_ArrayDisplay($aGroups, "_OL_NavigationFolderGet with $olModuleMail", "", 0, "|", "Navigation group|Folder name|Folder path|IsSelected?|IsRemovable?|IsSideBySide?|Position") For $i = 1 To $aGroups[0][0] If $aGroups[$i][0] = 'Favorites' And $aGroups[$i][3] = True Then MsgBox(0, 'Selected:', $aGroups[$i][1] & @CRLF & $aGroups[$i][2]) ;MsgBox(0, 'result:', _OL_SelectionSet($oOutlook, $aGroups[$i][2]) & @CRLF & '@error = ' & @error & ', @extended = ' & @extended) Return EndIf Next EndFunc ;==>main now what i need is to consolidate the AutoIt part of detecting the selected favorite folder, and the VBA part that expands the folders tree to it. this means converting either one of them to the other's language; i'm not too comfortable with VBA so i'm still learning... Edited March 25, 2023 by orbs Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff Link to comment Share on other sites More sharing options...
water Posted March 25, 2023 Author Share Posted March 25, 2023 if you have the object of the activated folder it seems you have to use: $oOutlook.ActiveExplorer.CurrentFolder = $oObjectOfTheSelectedFolder My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
orbs Posted March 25, 2023 Share Posted March 25, 2023 (edited) this is most probably correct, but how can i get the object of the folder to be activated, when i know only the properties of its corresponding favorite item? from what i understand from the VBA code above, it loops all folder objects recursively (the LoopFolders sub) until it finds the folder matching the search string, then it returns the object of the folder. i can probably translate that to AutoIt - unless there is a more direct approach? EDIT: _OL_NavigationFolderGet() returns an array of properties of the given folder, such as DisplayName and IsSelected. however there is another property the function does not return - the Folder property - which "Returns a Folder object that represents the shared or linked folder associated with the navigation folder", according to this MS article. this looks like exactly what i'm looking for, so i modified the function to return the Folder property too, then i passed that value to the line you mentioned in the post above, but... that does nothing. i also passed it to _OL_SelectionSet(), and got return value 0 with @error = 2, @extended = -2147352567 @error=2 means "Error selecting the item". EDIT #2: this is getting ridiculous. i get the Folder property and pass it to $oOutlook.ActiveExplorer.CurrentFolder as above. the folder tree does not change. now, i keep the favorite item selected, then i switch to another view - i.e. calendar - then i launch the function again, and guess what? it throws me back to the mail view, and now it does expand the folders tree! Edited March 25, 2023 by orbs Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff Link to comment Share on other sites More sharing options...
water Posted March 25, 2023 Author Share Posted March 25, 2023 If you've got the navigation folder item you could get the "Folder" property of this item to activate the linked folder as described in my last post. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
corbeau56 Posted July 1 Share Posted July 1 (edited) Hi, I am using OutlookEX for a while now. I have written an AutoIt Macro that allows all of my collegues to save their mail in our bureau's internal folder structure. When you are in Outlook, you Press Ctrl-Decimal point, give a project number and then as FileSaveAs-Window opens in the correct project folder, and the filename is prompted (made automatically from the project number, mail date, mail sender and mail subject - this is our bureau's definition of how to save mails). This worked fine for at least 2 years. Since several weeks, we noticed that the mail is saved in plain text format. No changes were made in the macro, we suppose it to be caused by an update of the exchange server, outlook or whatever. I tried some things, like saving the mail items with both data types $olMSG and $olMSGUnicode, no difference. While testing, I noticed, that the mail is saved in plain text only on first attempt! When I repeat saving the mail a second time in exactly the same way, it is saved in HTML-mode correctly !? Any ideas, what could cause this issue? I googled lots of webpages but did not find any similar issue. Greetings Matthias My code (in german) expandcollapse popup; Funktion Mailablage, ausgelöst durch STRG-Komma (Zehnerblock) oder STRG-ä Func Mailablage() Local $pfad, $i_abs ; frage Handle und Class des aktuellen Fensters ab $fhandle = WinGetHandle("[ACTIVE]") $fclass = _WinAPI_GetClassName($fhandle) ; falls Outlook-Fenster If $fclass = $win_Outlook Then ; Verbindung zu Outlook öffnen Local $oOutlook = ObjGet("", "Outlook.Application") ; nur wenn Verbindung zu Outlook gelingt If IsObj($oOutlook) Then ; Verbindung zum ausgewählten Objekt öffnen (das, welches gerade in Outlook markiert ist) Local $aReturn = _OL_FolderSelectionGet($oOutlook) ; abfragen, von welchem Typ es ist (Mail, Kontakt, Termin...) Local $olClass = _OL_ItemGet($oOutlook, $aReturn[1][1], Default, "MessageClass")[1][1] ; nur wenn das Item eine Mail ist If $olClass = "IPM.Note" Then ; ermittele Absender der Mail Local $absender = _OL_ItemGet($oOutlook, $aReturn[1][1], Default, "SenderEmailAddress")[1][1] ; prüfen, ob schon gespeichert $i_abs = _ArraySearch($projekterkennung, $absender, 0, 0, 0, 0, 1) If $i_abs > 0 Then ; wenn gefunden, dann PN im Combo speichern und als Default setzen GUICtrlSetData($Combo_PN, $projekterkennung[$i_abs][1], $projekterkennung[$i_abs][1]) ; Labeltext anpassen und auf grün umstellen GUICtrlSetData($Label_PN, "Projektnummer aus Absender erkannt:") GUICtrlSetColor($Label_PN, 0x107C10) Else ; Labeltext anpassen und auf schwarz umstellen GUICtrlSetData($Label_PN, "Bitte Projektnummer eingeben oder auswählen:") GUICtrlSetColor($Label_PN, 0x000000) EndIf ; Hole Projektnummer $pfad = GetProj() ; nur wenn Eingabe erfolgt If $pfad <> "" Then ; wenn Absender "@xxx.de" enthält, dann ersetze Absender durch "xxx" If (StringInStr($absender, "@xxx.de") > 0 Or StringInStr($absender, "/o=XXX/") > 0) Then $absender = "xxx" ; ermittele Sendedatum der Mail und formatiere es richtig Local $olDate = _OL_ItemGet($oOutlook, $aReturn[1][1], Default, "CreationTime") Local $datum = StringLeft($olDate[1][1], 4) & "-" & StringMid($olDate[1][1], 5, 2) & "-" & StringMid($olDate[1][1], 7, 2) ; ermittele Betreff der Mail und lösche unzulässige Zeichen ; zum Entfernen von Backslash und Anführungszeichen müssen diese innerhalb der eckigen Klammern doppelt stehen! Local $betreff = StringRegExpReplace(_OL_ItemGet($oOutlook, $aReturn[1][1], Default, "Subject")[1][1], "[<>/\\|?*:,;""]", "") ; Mehrfachleerzeichen durch Einfachleerzeichen ersetzen, ggf. mehrfach While StringInStr($betreff, " ") > 0; solange ein doppeltes Leerzeichen gefunden wird $betreff = StringRegExpReplace($betreff, " ", " "); ersetze doppeltes Leerzeichen durch einfaches Leerzeichen WEnd ; alle Leerzeichen durch Unterstriche ersetzen $betreff = StringRegExpReplace($betreff, " ", "_") ; überlange Betreffzeilen kürzen If StringLen($betreff) > 50 Then $betreff = StringLeft($betreff, 40) & "..." & StringRight($betreff, 7) Local $nproj = StringRight($pfad, 5) ; Variable pfad erweitern, neue Ordnerstruktur ab 16300 berücksichtigen If Number($nproj) >= 16300 Then $pfad = $pfad & "\Kommunikation\" Else $pfad = $pfad & "\Faxe_E-Mails\" EndIf ; Prompt für Dateinamen (Vorschlag) erzeugen Local $prompt = $nproj & "_" & $datum & "_" & $absender & "_" & $betreff & ".msg" ; endgültigen Dateinamen über Standarddialog holen, dabei $prompt als Vorschlag anbieten Local $dateiname = FileSaveDialog("ifb-Mail speichern (c)ifb(Wb) 2020-2023", $pfad, "Outlook-Nachrichtenformat - Unicode (*.msg)", 0, $prompt) ; falls nicht Escape gewählt If $dateiname <> "" Then ; Dateinamen auf schon vorhanden prüfen und ggf. anpassen (externe Funktion) $dateiname = NextMsgFilename($dateiname) ; dann Mail speichern Local $olEntryID = _OL_ItemGet($oOutlook, $aReturn[1][1], Default, "EntryID")[1][1] _OL_ItemSave($oOutlook, $olEntryID, Default, $dateiname, $olMsg, 1) ; falls Fehler beim Speichern: Fehlercode anzeigen If @error <> 0 Then MsgBox(0, "Fehler beim Speichern! Fehlercode: ", @error) ; Absender, zugehörige PN und Datum in SQL-Datenbank speichern, aber nur, wenn es nicht "ifb" ist If $absender <> "ifb" Then SQL_AddItem($absender, $nproj, $datum) ; setze Kategorie der Mail in Outlook auf "gespeichert" _OL_ItemModify($oOutlook, $olEntryID, Default, "Categories=gespeichert") ; falls Fehler beim Ändern der Kategorie: Fehlercode anzeigen If @error <> 0 Then MsgBox(0, "Fehler beim Ändern der Kategorie! Fehlercode: ", @error) Else ; in der Dateiauswahl Esc bzw. Abbrechen gewählt --> Warnhinweis anzeigen MsgBox(0, "Wb informiert:", "E-Mail wurde nicht gespeichert!") EndIf ; If (Projektnummer eingegeben) EndIf ; If (Mail-Item ausgewählt) EndIf Else ; Verbindung zu Outlook fehlgeschlagen MsgBox(0, "Wb informiert:", "Verbindung zu Outlook nicht möglich!" & Chr(10) & "Passiert i.A. kurz nach dem Starten von Outlook." & Chr(10) & "Bitte kurz warten und nochmal versuchen.") EndIf ; If (aktuelles Fenster ist Outlook) EndIf EndFunc ;==>Mailablage Edited July 2 by corbeau56 Link to comment Share on other sites More sharing options...
water Posted July 1 Author Share Posted July 1 I had a look at the Outlook UDF and your code snippet. I wonder how a message could get saved as plain text or HTML🤔 $olMSGUnicode is specified in your script and cannot be changes as it is specified as CONST in the UDF. Which extension do you get for the plain text and HTML file? MSG or TXT and HTML? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - 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