Jump to content

OutlookEX UDF - Help & Support (II)


water
 Share

Recommended Posts

i will post the code, just let me comment it properly... sometimes i get the feeling the commenting is the harder part of coding...

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

Only sometimes? I always find it hard to write down in simple words how the function works and which parameters are expected. When the questions of the users drop in I know that i often missed relevant parts or was unclear in the way I described the function.

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

ok, here goes:
 
see 5 functions:
 
the main function _OL_ProfileGetCurrent() is called by a script to return the currently used Outlook profile.

 
how it works:
 
it calls __OL_PSTGet_StoreID_FromOutlook() which returns a list of mail stores currently loaded to Outlook.
 
regardless, it calls __OL_ProfileGetRegKey() which returns the registry key where Outlook profiles are stored.
 
for every profile stored in the registry, a list of mail stores is produced.by calling __OL_PSTGet_StoreID_FromRegistry()
 
one by one, the list generated from Outlook is compared to every list generated from the registry, by calling _Array_Compare2D()
 
if only a single match is found, then the related profile name is returned to the calling script.
 
the entire process works with Outlook XP and above, also tested on Outlook 2013 64-bit.
what can i say, i did warn you it's not a one-liner...
 

; #FUNCTION# ====================================================================================================================
; Name ..........: _OL_ProfileGetCurrent
; Description ...: Returns the currently used Outlook profile.
; Syntax.........: _OL_ProfileGetCurrent($oOL)
; Parameters ....: $oOL          - Outlook object returned by a preceding call to _OL_Open()
; Return values .: Success - The currently used Outlook profile.
;                  Failure - Returns "" and sets @error:
;                  |1 - Error connecting to Outlook
;                  |2 - Error generating currently loaded stores list
;                  |3 - Error determining teh registry key where Outlook profiles are stored
;                  |4 - No Outlook profiles are stored in the registry
;                  |5 - No match found
;                  |6 - Multiple matches found
; Author ........: orbs
; Modified ......:
; Remarks .......: the following steps are taken to produce the currently used Outlook profile:
;                  1) a list of mail stores currently loaded to Outlook is genereted
;                  2) a list of Outlook profiles stored in the registry is genereted
;                  3) for every profile stored in the registry, a list of mail stores is produced.
;                  4) the list generated in step (1) is compared to each of the lists generated in step (3)
;                  5) if a single match is found, the profile name is returned
; Related .......: _Array_Compare2D
;                  __OL_ProfileGetRegKey
;                  __OL_PSTGet_StoreID_FromOutlook
;                  __OL_PSTGet_StoreID_FromRegistry
; Link ..........:
; Example .......:
; ===============================================================================================================================
Func _OL_ProfileGetCurrent($oOL)
    ; init
    Local $sResult=''
    Local $nResults=0
    Local $s_OL_RegKeyProfiles=''
    Local $sProfile=''
    Local $nProfiles=0
    Dim $aProfiles[1]=[0]
    ; verify connection to Outlook
    If $oOL=0 Then Return SetError(1,0,'')
    ; get PSTs list from Outlook
    $aPST_Outlook=__OL_PSTGet_StoreID_FromOutlook($oOL)
    If $aPST_Outlook[0][0]=0 Then Return SetError(2,0,'')
    _ArraySort($aPST_Outlook)
    ; get profiles list key in registry
    $s_OL_RegKeyProfiles=__OL_ProfileGetRegKey($oOL)
    If $s_OL_RegKeyProfiles='' Then Return SetError(3,0,'')
    ; get list of profiles from registry
    While True
        $sProfile=RegEnumKey($s_OL_RegKeyProfiles,$nProfiles+1)
        If @error <> 0 Then ExitLoop
        $nProfiles+=1
        ReDim $aProfiles[$nProfiles+1]
        $aProfiles[$nProfiles]=$sProfile
        $aProfiles[0]=$nProfiles
    WEnd
    If $nProfiles=0 Then Return SetError(4,0,'')
    ; for each profile get list of PSTs and compare to PSTs list from Outlook
    For $i=1 To $aProfiles[0]
        $aPST_Reg=__OL_PSTGet_StoreID_FromRegistry($aProfiles[$i],$s_OL_RegKeyProfiles)
        _ArraySort($aPST_Reg)
        $aDiff=_Array_Compare2D($aPST_Outlook,$aPST_Reg)
        If $aDiff[0][0]=0 Then
            $nResults+=1
            $sResult=$aProfiles[$i]
        EndIf
    Next
    ; return
    Switch $nResults
        Case 0  ; no match found
            Return SetError(5,0,'')
        Case 1  ; match
            Return $sResult
        Case Else   ; multiple match
            Return SetError(6,0,'')
    EndSwitch
EndFunc

