Jump to content

OutlookEX UDF - Help & Support (IV)


water
 Share

Recommended Posts

Done! Set $iFlags to 8 to ignore such errors:

; #FUNCTION# ====================================================================================================================
; Name ..........: _OL_ItemFind
; Description ...: Finds items (contacts, appointments ...) returning an array of all specified properties.
; Syntax.........: _OL_ItemFind($oOL, $vFolder[, $iObjectClass = Default[, $sRestrict = ""[, $sSearchName = ""[, $sSearchValue = ""[, $sReturnProperties = ""[, $sSort = ""[, $iFlags = 0[, $sWarningClick = ""]]]]]]]])
; Parameters ....: $oOL               - Outlook object returned by a preceding call to _OL_Open()
;                  $vFolder           - Folder object as returned by _OL_FolderAccess or full name of folder where the search will be started.
;                  +If you want to search a default folder you have to specify the folder object.
;                  $iObjectClass      - [optional] Class of items to search for. Defined by the Outlook OlObjectClass enumeration (default = Default = $olContact)
;                  $sRestrict         - [optional] Filter text to restrict number of items returned (exact match). For details please see Remarks
;                  $sSearchName       - [optional] Name of the property to search for (without brackets)
;                  $sSearchValue      - [optional] String value of the property to search for (partial match)
;                  $sReturnProperties - [optional] Comma separated list of properties to return (default = depending on $iObjectClass. Please see Remarks)
;                  $sSort             - [optional] Property to sort the result on plus optional flag to sort descending (default = None). E.g. "[Subject], True" sorts the result descending on the subject
;                  $iFlags            - [optional] Flags to set different processing options. Can be a combination of the following:
;                  |  1: Subfolders will be included
;                  |  2: Row 1 contains column headings. Therefore the number of rows/columns in the table has to be calculated using UBound
;                  |  4: Just return the number of records. You don't get an array, just a single integer denoting the total number of records found
;                  |  8: Ignore errors when accessing non-existing properties. Return "N/A" (not available) instead. This avoids @error = 4 - Error accessing specified property.
;                  $sWarningClick     - [optional] The entire path (drive, directory, file name and extension) to 'OutlookWarning2.exe' or another exe with the same function (default = None)
; Return values .: Success - One based two-dimensional array with the properties specified by $sReturnProperties
;                  Failure - Returns "" and sets @error:
;                  |1 - You have to specifiy $sSearchName AND $sSearchValue or none of them
;                  |2 - $sWarningClick not found
;                  |3 - Error accessing the specified folder. See @extended for errorcode returned by _OL_FolderAccess
;                  |4 - Error accessing specified property. @extended is set to the COM error
;                  |5 - Error filtering items. @extended is set to the COM error
;                  |6 - You didn't provide properties to be returned and _OL_ItemFind doesn't provide any default properties for this item type
;                  |1nmm - Error checking the $sReturnProperties as returned by __OL_CheckProperties.
;                  +      n is either 0 (property does not exist) or 1 (Property has invalid case)
;                  +      mm is the index of the property in error (one based)
; Author ........: water
; Modified ......:
; Remarks .......: Be sure to specify the values in $sReturnProperties and $sSearchName in correct case e.g. "FirstName" is valid, "Firstname" is invalid
;+
;                  If you do not specify any properties then the following properties will be returned depending on the objectclass:
;                  Contact: FirstName, LastName, Email1Address, Email2Address, MobileTelephoneNumber
;                  DistributionList: Subject, Body, MemberCount
;                  Note, Mail: Subject, Body, CreationTime, LastModificationTime, Size
;                  Appointment: EntryID, Start, End, Subject, IsRecurring
;+
;                  Pseudo properties:
;                  You can specify the following pseudo properties which can't be derived directly from the item.
;                  @ItemObject   - Object of the item that matches the search criteria
;                  @FolderObject - Object of the folder where the item resides. Helpful when you search subfolders.
;+
;                  $sRestrict: Filter can be a Jet query or a DASL query with the @SQL= prefix. Jet query language syntax:
;                  Restrict filter:  Filter LogicalOperator Filter ...
;                  LogicalOperator:  And, Or, Not. Use ( and ) to change the processing order
;                  Filter:           "[property] operator 'value'" or '[property] operator "value"'
;                  Operator:         <, >, <=, >=, <>, =
;                  Example:          "[Start]='2011-02-21 08:00' And [End]='2011-02-21 10:00' And [Subject]='Test'"
;                  See: http://msdn.microsoft.com/en-us/library/cc513841.aspx              - "Searching Outlook Data"
;                       http://msdn.microsoft.com/en-us/library/bb220369(v=office.12).aspx - "Items.Restrict Method"
;+
;                  N.B.: Pass time as HH:MM, HH:MM:SS is invalid and returns no result
; Related .......:
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _OL_ItemFind($oOL, $vFolder, $iObjectClass = Default, $sRestrict = "", $sSearchName = "", $sSearchValue = "", $sReturnProperties = "", $sSort = "", $iFlags = 0, $sWarningClick = "")
    If $sRestrict = Default Then $sRestrict = ""
    If $sSearchName = Default Then $sSearchName = ""
    If $sSearchValue = Default Then $sSearchValue = ""
    If $sReturnProperties = Default Then $sReturnProperties = ""
    If $sSort = Default Then $sSort = ""
    If $iFlags = Default Then $iFlags = 0
    If $sWarningClick = Default Then $sWarningClick = ""
    Local $bChecked = False, $oItems, $aTemp, $iCounter = 0, $oItem
    If $sWarningClick <> "" Then
        If FileExists($sWarningClick) = 0 Then Return SetError(2, 0, "")
        Run($sWarningClick)
    EndIf
    If $iObjectClass = Default Then $iObjectClass = $olContact ; Set Default ObjectClass
    ; Set default return properties depending on the class of items
    If StringStripWS($sReturnProperties, BitOR($STR_STRIPLEADING, $STR_STRIPTRAILING)) = "" Then
        Switch $iObjectClass
            Case $olContact
                $sReturnProperties = "FirstName,LastName,Email1Address,Email2Address,MobileTelephoneNumber"
            Case $olDistributionList
                $sReturnProperties = "Subject,Body,MemberCount"
            Case $olNote, $olMail
                $sReturnProperties = "Subject,Body,CreationTime,LastModificationTime,Size"
            Case $olAppointment
                $sReturnProperties = "EntryID,Start,End,Subject,IsRecurring" ; Same as returned by _OL_AppointmentGet
            Case Else
                Return SetError(6, 0, "")
        EndSwitch
    EndIf
    If Not IsObj($vFolder) Then
        $aTemp = _OL_FolderAccess($oOL, $vFolder)
        If @error Then Return SetError(3, @error, "")
        $vFolder = $aTemp[1]
    EndIf
    If ($sSearchName <> "" And $sSearchValue = "") Or ($sSearchName = "" And $sSearchValue <> "") Then Return SetError(1, 0, "")
    Local $aReturnProperties = StringSplit(StringStripWS($sReturnProperties, $STR_STRIPALL), ",")
    Local $iIndex = $aReturnProperties[0]
    If $aReturnProperties[0] < 2 Then $iIndex = 2
    If StringStripWS($sRestrict, BitOR($STR_STRIPLEADING, $STR_STRIPTRAILING)) = "" Then
        $oItems = $vFolder.Items
        If @error Then Return SetError(5, @error, "")
    Else
        $oItems = $vFolder.Items.Restrict($sRestrict)
        If @error Then Return SetError(5, @error, "")
    EndIf
    Local $iItems = $oItems.Count
    Local $aItems[$iItems + 1][$iIndex] = [[0, $aReturnProperties[0]]]
    If BitAND($iFlags, 4) <> 4 And $sSort <> "" Then
        $aTemp = StringSplit($sSort, ",")
        If $aTemp[0] = 1 Then
            $oItems.Sort($sSort)
        Else
            $oItems.Sort($aTemp[1], True)
        EndIf
    EndIf
    For $i = 1 To $iItems
        $oItem = $oItems.Item($i)
        If $oItem.Class <> $iObjectClass Then ContinueLoop
        ; Get all properties of first item and check for existance and correct case
        If BitAND($iFlags, 4) <> 4 And Not $bChecked Then
            If Not __OL_CheckProperties($oItem, $aReturnProperties, 1) Then Return SetError(@error, @extended, "")
            $bChecked = True
        EndIf
        If $sSearchName <> "" And StringInStr($oItem.ItemProperties.Item($sSearchName).value, $sSearchValue) = 0 Then ContinueLoop
        ; Fill array with the specified properties
        $iCounter += 1
        If BitAND($iFlags, 4) <> 4 Then
            For $iIndex = 1 To $aReturnProperties[0]
                If StringLeft($aReturnProperties[$iIndex], 1) <> "@" Then
                    $aItems[$iCounter][$iIndex - 1] = $oItem.ItemProperties.Item($aReturnProperties[$iIndex]).value
                    If @error Then
                        If BitAND($iFlags, 8) = 8 Then
                            $aItems[$iCounter][$iIndex - 1] = "N/A"
                        Else
                            Return SetError(4, @error, "")
                        EndIf
                    EndIf
                Else
                    If $aReturnProperties[$iIndex] = "@ItemObject" Then $aItems[$iCounter][$iIndex - 1] = $oItem
                    If $aReturnProperties[$iIndex] = "@FolderObject" Then $aItems[$iCounter][$iIndex - 1] = $vFolder
                EndIf
                If BitAND($iFlags, 2) = 2 And $iCounter = 1 Then
                    If StringLeft($aReturnProperties[$iIndex], 1) <> "@" Then
                        $aItems[0][$iIndex - 1] = $oItem.ItemProperties.Item($aReturnProperties[$iIndex]).Name
                    Else
                        $aItems[0][$iIndex - 1] = $aReturnProperties[$iIndex]
                    EndIf
                EndIf
            Next
        EndIf
        If BitAND($iFlags, 4) <> 4 And BitAND($iFlags, 2) <> 2 Then $aItems[0][0] = $iCounter
    Next
    If BitAND($iFlags, 4) = 4 Then
        ; Process subfolders
        If BitAND($iFlags, 1) = 1 Then
            For $vFolder In $vFolder.Folders
                $iCounter += _OL_ItemFind($oOL, $vFolder, $iObjectClass, $sRestrict, $sSearchName, $sSearchValue, $sReturnProperties, $sSort, $iFlags, $sWarningClick)
            Next
        EndIf
        Return $iCounter
    Else
        ReDim $aItems[$iCounter + 1][$aReturnProperties[0]] ; Process subfolders
        If BitAND($iFlags, 1) = 1 Then
            For $vFolder In $vFolder.Folders
                $aTemp = _OL_ItemFind($oOL, $vFolder, $iObjectClass, $sRestrict, $sSearchName, $sSearchValue, $sReturnProperties, $sSort, $iFlags, $sWarningClick)
                __OL_ArrayConcatenate($aItems, $aTemp, $iFlags)
            Next
        EndIf
        Return $aItems
    EndIf
