rudi Posted February 3, 2023 Share Posted February 3, 2023 Hello, after doing some searches (keywords as in OP title) I didn's find a native solution here. With Google I found this PowerShell script and here (Answer #1) howto display the Outlook new email window with the prefilled things: $o = New-Object -com Outlook.Application $mail = $o.CreateItem(0) #2 = High importance message $mail.importance = 1 $mail.subject = "invoice" $mail.body = "Some body text, ... invoice PDF see attachment, please." #separate multiple recipients with a ";" $mail.To = "" # no recipients shall be prefilled #$mail.CC = <OTHER RECIPIENT 1>;<OTHER RECIPIENT 2> # Iterate over all files and only add the ones that have an .html extension $AttachFPFN = $(Get-ChildItem "C:\temp\invoice.pdf").fullname # if the extension is the one we want, add to attachments $mail.Attachments.Add($AttachFPFN) $mail.display() I have close to no experience with all the Autoit object functions and was quite astonished, that with the sample code from the help file for ObjCreate() it was quite easy to modify that code to work with Autoit as well: $oOutlook =ObjCreate("Outlook.Application") $mail = $oOutlook.CreateItem(0) $mail.subject = "invoice" $mail.body = "Some body text, ... invoice PDF see attachment, please." $mail.To = "" ; no recipients shall be prefilled $AttachFPFN = "C:\temp\invoice.pdf" $mail.Attachments.Add($AttachFPFN) $mail.display() Is it required / recommended to "cleanup / destroy" such Objects after their use? (once the email has been sent), and how to do so? The script will run in an infinite WHILE loop waiting for new PDFs to show up in the file system in some special folder. And a final question upon Objects: Is it possible to list the sub-items of an Autoit Object? With PowerShell e.g. I type $mail. [then press STRG+"SPACE" --> "Y" so see all the 123 the subitems] Earth is flat, pigs can fly, and Nuclear Power is SAFE! Link to comment Share on other sites More sharing options...
Danp2 Posted February 3, 2023 Share Posted February 3, 2023 There's a UDF for controlling Outlook. See here for more details. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
rudi Posted February 3, 2023 Author Share Posted February 3, 2023 Hello @Danp2 thanks for your reply. I've found that one before, but attachments seem not to be handled? At least I found just the notes upon "Attachment in GMail" -- propably I missed it? Earth is flat, pigs can fly, and Nuclear Power is SAFE! Link to comment Share on other sites More sharing options...
Danp2 Posted February 3, 2023 Share Posted February 3, 2023 @rudiI'm sure it can handle attachments, but I haven't actually used it so I'll defer to @wateror someone else with actual experience using this UDF. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
water Posted February 3, 2023 Share Posted February 3, 2023 Use function _OL_ItemAttachmentAdd to add an attachment to a mail item. See the example script _OL_ItemAttachmentAdd.au3 Danp2 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
rudi Posted February 6, 2023 Author Share Posted February 6, 2023 @water thanks for your suggestion. For the next, different task that's outlook related I'll take a closer look to the UDF you provided. Probably there is another function in your UDF to open a new Outlook mail, giving back an object, to wich _OL_ItemAttachmentAdd() can add files as attachment? Earth is flat, pigs can fly, and Nuclear Power is SAFE! Link to comment Share on other sites More sharing options...
water Posted February 6, 2023 Share Posted February 6, 2023 (edited) You will get a better overview by having a look at the help file (CHM) that comes with the UDF. The function reference is grouped by Outlook objects (mail, appointment ... general). More detailed information can be found in the AutoIt wiki - or here in the forum. To create a new mail item use function _OL_ItemCreate. This is a general function because it can create all types of items (mails, notes, appointments ...). Edited February 6, 2023 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 More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now