; #FUNCTION# ====================================================================================================================
; Name ..........: _Array_Compare2D
; Description ...: Compares the first two diemnsions of two input arrays.
; Syntax.........: _Array_Compare2D($a1,$a2)
; Parameters ....: $a1,$a2 - two 2D arrays.
; Return values .: An array of size [n+1][3], where n is the number of differences, and the columns are:
;                  rows 1..n:
;                    cell position (zero-based) | value in $a1 | value in $a2
;                  row 0:
;                    cell [0][0] holds the number of differences, 0 means no differences, -1 means some mismatch between the arrays sizes or dimensions.
;                    cell [0][1] holds the sizes of dimensions of $a1 (only 1st two dimentions)
;                    cell [0][2] holds the sizes of dimensions of $a2 (only 1st two dimentions)
;                  an array is always returned, even when an error occurs - see "Remarks" section hereunder.
; Author ........: orbs
; Modified ......:
; Remarks .......: input variables, 1D arrays, or arrays different in sizes, are handled as described in the "Return values" section above, also see Exmple #2 hereunder
;                  to use this function as boolean indication (arrays are either identical or not), check cell [0][0] of the return array:
;                    arrays are identical only when cell [0][0] holds 0.
;                  Example #1: in case the arrays are of size 8x7 and are identical except of:
;                    $a1[3][1]='ABC' and $a2[3][1]='DEF'
;                    $a1[5][6]='123' and $a2[5][6]='456'
;                  the return array will be:
;                    +---+---+---+
;                    | 2 |8x7|8x7|
;                    +---+---+---+
;                    |3x1|ABC|DEF|
;                    +---+---+---+
;                    |5x6|123|456|
;                    +---+---+---+
;                  Example #2: in case the arrays sizes are different: $a1 size = 3x2 , $a2 size = 1x2
;                  the return array will be:
;                    +---+---+---+
;                    | -1|3x2|1x2|
;                    +---+---+---+
;                  note: 1D array of size 3 will be noted as 3x0, a variable will be noted as an array of size 0x0
; Related .......:
; Link ..........:
; Example .......:
; ===============================================================================================================================
Func _Array_Compare2D($a1,$a2)
    ; declare
    Local $a3[1][3] ; will be filled and returned
    Local $n=0      ; the number of differences
    Local $i,$j     ; loop index variables
    ; init
    $a3[0][0]=0
    $a3[0][1]=UBound($a1,1)&'x'&UBound($a1,2)
    $a3[0][2]=UBound($a2,1)&'x'&UBound($a2,2)
    If UBound($a1,0)<>2 Or (Ubound($a1,1)<>Ubound($a2,1)) Or (Ubound($a1,2)<>Ubound($a2,2)) Then
        $a3[0][0] = -1
    Else
        ; compare
        For $i=0 To UBound($a1,1)-1
            For $j=0 To UBound($a1,2)-1
                If $a1[$i][$j]<>$a2[$i][$j] Then
                    $n+=1
                    ReDim $a3[$n+1][3]
                    $a3[0][0]=$n
                    $a3[$n][0]=$i&'x'&$j
                    $a3[$n][1]=$a1[$i][$j]
                    $a3[$n][2]=$a2[$i][$j]
                EndIf
            Next
        Next
    EndIf
    ; return
    Return $a3
EndFunc   ;==>_Array_Compare2D

; #FUNCTION# ====================================================================================================================
; Name ..........: __OL_ProfileGetRegKey
; Description ...: Returns the key where Outlook profiles are stored. different versions of Outlook use different keys.
; Syntax.........: __OL_ProfileGetRegKey($oOL)
; Parameters ....: $oOL          - Outlook object returned by a preceding call to _OL_Open()
; Return values .: Success - The registry key where Outlook profiles are stored
;                  Failure - Returns "" and sets @error:
;                  |1 - Error connecting to Outlook
;                  |2 - Error retrieving Outlook version
; Author ........: orbs
; Modified ......:
; Remarks .......:
; Related .......: _OL_ProfileGetCurrent
;                  __OL_ProfileGetRegKey
; Link ..........:
; Example .......:
; ===============================================================================================================================
Func __OL_ProfileGetRegKey($oOL)
    Local $s_OL_RegKeyProfiles=''
    ; verify connection to Outlook
    If $oOL=0 Then SetError(1,0,'')
    ; get Outlook version
    $aVersion=StringSplit($oOL.Version, '.')
    If @error Then SetError(2,0,'')
    ; parse version number for registry key location
    If Int($aVersion[1])>=15 Then   ; Outlook 2013 and later
        $s_OL_RegKeyProfiles='HKCU\Software\Microsoft\Office\15.0\Outlook\Profiles'
    Else    ; Outlook 2010 and earlier
        $s_OL_RegKeyProfiles='HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles'
    EndIf
    Return $s_OL_RegKeyProfiles
EndFunc

; #FUNCTION# ====================================================================================================================
; Name ..........: __OL_PSTGet_StoreID_FromOutlook
; Description ...: Returns a list of currently accessed mail stores
; Syntax.........: __OL_PSTGet_StoreID_FromOutlook($oOL)
; Parameters ....: $oOL - Outlook object returned by a preceding call to _OL_Open()
; Return values .: Success - two-dimensional one-based array with the following columns:
;                  |0 - Display name of the mail store
;                  |1 - StoreID of the mail store
;                  Failure - Returns "" and sets @error:
;                  |1 - Error accessing namespace object. For details check @extended
; Author ........: water
; Modified ......: orbs
; Remarks .......: based on function _OL_PSTGet by water
; Related .......: _OL_ProfileGetCurrent
; Link ..........:
; Example .......:
; ===============================================================================================================================
Func __OL_PSTGet_StoreID_FromOutlook($oOL)
    Local $sFolderSubString, $sPath, $iIndex1 = 0, $iIndex2, $iPos, $aPST[1][2]
    $aPST[0][0]=0
    Local $oNamespace = $oOL.GetNamespace("MAPI")
    If @error Or Not IsObj($oNamespace) Then Return SetError(1, 0, "")
    For $oFolder In $oNamespace.Folders
        $sPath = ""
        For $iIndex2 = 1 To StringLen($oFolder.StoreID) Step 2
            $sFolderSubString = StringMid($oFolder.StoreID, $iIndex2, 2)
            If $sFolderSubString <> "00" Then $sPath &= Chr(Dec($sFolderSubString))
        Next
        If StringInStr($sPath, "mspst.dll") > 0 Or StringInStr($sPath, "pstprx.dll") > 0 Then
            ReDim $aPST[UBound($aPST, 1) + 1][UBound($aPST, 2)]
            $iIndex1 = $iIndex1 + 1
            $aPST[$iIndex1][0] = $oFolder.Name
            $aPST[$iIndex1][1] = $oFolder.StoreID
            $aPST[0][0] = $iIndex1
        EndIf
    Next
    Return $aPST
