Jump to content

OutlookEX UDF - Help & Support (IV)


Recommended Posts

You are looking for news mails in a loop. Better check the examples for events that come with the UDF (_OL_Example_NewMailEX). This script waits until a new mail arrives without using any CPU cycles. When a new mail arrives a specified function gets called to process this mail(s).

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to post
Share on other sites
  • Replies 516
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

Fixed in version 1.3.3.1 of the UDF I uploaded today

Version 1.7.0.0 of the UDF has been released. Now you get a help file that looks like the AutoIt help. Please test before using in production! For download please see my signature.

I know I'm not Bill Murray, so I'm not a god  

Posted Images

Another way to get the latest mail item is described here:

 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to post
Share on other sites

Hi,

I got a friend to help me with the code,
So now it should be more manageable. ( I could do better. :)

We have made it so that it now sorts and selects the oldest mails first.
And that we print files by name. with the lowest number / date first.

I will post a new version once I have tested it.
But here is my code at the moment.
Suggestions are welcome. 

Print Outlook attachments1.7.au3

Link to post
Share on other sites

I would change

If FileExists("C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe") Then
        If $DebugOn = 1 Then ConsoleWrite("Adobe 32Bit print: " & $vFileName & " ")
        If $DebugOn = 1 Then _WriteErrorLog("Adobe 32Bit print: " & $vFileName)
        If $DebugOn = 1 Then _WriteErrorLog('"C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe" /h /p "' & $sSaveDir & $vFileName)
        If $DebugOn = 1 Then ConsoleWrite('"C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe" /h /p "' & $sSaveDir & $vFileName & '" ')
        Local $iPID = Run('"C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe" /h /p "' & $sSaveDir & $vFileName & '" ',"",@SW_MINIMIZE)
        sleep(6500)
        ProcessClose($iPID)

to

If FileExists("C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe") Then
        If $DebugOn = 1 Then 
            ConsoleWrite("Adobe 32Bit print: " & $vFileName & " ")
            _WriteErrorLog("Adobe 32Bit print: " & $vFileName)
            _WriteErrorLog('"C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe" /h /p "' & $sSaveDir & $vFileName)
            ConsoleWrite('"C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe" /h /p "' & $sSaveDir & $vFileName & '" ')
        EndIf
        Local $iPID = Run('"C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe" /h /p "' & $sSaveDir & $vFileName & '" ',"",@SW_MINIMIZE)
        sleep(6500)
        ProcessClose($iPID)

And all other occurrences in your script.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to post
Share on other sites
  • 2 weeks later...

Dear water and Forum moderators,

My company has switched from using Outlook to the messaging system called HubSpot, and I was able to handle the transactions easily using the attached scenario before.

Could you please help me to produce a scenario for use in HubSpot? 

 

#include <OutlookEX.au3>


Func _WinWaitActivate($title,$text,$timeout=0)
   WinWait($title,$text,$timeout)
   If Not WinActive($title,$text) Then WinActivate($title,$text)
   WinWaitActive($title,$text,$timeout)
EndFunc

Opt('TrayIconDebug', 1)
   Opt("WinTitleMatchMode", 2)
   _WinWaitActivate("Satis Teklifi ","")
   Local $sText = WinGetTitle("[ACTIVE]")
   $sText=StringMid($sText,17,9)
;Sorgulama ekranı getiriliyor.



   sleep(3000)

MouseClick($MOUSE_CLICK_LEFT,1122 , 247, 1)

sleep(3000)

MouseClick($MOUSE_CLICK_RIGHT,1122 , 247, 1)

sleep(1000)
 send("{TAB 5}")

 sleep(1000)


Send("{ENTER}")
sleep(1000)

 _WinWaitActivate("Hızlı Rapor Sorgusu: 015 - SSH Teklif - IFS Applications","")
  sleep(2000)


send("{TAB 5}")
  Send("{ENTER}")

;teklif pdf ı görselı

sleep(1000)

  _WinWaitActivate("015 - SSH Teklif ","")

sleep(1000)


;burdamı hata bak
 MouseClick($MOUSE_CLICK_LEFT,67 , 98, 1)

