Juvigy Posted June 17, 2015 Posted June 17, 2015 Hi Guys,I am trying to do a 'resend' of an email in outlook. I found some VBA that should do it , but it doesn't work; $oOutlook = ObjCreate("Outlook.Application") $myItem = $oOutlook.ActiveExplorer.Selection.Item(1) $myItem.Display $objItem = $oOutlook.ActiveExplorer.CommandBars.FindControl(Default,3165) ConsoleWrite($objItem.Name &@CRLF) ConsoleWrite($objItem.Caption &@CRLF) $objItem.Execute MsgBox(0,"","") $oOutlook = 0 ExitI don't get any errors.
water Posted June 17, 2015 Posted June 17, 2015 Why do you want tor resend an item? To the same recipient(s)? 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
Juvigy Posted June 17, 2015 Author Posted June 17, 2015 It is convenient - same recipients , same body , same subject , same attachments. For example a small change in the text is needed - resent and edit it easily and fast. Above script is reported to run ok on older versions but i have 2013 and it doesnt work on it.
water Posted June 17, 2015 Posted June 17, 2015 I suggest to create a template from this mail and then call _OL_ItemCreate passing the template name. Do the needed changes and send the mail.So no automation of the GUI is needed. 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
Juvigy Posted June 17, 2015 Author Posted June 17, 2015 Templates are OK if frequently used , but for one/few times it is not. Resent mail is more useful as you cant have templates for everything.
water Posted June 17, 2015 Posted June 17, 2015 What does$oOutlook = ObjCreate("Outlook.Application") $myItem = $oOutlook.ActiveExplorer.Selection.Item(1) $myItem.Display() $myItem.Send() $oOutlook = 0 Exitdo? 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
water Posted June 17, 2015 Posted June 17, 2015 I haven't found a method to re-send a message using COM. Maybe that's the reason why the GUI is being automated.I suggest to grab the mail temporally, save it as a template (filetype: oft), create a new item using this template, make the needed changes and send the mail. Then the temp template can be deleted. 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
Juvigy Posted June 17, 2015 Author Posted June 17, 2015 (edited) Interesting - it sends the same message , but problem is you cant modify anything. Also it strangely does something - instead of having the email 2 times in the Sent folder - it moves the one from bellow to the top. The recipient receives is 2 times though. But i will test more.@Edit : Strange- this works too:$oMyError = ObjEvent("AutoIt.Error","MyErrFunc") $oOutlook = ObjCreate("Outlook.Application") $myItem = $oOutlook.ActiveExplorer.Selection.Item(1) $myItem.Display $myItem.subject = 'Test2' $myItem.SendIt opens a sent email , modifies the subject to test2 and sends it. I though that was not possible Edited June 17, 2015 by Juvigy
water Posted June 17, 2015 Posted June 17, 2015 If this doesn't work as expected I suggest the approach from my previous post My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
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