EndFunc   ;==>_OL_ItemFind

 

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

On 3/15/2021 at 6:54 PM, water said:

$oOutlook.GetNameSpace("MAPI" ).CurrentUser

@water If my code returns blank, does that mean no default user is defined?

;code

; populate each selector
Local $OL_Default_CurrentUser = $oOutlook.GetNameSpace("MAPI" ).CurrentUser
ConsoleWrite("$OL_Default_CurrentUser " & $OL_Default_CurrentUser & @CRLF)


;;; console output

$OL_Default_CurrentUser

 

Skysnake

Why is the snake in the sky?

Link to comment
Share on other sites

What you get is a recipient object (according to the MS docu I linked to in my last post).
Use

$oOutlook.GetNameSpace("MAPI" ).CurrentUser.Name

to get the display name.

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 please see example for 15 March? I updated the code and output.

I need to state that I do not use Exchange, in case there are certain assumptions based on this.

What I need to do now, is to be able to match a given name/email address to what Outlook returns, and send using same.

So

; mockup

Local $useThisEmail = 'skysnake@example.com'
Local $aAccountInProfile = _OL_AccountGet($oOutlook) ; returns an array with email in cols 1 and 2

If $useThisEmail = aAccountInProfile[1][1] Then 
    
    _OL_Wrapper_SendMail($oOutlook, $useThisEmail, "", "", "TestSubject", "Body<br><b>fett</b> normal.", @ScriptDir & "\_OL_Wrapper_SendMail.au3",
    $olFormatHTML, $olImportanceHigh)
    