sleep(2000)
  send("{TAB}")
 sleep(1000)
 Send("{ENTER}")
 sleep(1000)
 _WinWaitActivate("Raporu Dışa Aktar","")
 sleep(2000)
Send("{TAB 5}")
   Send("{ENTER}")
  Send("C:\Users\mdogru\Desktop\IFS ÇIKTILARI")
  sleep(500)
  MouseClick($MOUSE_CLICK_LEFT,311 , 75, 1)
sleep(500)
 Send("{ENTER}")
sleep(500)
 MouseClick($MOUSE_CLICK_LEFT,446 , 418, 1)
  sleep(500)

   MouseClick($MOUSE_CLICK_LEFT,459 , 451, 1)
  sleep(500)
;türü sec pdf
 MouseClick($MOUSE_CLICK_LEFT,358 , 396, 1)
  sleep(500)


 Send("DURMAZLAR_TEKLİF")
 sleep(500)
Send("{ENTER}")

 _WinWaitActivate("Farklı Kaydetmeyi Onayla","")
 send("{TAB}")
 sleep(1000)
 Send("{ENTER}")


 _WinWaitActivate("Raporu Dışa Aktar","")

Send("{ENTER}")
sleep(1000)


MouseClick($MOUSE_CLICK_LEFT,25 , 44, 1)
sleep(50)
 _WinWaitActivate("Satis Teklifi -","")



MouseClick($MOUSE_CLICK_LEFT,181 , 120, 2)
sleep(2000)
   ;1 veri kopyalanıyor ,1. copy to the subject okkkkk...
   Send("^C")
   sleep(1000)




;Now please help to copy the data to the email subject section,şimdi email konu kısmına veri kopyalama işlemi için lütfen yardım ,


Global $oOutlook, $oInspector, $oItem
; Open connection to Outlook
$oOutlook = _OL_Open()
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error creating a connection to Outlook. @error = " & @error & ", @extended = " & @extended)

; Access the currently displayed mail item
$oInspector = $oOutlook.ActiveInspector
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error accessing ActiveInspector. @error = " & @error & ", @extended = " & @extended)
$oItem = $oInspector.CurrentItem
$sSubject = ClipGet()
_OL_ItemModify($oOutlook, $oItem, Default, "Subject=" & $sSubject)


If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error accessing current item. @error = " & @error & ", @extended = " & @extended)
If $oItem.Class <> $olMail Then Exit MsgBox(16, "OutlookEX UDF", "Current item isn't a mail item. @error = " & @error & ", @extended = " & @extended)

; Add a PDF file
$sAttachment  ="C:\Users\mdogru\Desktop\IFS ÇIKTILARI\"&"DURMAZLAR_TEKLİF.pdf"
_OL_ItemAttachmentAdd($oOutlook, $oItem, Default, $sAttachment)

; Change <Test.pdf> to the name of your PDF file - or change the whole path if the fil is stored in a different directory.





If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error adding attachment to mail item. @error = " & @error & ", @extended = " & @extended)



; Display item
$oItem.Display

 

TEKLİF 25 03 2021.au3

Edited by mustilem23
flod
Link to post
Share on other sites

@water,

I think I found a tiny bug? Or I just missed something but looking at the UDF:

Func _OL_ItemAttachmentAdd($oOL, $vItem, $sStoreID, $vP1, $vP2 = "", $vP3 = "", $vP4 = "", $vP5 = "", $vP6 = "", $vP7 = "", $vP8 = "", $vP9 = "", $vP10 = "", $sDelimiter = ",")
    If $sDelimiter = Default Then $sDelimiter = ","

But the description mentions that default delimited is ;

; #FUNCTION# ====================================================================================================================
; Name...........: _OL_Wrapper_SendMail
; Description ...: Creates and sends a mail (wrapper function).
; Syntax.........: _OL_Wrapper_SendMail($oOL[, $sTo = ""[, $sCc= ""[, $sBCc = ""[, $sSubject = ""[, $sBody = ""[, $sAttachments = ""[, $iBodyFormat = $olFormatUnspecified[, $iImportance = $olImportanceNormal]]]]]]]])
; Parameters ....: $oOL          - Outlook object returned by a preceding call to _OL_Open()
;                  $sTo          - [optional] The display name of the recipient(s), separated by ;
;                  $sCc          - [optional] The display name of the CC recipient(s) of the mail, separated by ;
;                  $sBCc         - [optional] The display name of the BCC recipient(s) of the mail, separated by ;
;                  $sSubject     - [optional] The Subject of the mail
;                  $sBody        - [optional] The Body of the mail
;                  $sAttachments - [optional] Attachments, separated by ;