EndFunc

; #FUNCTION# ====================================================================================================================
; Name ..........: __OL_PSTGet_StoreID_FromRegistry
; Description ...: Returns a list of currently accessed mail stores
; Syntax.........: __OL_PSTGet_StoreID_FromRegistry($sProfile,$s_OL_RegKeyProfiles [,$bFileNameInsteadOfStoreID = False])
; Parameters ....: $oOL - Outlook object returned by a preceding call to _OL_Open()
;                  $s_OL_RegKeyProfiles - Registry key that holds Outlook profiles, returned by __OL_ProfileGetRegKey
;                  $bFileNameInsteadOfStoreID - if True, then the file name of the mail store is returned instead of the StoreID
; Return values .: Success - two-dimensional one-based array with the following columns:
;                  |0 - Display name of the mail store
;                  |1 - StoreID or full file name of the mail store
;                  Failure - two-dimensional array of size [1][2], where cell[0][0]=0
; Author ........: orbs
; Modified ......:
; Remarks .......:
; Related .......: _OL_ProfileGetCurrent
;                  __OL_ProfileGetRegKey
; Link ..........: http://www.codeproject.com/Articles/273751/How-to-list-your-Outlook-PST-details-file-name-loc
; Example .......:
; ===============================================================================================================================
Func __OL_PSTGet_StoreID_FromRegistry($sProfile,$s_OL_RegKeyProfiles,$bFileNameInsteadOfStoreID=False)
    Local Const $sRegKeyMaster='9207f3e0a3b11019908b08002b2a56c2'
    Local Const $sRegValMasterConfig='01023d0e'
    Local Const $sRegValPST_IsPST='00033009'
    Local Const $sRegValPST_DataKey='01023d00'
    Local Const $sRegValPST_DisplayName='001f3001'
    Local Const $sRegValPST_DisplayNameOld='001e3001'
    Local Const $sRegValPST_FileName='001f6700'
    Local Const $sRegValPST_StoreID='01020fff'
    Local $sRegValPST_ToTake=$sRegValPST_StoreID
    Local $sRegKeyPST=''
    Local $sRegDatPSTs=''
    Local $i=0
    Local $nResult=0
    Dim $aResult[1][2]
    If $s_OL_RegKeyProfiles='' Then Return $aResult
    If $bFileNameInsteadOfStoreID Then $sRegValPST_ToTake=$sRegValPST_FileName
    $sRegDatPSTs=RegRead($s_OL_RegKeyProfiles&'\'&$sProfile&'\'&$sRegKeyMaster,$sRegValMasterConfig)
    If @error Then Return $aResult
    $sRegDatPSTs=String(Hex($sRegDatPSTs))
    Local $nCount=Ceiling(StringLen($sRegDatPSTs)/32)
    Local $sRegKeyAssumedRedirectsToPST
    For $i=1 To $nCount
        $sRegKeyAssumedRedirectsToPST=StringMid($sRegDatPSTs,1+($i-1)*32,32)
        If StringLeft(String(Hex(RegRead($s_OL_RegKeyProfiles&'\'&$sProfile&'\'&$sRegKeyAssumedRedirectsToPST,$sRegValPST_IsPST))),2)='20' Then
            $nResult+=1
            ReDim $aResult[$nResult+1][UBound($aResult,2)]
            $aResult[0][0]=$nResult
            $sRegKeyPST=String(Hex(RegRead($s_OL_RegKeyProfiles&'\'&$sProfile&'\'&$sRegKeyAssumedRedirectsToPST,$sRegValPST_DataKey)))
            $aResult[$nResult][0]=RegRead($s_OL_RegKeyProfiles&'\'&$sProfile&'\'&$sRegKeyPST,$sRegValPST_DisplayNameOld)
            If $aResult[$nResult][0]='' Then $aResult[$nResult][0]=StringTrimRight(BinaryToString(RegRead($s_OL_RegKeyProfiles&'\'&$sProfile&'\'&$sRegKeyPST,$sRegValPST_DisplayName),2),1)
            $aResult[$nResult][1]=StringTrimLeft(RegRead($s_OL_RegKeyProfiles&'\'&$sProfile&'\'&$sRegKeyPST,$sRegValPST_ToTake),2)
        EndIf
    Next
    Return $aResult
EndFunc

PS: about _OL_PSTGet() i think we can just add the condition checking for pstprx.dll, no further modification is required.

Edited 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

orbs,

thanks a lot for this functions! You are correct, it's not a one-liner.

I will have a look and test with Outlook 2010 as soon as I find some spare time.

I will post again as soon as I have finished testing - but please don't hold your breath :x

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

  • 2 weeks later...

orbs,

I did find some spare time and tested your code. It runs fine here with Outlook 2010 :thumbsup:

As the function is a one-liner starting with Outlook 2007 and not too much people seem to use Outlook 2003 any longer (and need the current profile name) I think it is not sensible to add > 200 lines to the UDF.

But I think the Example Scripts thread for the UDF would be the perfect place to publish your script. If you like, just add it tho the thread.

In addition I can add it to the first post so it gets more attention of the users.

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

agreed. i will add have added the code to the Example Scripts thread.

also, to keep the mystery... i will soon share the greater goal of this entire work.

i think (and hope) you'll like it.

Edited 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

I will post have posted a >link to your code on the first page of the Example Scripts thread.

Edited by water

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

since i found no free programs to do it (actually just one, but not the way i want it), i added something to the Example Scripts:

a full featured PST to MSG converter.

state-of-the-art, if i may humbly say so myself. tops some of the commercial programs i tried.

enjoy!

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

I have posted a >link to your code on the first page of the Example Scripts thread.

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

Hi Water,

I was wondering if you could help me with something. I'm using the UDF to get new mail items but it gets them before they are processed by any of my rules/filters. Is there way to get a new email after it has been processed or filtered?
I want to send myself a text message with the From:, Subject:, and body of every new email I get in my inbox after it has been filtered by my rules. Right now I'm getting a text messege for every single email I get and I only want to get a text message for emails that stay in my inbox. I hope my code makes sense.

Thank you!

#AutoIt3Wrapper_Au3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#AutoIt3Wrapper_Au3Check_Stop_OnWarning=Y
 
#region
 
#include <OutlookEX.au3>
#include <IE.au3>
#include <File.au3>
#include <String.au3>
#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#include <Constants.au3>
;#NoTrayIcon
 
_IEErrorHandlerRegister()
_IEErrorNotify(False)
 
Opt("GUIOnEventMode", 1)
Opt("WinTitleMatchMode", 3)
Opt("TrayOnEventMode", 1)
Opt("TrayMenuMode", 1)
 
TrayCreateItem("Change Settings")
TrayItemSetOnEvent(-1, "_Change")
TrayCreateItem("Exit")
TrayItemSetOnEvent(-1, "_Exit")
 
Global $settingsDir = "c:\users\" & @UserName & "\AppData\Local\AutoIT\Settings.txt"
Global $attempts = 0
OpenOutlook()
Login()
 
#endregion
 
Func OpenOutlook()
 
   Local $exit = 0
   Do
      If ProcessExists("OUTLOOK.EXE") Then
         Global $oOApp = ObjCreate("Outlook.Application")
         Global $test = ObjEvent($oOApp, "oOApp_")
         $exit = 1
      Else
         Run("C:\Program Files (x86)\Microsoft Office\Office14\OUTLOOK.EXE")
         Sleep(5000)
         $exit = 0
      EndIf
   Until $exit = 1
 
EndFunc ;==> End of OpenOutlook()
 
Func Login()
 
   Global $username, $password, $phone, $limit, $format, $ifrom, $isubj, $ibody, $cryptkey, $caretech
   Local $sArray[1]
   If FileExists($settingsDir) Then ;if settings file exists
      Local $mcryptkey = InputBox("Login - Encryption Key", "Type Master Encryption Key:", "", "xM", 150, 120)
      _FileReadToArray($settingsDir, $sArray)
      Local $cryptkey = _StringEncrypt(0, $sArray[1], $mcryptkey, 5)
      If $cryptkey = $mcryptkey Then
      Else
         $attempts += 1
         If $attempts > 3 Then
            MsgBox(64, "WARNING", "Maximum attempts reached. Deleting settings file. Relaunch program and set new Encryption Key")
            FileDelete($settingsDir)
            Exit
         Else
            Login()
         EndIf
      EndIf
      $username = _StringEncrypt(0, $sArray[2], $mcryptkey, 5)
      $password = _StringEncrypt(0, $sArray[3], $mcryptkey, 5)
      $phone = _StringEncrypt(0, $sArray[4], $mcryptkey, 5)
      $limit = $sArray[5]
      $format = $sArray[6]
      $ifrom = $sArray[7]
      $isubj = $sArray[8]
      $ibody = $sArray[9]
      $caretech = $sArray[10]
   Else ;if settings file doesn't exist
      Global $mainGUI = GUICreate("User Credentials", 490, 160)
      GUISetOnEvent($GUI_EVENT_CLOSE, "On_Close")
      GUICtrlCreateLabel("GV Username:", 10, 10, 150, 20)
      $username = GUICtrlCreateInput("", 10, 25, 150, 20)
      GUICtrlCreateLabel("GV Password:", 170, 10, 150, 20)
      $password = GUICtrlCreateInput("", 170, 25, 150, 20, $ES_PASSWORD)
      GUICtrlCreateLabel("Number to send texts to:", 330, 10, 150, 20)
      $phone = GUICtrlCreateInput("", 330, 25, 150, 20)
      $limit = GUICtrlCreateCheckbox("Limit TXT message size", 10, 55, 150, 20)
      GUICtrlSetState(-1, $GUI_CHECKED)
      $format = GUICtrlCreateCheckbox("Remove repeated CR\LF", 170, 55, 150, 20)
      GUICtrlSetState(-1, $GUI_CHECKED)
      $caretech = GUICtrlCreateCheckbox("Format CareTech e-mails", 330, 55, 150, 20)
      GUICtrlSetOnEvent(-1, "On_CareTech")
      GUICtrlSetState(-1, $GUI_UNCHECKED)
      GUICtrlCreateLabel("Master Encryption Key:", 10, 85, 150, 20)
      $cryptkey = GUICtrlCreateInput("", 10, 100, 150, 20, $ES_PASSWORD)
      GUICtrlCreateLabel("Include these fields in text:", 170, 85, 300, 20)
      $ifrom = GUICtrlCreateCheckbox("Sender's name", 170, 100, 95, 20)
      GUICtrlSetState(-1, $GUI_CHECKED)
      $isubj = GUICtrlCreateCheckbox("Subject content", 275, 100, 95, 20)
      GUICtrlSetState(-1, $GUI_CHECKED)
      $ibody = GUICtrlCreateCheckbox("E-mail's content", 380, 100, 95, 20)
      GUICtrlSetState(-1, $GUI_CHECKED)
      $save = GUICtrlCreateButton("Save and Close", 10, 130, 470, 20)
      GUICtrlSetOnEvent(-1, "On_Save")
 
      GUISetState()
   EndIf
 
   While 1
   WEnd
 
EndFunc
 
Func _Change()
 
   Global $username, $password, $phone, $limit, $format, $ifrom, $isubj, $ibody, $cryptkey, $caretech
   Local $sArray[1]
   Local $mcryptkey = InputBox("Change Settings - Encryption Key", "Type Master Encryption Key:", "", "xM", 150, 120)
   _FileReadToArray($settingsDir, $sArray)
   Local $fcryptkey = _StringEncrypt(0, $sArray[1], $mcryptkey, 5)
   If $fcryptkey = $mcryptkey Then
   Else
      $attempts += 1
      If $attempts > 3 Then
         MsgBox(64, "WARNING", "Maximum attempts reached. Deleting settings file. Relaunch program and set new Encryption Key")
         FileDelete($settingsDir)
         Exit
      Else
         _Change()
      EndIf
   EndIf
   $fusername = _StringEncrypt(0, $sArray[2], $mcryptkey, 5)
   $fpassword = _StringEncrypt(0, $sArray[3], $mcryptkey, 5)
   $fphone = _StringEncrypt(0, $sArray[4], $mcryptkey, 5)
   $flimit = $sArray[5]
   $fformat = $sArray[6]
   $fifrom = $sArray[7]
   $fisubj = $sArray[8]
   $fibody = $sArray[9]
   $fcaretech = $sArray[10]
 
   Global $mainGUI = GUICreate("User Credentials", 490, 160)
   GUISetOnEvent($GUI_EVENT_CLOSE, "On_Close")
   GUICtrlCreateLabel("GV Username:", 10, 10, 150, 20)
   $username = GUICtrlCreateInput($fusername, 10, 25, 150, 20)
   GUICtrlCreateLabel("GV Password:", 170, 10, 150, 20)
   $password = GUICtrlCreateInput($fpassword, 170, 25, 150, 20, $ES_PASSWORD)
   GUICtrlCreateLabel("Number to send texts to:", 330, 10, 150, 20)
   $phone = GUICtrlCreateInput($fphone, 330, 25, 150, 20)
   $limit = GUICtrlCreateCheckbox("Limit TXT message size", 10, 55, 140, 20)
   If $flimit = 1 Then
      GUICtrlSetState($limit, $GUI_CHECKED)
   Else
      GUICtrlSetState($limit, $GUI_UNCHECKED)
   EndIf
   $format = GUICtrlCreateCheckbox("Remove repeated CR\LF", 160, 55, 140, 20)
   If $fformat = 1 Then
      GUICtrlSetState($format, $GUI_CHECKED)
   Else
      GUICtrlSetState($format, $GUI_UNCHECKED)
   EndIf
   $caretech = GUICtrlCreateCheckbox("Format CareTech ticket e-mails", 330, 55, 150, 20)
   GUICtrlSetOnEvent(-1, "On_CareTech")
   If $fcaretech = 1 Then
      GUICtrlSetState($caretech, $GUI_CHECKED)
   Else
      GUICtrlSetState($caretech, $GUI_UNCHECKED)
   EndIf
   GUICtrlCreateLabel("Master Encryption Key:", 10, 85, 150, 20)
   $cryptkey = GUICtrlCreateInput($fcryptkey, 10, 100, 150, 20, $ES_PASSWORD)
   GUICtrlCreateLabel("Include these fields in text", 170, 85, 300, 20)
   $ifrom = GUICtrlCreateCheckbox("Sender's name", 170, 100, 95, 20)
   If $fifrom = 1 Then
      GUICtrlSetState($ifrom, $GUI_CHECKED)
   Else
      GUICtrlSetState($ifrom, $GUI_UNCHECKED)
   EndIf
   $isubj = GUICtrlCreateCheckbox("Subject content", 275, 100, 95, 20)
   If $fisubj = 1 Then
      GUICtrlSetState($isubj, $GUI_CHECKED)
   Else
      GUICtrlSetState($isubj, $GUI_UNCHECKED)
   EndIf
   $ibody = GUICtrlCreateCheckbox("E-mail's content", 380, 100, 80, 20)
   If $fibody = 1 Then
      GUICtrlSetState($ibody, $GUI_CHECKED)
   Else
      GUICtrlSetState($ibody, $GUI_UNCHECKED)
   EndIf
 
   $save = GUICtrlCreateButton("Save and Close", 10, 130, 470, 20)
   GUICtrlSetOnEvent(-1, "On_Save")
 
   GUISetState()
 
EndFunc
 
Func On_Save()
 
   If GUICtrlRead($cryptkey) = "" Or GUICtrlRead($username) = "" Or GUICtrlRead($password) = "" Or GUICtrlRead($phone) = "" Then
      MsgBox(64, "Warning", "Make sure all fields are filled in correctly")
   Else
      If GUICtrlRead($limit) = $GUI_CHECKED Then
         $limit = 1
      Else
         $limit = 0
      EndIf
      If GUICtrlRead($format) = $GUI_CHECKED Then
         $format = 1
      Else
         $format = 0
      EndIf
      If GUICtrlRead($caretech) = $GUI_CHECKED Then
         $caretech = 1
      Else
         $caretech = 0
      EndIf
      If GUICtrlRead($ifrom) = $GUI_CHECKED Then
         $ifrom = 1
      Else
         $ifrom = 0
      EndIf
      If GUICtrlRead($isubj) = $GUI_CHECKED Then
         $isubj = 1
      Else
         $isubj = 0
      EndIf
      If GUICtrlRead($ibody) = $GUI_CHECKED Then
         $ibody = 1
      Else
         $ibody = 0
      EndIf
 
      $settingsstring = _StringEncrypt(1, GUICtrlRead($cryptkey), GUICtrlRead($cryptkey), 5) & @CRLF & _StringEncrypt(1, GUICtrlRead($username), GUICtrlRead($cryptkey), 5) & @CRLF & _
      _StringEncrypt(1, GUICtrlRead($password), GUICtrlRead($cryptkey), 5) & @CRLF & _StringEncrypt(1, GUICtrlRead($phone), GUICtrlRead($cryptkey), 5) & @CRLF & _
      $limit & @CRLF & $format & @CRLF & $ifrom & @CRLF & $isubj & @CRLF & $ibody & @CRLF & $caretech
      $file = FileOpen($settingsDir, 10)
      FileWrite($file, $settingsstring)
      FileClose($file)
      GUIDelete($mainGUI)
   EndIf
 
EndFunc
 
; Outlook 2007 - NewMailEx event - http://msdn.microsoft.com/en-us/library/bb147646%28v=office.12%29.aspx
Func oOApp_NewMailEx($sOL_EntryId)
 
   ;MsgBox(0, "", "You got mail")
    Local $oOL_Item = $oOApp.Session.GetItemFromID($sOL_EntryId, Default)
   $from = $oOL_Item.SenderName
   $subject = $oOL_Item.Subject
   $body = $oOL_Item.Body
 
   If $format = 1 Then
      $body = StringRegExpReplace($oOL_Item.Body, "((\r\n))+", '"CRLF"')
      $body = StringRegExpReplace($body, '("CRLF"[^\w])+', '')
      $body = StringRegExpReplace($body, '"CRLF"', @CRLF)
   EndIf
 
   If $ifrom = 1 And $isubj = 1 And $ibody = 1 Then
      $message = "From: " & $from & @CRLF & "Subject: " & $subject & @CRLF & $body
   ElseIf $ifrom = 1 And $isubj = 1 And $ibody = 0 Then
      $message = "From: " & $from & @CRLF & "Subject: " & $subject
   ElseIf $ifrom = 1 And $isubj = 0 And $ibody = 1 Then
      $message = "From: " & $from & @CRLF & $body
   ElseIf $ifrom = 1 And $isubj = 0 And $ibody = 0 Then
      $message = "From: " & $from
   ElseIf $ifrom = 0 And $isubj = 1 And $ibody = 1 Then
      $message = "Subject: " & $subject & @CRLF & $body
   ElseIf $ifrom = 0 And $isubj = 1 And $ibody = 0 Then
      $message = "Subject: " & $subject
   ElseIf $ifrom = 0 And $isubj = 0 And $ibody = 1 Then
      $message = $body
   ElseIf $ifrom = 0 And $isubj = 0 And $ibody = 0 Then
      $message = ""
   EndIf
 
   If $limit = 1 Then
      If StringLen($message) > 150 Then
         $message = StringLeft($message, 150)
      EndIf
   EndIf
 
   If $caretech = 1 Then
      If StringInStr($from, "Support Services") Or StringRegExp($subject, "^(Problem|Service)") Then
         $message = FormatTickets($from, $subject, $body)
      EndIf
   EndIf
   ;MsgBox(0, "", $username & " " & $password & " " & $phone & @CRLF & $message)
   _SendGVSMS($username, $password, $phone, $message)
 
EndFunc   ;==>oOApp_NewMailEx
 
Func On_CareTech()
 
   If GUICtrlRead($caretech) = $GUI_CHECKED Then
   MsgBox(64, "Warning", "Checking this box will override the following settings when getting emails from Caretech (other messages won't be affected)" & @CRLF & _
      "Limit TXT message size - You will always get at least two messages" & @CRLF & "Remove repeated CR\LF - This won't apply as body is formatted differently" & @CRLF & _
      "Texts will always include From, Subject, and Body" & @CRLF & "Tere is NOTHING I can do about it so DO NOT ask." & @CRLF & "Try it and if you don't like it turn it off.")
   EndIf
 
EndFunc
 
Func _SendGVSMS($FromGVAccount,$FromGVPassword,$To_SMS_NUM, $To_SMS_TXT )
 
   If $FromGVAccount = "" Or $FromGVPassword = "" Or $To_SMS_NUM = "" Or $To_SMS_TXT = "" Then
      MsgBox(64, "Warning", "Text can't be sent. One of the required fields is missing")
   Else
   ;MsgBox(0, "", "Sending message")
   $GV_SMS_URL = _IECreate("https://www.google.com/voice/b/0/m/sms",0,0,1,1)
   $GV_Form = _IEFormGetObjByName($GV_SMS_URL, "gaia_loginform")
   $o_username = _IEFormElementGetObjByName($GV_Form, "Email")
   _IEFormElementSetValue($o_username, $FromGVAccount)
   $o_password = _IEFormElementGetObjByName($GV_Form, "Passwd")
   _IEFormElementSetValue($o_password, $FromGVPassword)
   _IEFormSubmit($GV_Form,1)
   If @error Then
      ;MsgBox(0, "", "You are inside error")
      ; You will get a Warning from function _IEFormGetObjByName,  $_IEStatus_NoMatch and 5 others when this var is set. this is normal
      $SendSMSform = _IEFormGetCollection ($GV_SMS_URL, 0)
      $oQuery = _IEFormElementGetCollection ($SendSMSform, 2)
      $o_sms_num = _IEFormElementGetObjByName($SendSMSform, "number")
      _IEFormElementSetValue($o_sms_num, $To_SMS_NUM)
      $o_sms_txt = _IEFormElementGetObjByName($SendSMSform, "smstext")
      _IEFormElementSetValue($o_sms_txt, $To_SMS_TXT)
      $GV_SEND_SMS = _IEFormSubmit($SendSMSform,1)
      _IEQuit($GV_SMS_URL)
   Else
      ;MsgBox(0, "", "You are inside else")
      $SendSMSform = _IEFormGetCollection ($GV_SMS_URL, 0)
      $oQuery = _IEFormElementGetCollection ($SendSMSform, 2)
      $o_sms_num = _IEFormElementGetObjByName($SendSMSform, "number")
      _IEFormElementSetValue($o_sms_num, $To_SMS_NUM)
      $o_sms_txt = _IEFormElementGetObjByName($SendSMSform, "smstext")
      _IEFormElementSetValue($o_sms_txt, $To_SMS_TXT)
      $GV_SEND_SMS = _IEFormSubmit($SendSMSform,1)
      _IEQuit($GV_SMS_URL)
   EndIf
   EndIf
 
 EndFunc
 
 Func FormatTickets($from, $subject, $body)
 
   If StringInStr($from, "Support Services") Then
      $from = "From: CareTech"
   EndIf
   $match = StringRegExp($subject, "^(Problem Ticket|Service Request)\s(PT-|SR-)(\d{1,15}),\sPriority\s(Standard|Medium|High),", 1)
   $subject = "Subject: " & $match[1] & Number($match[2]) & " - " & StringUpper($match[3])
   $vip = StringRegExp($body, "(?m)(VIP:)\s(Yes|No)", 1)
   $name = StringRegExp($body, "(?m)(Name:)\s(.*?)\r", 1)
   $ctphone = StringRegExp($body, "(?m)(Phone:)\s(.*?)\r", 1)
   $loc = StringRegExp($body, "(?m)(Location:)\s(.*?)\r", 1)
   $split = StringSplit($loc[1], " - ", 1)
   If StringInStr($split[1], "Kadlec Regional Medical Center") Then
      $split[1] = "KRMC"
   ElseIf StringInStr($split[1], "Kadlec Clinics") Then
      $split[1] = "KC"
   EndIf
   $loc[1] = $split[1] & " - " & $split[2] & " - " & $split[3]
   $cti = StringRegExp($body, "(?m)(CTI:)\s(.*?)\r", 1)
   $summary = StringRegExp($body, "(?m)(Summary:)\s(.*?)\r", 1)
   $body = $cti[0] & " " & $cti[1] & @CRLF & _
            $summary[0] & " " & $summary[1] & @CRLF & _
            $loc[0] & " " & $loc[1] & @CRLF & _
            $name[0] & " " & $name[1] & @CRLF & _
            $vip[0] & " " & $vip[1] & @CRLF & _
            $ctphone[0] & " " & $ctphone[1]
   $message = $from & @CRLF & $subject & @CRLF & $body
 
   Return $message
 
EndFunc
 
Func _Exit()
    Exit
EndFunc   ;==>_Exit
Link to comment
Share on other sites

Looks like it isn't an easy task.

When a new mail arrives an event is triggered and the EntryID of the item is passed to the function. In Outlook the EntryID stays the same as long as you move the item within the same store.

You could wait a second and then use something like

Sleep(1000)
Local $oOL_Item = $oOApp.Session.GetItemFromID($sOL_EntryId, Default)
If $oOL_Item.Parent.Name <> "Your Inbox" Then ...

to check if the mail is still in your inbox.

If this works then you need to test what happens if a new mail arrives during the Sleep statement. Get's the new mail processed too?

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

Looks like it isn't an easy task.

When a new mail arrives an event is triggered and the EntryID of the item is passed to the function. In Outlook the EntryID stays the same as long as you move the item within the same store.

You could wait a second and then use something like

Sleep(1000)
Local $oOL_Item = $oOApp.Session.GetItemFromID($sOL_EntryId, Default)
If $oOL_Item.Parent.Name <> "Your Inbox" Then ...

to check if the mail is still in your inbox.

If this works then you need to test what happens if a new mail arrives during the Sleep statement. Get's the new mail processed too?

 

That sounds better than what I'm doing right now. I'm just calling a function that gets unread messages from my inbox and I try to match the EntryID from each unread message to the one from the messege that triggered the event. I'll give it a try and let you know.

Thanks again

Here is what I'm doing right now:

Func oOApp_NewMailEx($sOL_EntryId)

   ;MsgBox(0, "", "You got mail")
    Local $oOL_Item = $oOApp.Session.GetItemFromID($sOL_EntryId, Default)
   $entryid = $oOL_Item.EntryID
   $inbox = GetInboxUMail($entryid)
   If $inbox = True Then
      $efrom = $oOL_Item.SenderName
      $esubject = $oOL_Item.Subject
      $ebody = $oOL_Item.Body

      If $format = 1 Then
         $ebody = StringRegExpReplace($oOL_Item.Body, "((\r\n))+", '"CRLF"')
         $ebody = StringRegExpReplace($ebody, '("CRLF"[^\w])+', '')
         $ebody = StringRegExpReplace($ebody, '"CRLF"', @CRLF)
      EndIf

      If $from = 1 And $subject = 1 And $body = 1 Then
         $message = "From: " & $efrom & @CRLF & "Subject: " & $esubject & @CRLF & $ebody
      ElseIf $from = 1 And $subject = 1 And $body = 0 Then
         $message = "From: " & $efrom & @CRLF & "Subject: " & $esubject
      ElseIf $from = 1 And $subject = 0 And $body = 1 Then
         $message = "From: " & $efrom & @CRLF & $ebody
      ElseIf $from = 1 And $subject = 0 And $body = 0 Then
         $message = "From: " & $efrom
      ElseIf $from = 0 And $subject = 1 And $body = 1 Then
         $message = "Subject: " & $esubject & @CRLF & $ebody
      ElseIf $from = 0 And $subject = 1 And $body = 0 Then
         $message = "Subject: " & $esubject
      ElseIf $from = 0 And $subject = 0 And $body = 1 Then
         $message = $ebody
      ElseIf $from = 0 And $subject = 0 And $body = 0 Then
         $message = ""
      EndIf

      If $limit = 1 Then
         If StringLen($message) > 150 Then
            $message = StringLeft($message, 150)
         EndIf
      EndIf

      If $caretech = 1 Then
         If StringInStr($efrom, "Support Services") Or StringRegExp($esubject, "^(Problem|Service)") Then
            $message = FormatTickets($efrom, $esubject, $ebody)
         EndIf
      EndIf
      ;MsgBox(0, "", $username & " " & $password & " " & $phone & @CRLF & $message)
      _SendGVSMS($username, $password, $phone, $message)
   EndIf

EndFunc   ;==>oOApp_NewMailEx

Func GetInboxUMail($id)

   Local $oOutlook = _OL_Open()
   $Folder = _OL_FolderAccess($oOutlook, "", $olFolderInbox)
   $uEmail = _OL_ItemFind($oOutlook, $Folder[1], $olMail, "[UnRead]=True", "", "", "EntryID")
   Local $found = False
   For $i = 1 To $uEmail[0][0]
      ;MsgBox(0, "", $id & " --- " & $uEmail[$i][0])
      If $uEmail[$i][0] = $id Then
         $found = True
         ExitLoop
      EndIf
   Next
   Return $found

EndFunc
Link to comment
Share on other sites

Looks like it isn't an easy task.

When a new mail arrives an event is triggered and the EntryID of the item is passed to the function. In Outlook the EntryID stays the same as long as you move the item within the same store.

You could wait a second and then use something like

Sleep(1000)
Local $oOL_Item = $oOApp.Session.GetItemFromID($sOL_EntryId, Default)
If $oOL_Item.Parent.Name <> "Your Inbox" Then ...

to check if the mail is still in your inbox.

If this works then you need to test what happens if a new mail arrives during the Sleep statement. Get's the new mail processed too?

 

is there a way to find a mail item by EntryID?

Link to comment
Share on other sites

Another question: Is it sensible to send an email for every email you get? You could easily end up in a loop.

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

Water,

How would I use OutlookEX to approach this?

I have a .msg outside of outlook.  I want to able to select it or drop it in au3 and able to grab the body content only or better yet the body source code of the .msg

Would you able to assist and point me to the right directly on the outlook part?

Thanks.

Link to comment
Share on other sites

Quick reply. Use _OL_ItemCreate and use the .msg file as template.

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

#include <outlookEX.au3>
Global $OL = _OL_Open()
Global $oMsg = $OL.CreateItemFromTemplate("C:\help .msg")
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $oMsg.HTMLBody = ' & $oMsg.HTMLBody & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
_OL_Close($OL)

If I follow you this is correct but it's had a nagging screen.  Is there a simple way to stop it to nag outlook that outlookEX is trying to access .msg?

Link to comment
Share on other sites

Yes, start _OL_Warnings with _OL_Open

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

#include <outlookEX.au3>
$oOutlook = _OL_Open(True) ;Warning to True?
$filemsg ="C:\help.msg" ;Test MSG
$oItem = _OL_ItemCreate($oOutlook, $olMailItem, "*", $filemsg)
;$oMsg = $oOutlook.CreateItemFromTemplate($filemsg)
ConsoleWrite('HTMLBody = ' & $oItem.HTMLBody & @crlf) ;### Debug Console
_OL_Close($oOutlook)

If I set it to true, it giving me error.

C:\Downloads\outlookEX.au3 (1171) : ==> Error in expression.:
Local $oNamespace = $oOL.GetNamespace("MAPI")
Local $oNamespace = ^ ERROR
Link to comment
Share on other sites

Check the parameters for _ol_open in the help file. You need to pass the name of a compiled autoit script to click away the warmings

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

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...