EndIf

Except that I have never managed to get this to work. Ideas please?

Edited by Skysnake

Skysnake

Why is the snake in the sky?

Link to comment
Share on other sites

If something doesn't work as expected I suggest to check @error and @extended after calling a function of the OutlookEX UDF.

Do you really try to send a mail to one of your own accounts?

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

No. That's not the purpose. The point is to allow the user to specify an email account to use and then actually send, using the selection. The problem is that the select of the sender account is what I cannot figure out.

The destinations (To CC BCC) are easy to select.

But, YES, the answer to your question is also yes. If I want to send a diagnostic self-test eg from me to me, to make sure it works. Why exactly would that be such an unusual idea? :)

Thanks

 

Skysnake

Why is the snake in the sky?

Link to comment
Share on other sites

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

I am aware of that example. Does it work for you? I have also never managed to get that one to work. From there the current activity.  I will try that again. Thanks for your time. I'll be back in a few days :)

 

Skysnake

Why is the snake in the sky?

Link to comment
Share on other sites

The example works for me. I've just sent a mail to myself.
The SMTP address you check in the loop has to be the primary SMTP address not an alias!

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

13 hours ago, water said:

The SMTP address you check in the loop has to be the primary SMTP address not an alias!

Perphaps this is an interpretation issue. On my profile I have nine email accounts. When you write primary SMTP address what exactly are you referring to? The default account set in the profile? Or the email address specified in the array returned?