Just a heads up. The reason why I posted this is because I kept getting a @error=5004 and I think it's because the file has a comma in it.

 

Nope, even after changing the , to a ; I still get an 5004 error. Weird, maybe it's not a bug.

Edited by BatMan22
Link to post
Share on other sites

; is correct for all parameters of _OL_Wrapper_SendMail. When calling _OL_ItemAttachmentAdd parameter $sDelimiter is set to Default (= ,).
This delimiter is only used to split a string with multiple recipients. As _OL_Wrapper_SendMail passes an array of recipients $sDelimiter isn't used in _OL_ItemAttachmentAdd .

It is a kind of bug as such delimiters should be consistent for all functions. 
If needed I could modify the UDF to accept , ; or both as separators.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to post
Share on other sites

5004 means: Attachment not found.
How do you specify the attachment to add?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to post
Share on other sites

Hi @water,

Turns out I'm an idiot, the pdf I am attempting to email is being written to in the step immediately before sending this email. File is just busy apparently and a pause has fixed my issue. Will leave this here for anyone else that runs into this to know that Error 5004 can also mean file busy / file not found.

Link to post
Share on other sites

:)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to post
Share on other sites

@water

Actually I definitely think is a bug. I stand by my comment about being an idiot but when adding an attachment with a "," in the name, it does get split up. I added an array to show $aTemp with and without hard coding the delimiter: 

 

 

Func _OL_ItemAttachmentAdd($oOL, $vItem, $sStoreID, $vP1, $vP2 = "", $vP3 = "", $vP4 = "", $vP5 = "", $vP6 = "", $vP7 = "", $vP8 = "", $vP9 = "", $vP10 = "", $sDelimiter = ",")
;~  If $sDelimiter = Default Then $sDelimiter = ","
    $sDelimiter = ";" ;Works
;~  $sDelimiter = "," ;Doesn't work
    Local $aAttachments[10]
    If Not IsObj($vItem) Then
        If StringStripWS($vItem, BitOR($STR_STRIPLEADING, $STR_STRIPTRAILING)) = "" Then Return SetError(1, 0, 0)
        $vItem = $oOL.Session.GetItemFromID($vItem, $sStoreID)
        If @error Then Return SetError(2, @error, 0)
    EndIf
    ; Move attachments into an array
    If Not IsArray($vP1) Then
        $aAttachments[0] = $vP1
        $aAttachments[1] = $vP2
        $aAttachments[2] = $vP3
        $aAttachments[3] = $vP4
        $aAttachments[4] = $vP5
        $aAttachments[5] = $vP6
        $aAttachments[6] = $vP7
        $aAttachments[7] = $vP8
        $aAttachments[8] = $vP9
        $aAttachments[9] = $vP10
    Else
        $aAttachments = $vP1
    EndIf
    ; Add attachments to the item
    For $iIndex = 0 To UBound($aAttachments) - 1
        If $aAttachments[$iIndex] = "" Or $aAttachments[$iIndex] = Default Then ContinueLoop
        Local $aTemp = StringSplit($aAttachments[$iIndex], $sDelimiter)
        _ArrayDisplay($aTemp)
        ReDim $aTemp[5] ; Make sure the array has 4 elements (element 2-4 might be empty)

 

image.png

Link to post
Share on other sites

A quick and dirty fix could be to modify _OL_Wrapper_SendMail:

_OL_ItemAttachmentAdd($oOL, $oItem, Default, $aAttachments)

with

_OL_ItemAttachmentAdd($oOL, $oItem, Default, $aAttachments, Default, Default, Default, Default, Default, Default, Default, Default, Default, ";")

 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to post
Share on other sites
  • 1 month later...

Yes. #RequireAdmin starts a new process as Admin with elevated permissions. Outlook needs to be started by the user who runs the script. 
please have a look at the wiki. 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to post
Share on other sites
  • 3 weeks later...

Version 1.7.0.0 of the UDF has been released.

Now you get a help file that looks like the AutoIt help.

Please test before using in production!

For download please see my signature.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to post
Share on other sites
  • 1 month later...

When using the below code snippet , I only expect to get appointments for 2/18.

 

I have recurring appointments and it seems to include those in the results  , so for an example I have a recurring one that was built on 5/6/2021 and it is included when i run the below find , but is not scheduled for 2/18/2022.

 

Global $aAppointments = _OL_ItemFind($oOutlook, "*\Calendar", $olAppointment, "[Start]>='2022-02-18 00:00' And [End]<='2022-02-18 23:59'", "", "", "EntryID,Subject,Body,ConversationTopic,Start", "", 2)

What am I missing

Link to post
Share on other sites

Does the recurrence define an appointment for 2022-02-18 which later has been deleted or moved?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Cyborg5000
      Can some one please point me why i keep getting the error while the script is in loop:-
      "C:\Program Files (x86)\AutoIt3\Include\OutlookEX.au3" (2443) : ==> Subscript used on non-accessible variable.:
      If Not (IsNumber($iAttachment)) Or $iAttachment < 1 Or $iAttachment > $aAttachments[0][0] Then Return SetError(8, $aAttachments[0][0], 0)
      If Not (IsNumber($iAttachment)) Or $iAttachment < 1 Or $iAttachment > $aAttachments^ ERROR
      My code as below though copied and modified as per need, to get attachments, and other details.
      #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <File.au3> #include <IE.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GuiStatusBar.au3> #include <StringConstants.au3> #include <FileConstants.au3> #include <Array.au3> #include <String.au3> #include <UIAWrappers.au3> #include <GuiEdit.au3> #include <Clipboard.au3> #include <WinAPI.au3> #include <ColorConstants.au3> #include <FontConstants.au3> #include <ProgressConstants.au3> #include <Restart.au3> #include <_IEquerySelectorAll.au3> #include <GuiRichEdit.au3> #include <hiddenDesktopInteract.au3> #include <Date.au3> #include <CUIAutomation2.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <OutlookEX.au3> #include <Misc.au3> #include <MsgBoxConstants.au3> ;Global $oErrorHandler = ObjEvent("Autoit.Error", "ComErrorHandler") FileDelete("D:\attachment\*.*") FileDelete("D:\Email-Details\*.*") FileDelete("D:\Script-temp\*.*") FileDelete("D:\Downloaded-Cert\*.*") FileDelete("D:\LOG\*.*") RunWait("taskkill /F /IM iexplore.exe /T", "", @SW_HIDE) ;Global $Errorcomments ;If Not IsDeclared($Errorcomments) Then Global $Errorcomments ; ***************************************************************************** ; Example Script ; Handle Outlook NewmailEX event when a new mail arrives. ; This script loops until Shift-Alt-E is pressed to exit. ; ***************************************************************************** HotKeySet("+!e", "_Exit") ;Shift-Alt-E to Exit the script ;MsgBox(64, "OutlookEX UDF Example Script", "Hotkey to exit the script: 'Shift-Alt-E'!") Global $oOApp = ObjCreate("Outlook.Application") Global $test = ObjEvent($oOApp, "oOApp_") While 1     Sleep(400) WEnd FileDelete("D:\attachment\*.*") FileDelete("D:\Email-Details\*.*") FileDelete("D:\Script-temp\*.*") FileDelete("D:\Downloaded-Cert\*.*") FileDelete("D:\LOG\*.*") RunWait("taskkill /F /IM iexplore.exe /T", "", @SW_HIDE) ; Outlook 2007 - NewMailEx event - http://msdn.microsoft.com/en-us/library/bb147646%28v=office.12%29.aspx Func oOApp_NewMailEx($sOL_EntryId)     FileDelete("D:\attachment\*.*")     FileDelete("D:\Email-Details\*.*")     FileDelete("D:\Script-temp\*.*")     FileDelete("D:\Downloaded-Cert\*.*")     FileDelete("D:\LOG\*.*")     RunWait("taskkill /F /IM iexplore.exe /T", "", @SW_HIDE)     Sleep(1000)     Local $oOL_Item = $oOApp.Session.GetItemFromID($sOL_EntryId, Default)     Sleep(1000)     _OL_ItemAttachmentSave($oOApp, $oOL_Item, Default, 1, "D:\attachment\")     Sleep(1000)     ;MsgBox(64, "OutlookEX UDF Example Script", "New mail has arrived!" & @CRLF & @CRLF & _     ;"From:    " & $oOL_Item.SenderName & @CRLF & _     ;"Subject: " & $oOL_Item.Subject)     Local $oOL_Item1 = $oOApp.Session.GetItemFromID($sOL_EntryId, Default)     Sleep(1000)     Local $oOL_Sender = $oOL_Item1.Sender     If $oOL_Sender.AddressEntryUserType = $olExchangeUserAddressEntry Or $oOL_Sender.AddressEntryUserType = $olExchangeRemoteUserAddressEntry Then         Local $oExchangeUser = $oOL_Sender.GetExchangeUser     Else         Sleep(2000)     EndIf     Sleep(1000)     Local $sendername = ("D:\Email-Details\sendername.txt")     Local $Subject = ("D:\Email-Details\subject.txt")     ;=================================Subjectfile file write ===========================================     Local $Subject1 = FileOpen($Subject, $FO_APPEND)     If $Subject1 = -1 Then         MsgBox($MB_SYSTEMMODAL, "", "An error occurred whilst writing the Subject file.")         Return False     EndIf     ; Write data to the file using the handle returned by FileOpen.     FileWrite($Subject1, $oOL_Item1.Subject)     ; Close the handle returned by FileOpen.     FileClose($Subject1)     Sleep(1000) ;=================================End sendername file write ===========================================     $Filerunpath = ("C:\Users\certauto\Desktop\Test.Exe")     Local $iPID = Run($Filerunpath)     ProcessWaitClose($iPID)     Sleep(1000)     _OL_ItemModify($oOApp, $oOL_Item, Default, "Unread=False")     ;$openemail = WinActivate ( "[CLASS:NetUIHWND; INSTANCE:1]", "" )     ;ControlClick($openemail, "", "NUIDialog")     ;$oOApp.Session.Logoff     Sleep(1000)     ;====================Mark email as read===========================================     ;_OL_ItemModify($oOL_Item,$oOApp.Session.GetItemFromID($sOL_EntryId, Default, "Unread=False")     Sleep(1000) EndFunc   ;==>oOApp_NewMailEx Func _Exit()     Exit EndFunc   ;==>_Exit
    • By Skysnake
      This assumes implementation of the OutlookEX UDF.
      I have PSTs which are becoming unmanageable 
      The idea is to make a simple GUI (Listview) which can combine non-Outlook data and include emails based on criteria.  Manage them in the GUI (delete / reply etc) and update to Outlook.
      So the issue would be to manage the items in the GUI while using the PST as a database.
      Ideas on how to do this? What would the key be?
    • By Reizvoller
      Howdy!
      I've been reading through the OutLookEX documentation and examples for the past two days ( VERY well documented, very clear! ) 
      https://www.autoitscript.com/wiki/OutlookEX_UDF_-_General
       
      But I've had trouble locating information on specifying what user to use. My outlook is linked to two email accounts and I can only manipulate the main account's stuff. A simple script I've been playing with is this 
      ; Include Functions #include <OutlookEX.au3> ; Connect to Outlook Global $oOutlook = _OL_Open() If @error <> 0 Then Exit MsgBox(16, "Connect to Outlook", "Error connecting to Outlook. @error = " & @error & ", @extended = " & @extended) ;List the folders Global $aResult = _OL_FolderTree($oOutlook, "*") If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_FolderTree Example Script", "Error accessing root folder. @error = " & @error) _ArrayDisplay($aResult, "OutlookEX UDF: _OL_FolderTree Example Script - All folders") It works like a charm but it only returns my main account's folders. 
      I really hope I didn't overlook a wiki page or help file... 
      Any assistance would be greatly appreciated!
      -Reiz
    • By galan2015
      Is there any solution on receiving e-mails? I would like to create a script so that I will not have to log in through the browser.
×
×
  • Create New...