This is the array returned by my query:

; $aAccountInProfile = _OL_AccountGet($oOutlook) returns this

Row  |Col 0|Col 1               |Col 2               |Col 3        |Col 4|Col 5|Col 6|Col 7|Col 8
Row 0|10   |9                   |                    |             |     |     |     |     |
Row 1|2    |skysnake@example.com|skysnake@example.com|The Sky Snake|     |0    |0    |     |

; challenge is to match this and extract email -------------^^^^^^

; script returns

$OL_Default_CurrentUser = $oOutlook.GetNameSpace("MAPI" ).CurrentUser.Name ; returns The Sky Snake

Obviously the CurrentUser.Name ; returns The Sky Snake in Col 3 is not an SMTP address. 

So the addresses returned in Col 1 and Col 2, are those (a) primary SMTP or (b) alias, and if so, which one?

I am really struggling with this. My single biggest problem is that this does not work for me as expected, which leads me to think I am making a mistake somewhere.

Thank you for your time

Edited by Skysnake

Skysnake

Why is the snake in the sky?

Link to comment
Share on other sites

1 hour ago, Skysnake said:

Perphaps this is an interpretation issue. On my profile I have nine email accounts. When you write primary SMTP address what exactly are you referring to?

I only have one account. But this account has multiple mail addresses (due to different reasons). The primary SMTP address is used when sending a mail from this account. But when I receive a mail this can be sent to any of the multiple addresses.

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

Back to your problem:

  • _OL_Wrapper_SendMail does not allow to specify the senders account/mail address. You have to use the code as described in the wiki.
  • 1 hour ago, Skysnake said:

    My single biggest problem is that this does not work for me as expected

    Hard to debug :) We need an error code or more information why the example code from the wiki would ignore the account you want to use. The wiki example code comes without error checking (for readability reasons). So please add some debugging code and post the results.

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 Thank you. I just had a thought, that may also help explain my issue. What I am attempting to achieve is that the user can set a specific email address in an app. A small AutoIt app what remembers  that email. Lets call this user selected Email@Two

Now, on my computer I have two user accounts. PersonA and PersonB. PersonB is not important now. 

Account PersonA has an Outlook profile with 2 email accounts listed.  The top item is described by Outlook as the default (send email from this account by default). Call this default Email@One

But, and here is the issue, user does not at this time, want to use the default account, but the other account specified in the AutoIt app.

So, the sender must be changed from default to selected. 

The usual OutlookEX settings are to send using default Email@One. Which is what Outlook does very well. 

How to send email using selected Email@Two?

I think, my single biggest issue here is how to select Email@Two from available accounts. I'll post some more code.

Skysnake

Why is the snake in the sky?

Link to comment
Share on other sites

Do you want to select Email@Two to send a single mail using an AutoIt script?
Or do you want to change the default account (until the user switches the account again) and let the user manually send mails?

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

  • 3 weeks later...

Based on your explanations I suggest to try the example from the wiki again. I have added some error checking so we might see why it doesn't work.
Please change the lines marked with "   ; <=="

#include <OutlookEX.au3>
Global $oOutlook = _OL_Open()
_OL_ErrorNotify(2)
; Create the mail item
Global $oItem = _OL_ItemCreate($oOutlook, $olMailItem, "", "", "Subject=TestMail", "Body=TestBody")
; Add Jon Doe as recipient
$oItem = _OL_ItemRecipientAdd($oOutlook, $oItem, Default, $olTo, "John.Doe@gmx.com")   ; <==
; Search for the account with SMTP mail address "mail.address@company.com"             ; <==
For $oAccount In $oOutlook.Session.Accounts
    ConsoleWrite("Checked account: " & $oAccount.DisplayName & ", with SMTPAddress: " & $oAccount.SMTPAddress & @CRLF)
    If $oAccount.SMTPAddress = "mail.address@company.com" Then                         ; <==
        $oItem.SendUsingAccount = $oAccount
        ExitLoop
    EndIf
Next
; Send the mail from this account
_OL_ItemSend($oOutlook, $oItem)
_OL_Close($oOutlook)

 

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

Both OutlookEX.ZIP and OutlookEX_GUI.ZIP contain OutlookEX_Base.au3 right now.
I think I will remove OutlookEX_Base.au3 from OutlookEX_GUI.ZIP and update the "installation" documentation for OutlookEX_GUI.

26 minutes ago, Skysnake said:

And the content (_base etc) is not in sync

Is there more than just OutlookEX_Base.au3 that#s out of sync?

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

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
 Share

×
×
  • Create New...