zotchy Posted August 27, 2012 Share Posted August 27, 2012 Dear Colleagues, I have a task to generate an email from GUI. This is what I have. 1. GUI with some drop-down lists; 2. Some template in HTML (or msg format) with markers. I need to generate an email. Script should open a template, replace markers with values from GUI and open it in MSG format. To, BC, BCC, Subject should be filled as well to allow me to make some modifications and press Send button. Do you have some scripts for that? Thank you very much for the help. Link to comment Share on other sites More sharing options...
water Posted August 27, 2012 Share Posted August 27, 2012 Which mail program do you use? My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
zotchy Posted August 27, 2012 Author Share Posted August 27, 2012 Which mail program do you use?Thanks for replyI have an Outlook Link to comment Share on other sites More sharing options...
water Posted August 27, 2012 Share Posted August 27, 2012 In this case you should have a look at my OutlookEX UDF (for download please see the signature). To open a template use function _OL_ItemCreate. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
zotchy Posted August 27, 2012 Author Share Posted August 27, 2012 In this case you should have a look at my OutlookEX UDF (for download please see the signature). To open a template use function _OL_ItemCreate. I have a problem creating mail based on a template. When I use function _OL_ItemCreate it renurns error. I have a script in standard AutoIt folder "Include". I have template there. I want to create mail in the same folder $oItem = _OL_ItemCreate($oOutlook, $olMailItem, "*", @ScriptDir & "unplanned_template.oft") No errors appear, but mail is not being created as well. Also how should I call this create email? I need to check the content in it and modify it by required values from GUI. Thank you for help. Link to comment Share on other sites More sharing options...
water Posted August 27, 2012 Share Posted August 27, 2012 Whats the value of @error and @extended after you called _OL_ItemCreate? My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
zotchy Posted August 27, 2012 Author Share Posted August 27, 2012 Whats the value of @error and @extended after you called _OL_ItemCreate?It returns '0' for both. Link to comment Share on other sites More sharing options...
water Posted August 27, 2012 Share Posted August 27, 2012 Then there should be a mail in the drafts folder. To display the mail use: $oItem = _OL_ItemCreate($oOutlook, $olMailItem, "*", @ScriptDir & "unplanned_template.oft") $oitem.Display My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
zotchy Posted August 27, 2012 Author Share Posted August 27, 2012 Then there should be a mail in the drafts folder.To display the mail useIt works now! Thanks. What function should we use to modify parameters of $oItem? (replace a text in Body for example) Link to comment Share on other sites More sharing options...
water Posted August 27, 2012 Share Posted August 27, 2012 Depending on the type of mail (text or html - can be accessed with property $oitem.BodyFormat) you have to access $oItem.Body or $oitem.HTMLBody. Use function _OL_ItemGet to read the property and _OL_ItemModify to update. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
zotchy Posted August 27, 2012 Author Share Posted August 27, 2012 (edited) Depending on the type of mail (text or html - can be accessed with property $oitem.BodyFormat) you have to access $oItem.Body or $oitem.HTMLBody. Use function _OL_ItemGet to read the property and _OL_ItemModify to update. Could you please provide me the example? How can I call a particular property? For example field TO:? Is the syntax correct? $oItem = _OL_ItemCreate($oOutlook, $olMailItem, "*", @ScriptDir & "unplanned_template.oft") $aOL_Properties = _OL_ItemGet($oOutlook, $oItem[1][0], Default, "??????") What options should I use instead of ?????? Thanks Dmitry Edited August 27, 2012 by zotchy Link to comment Share on other sites More sharing options...
water Posted August 27, 2012 Share Posted August 27, 2012 (edited) To set the recipients (To, CC, BCC) you need to use function _OL_ItemRecipientAdd. Example: _OL_ItemRecipientAdd($oOutlook, $oItem, Default, $olTo, "Name of Recipient1", "SMTP Mail Address of recipient 2") To retrieve the body, change and update the mail item use: $asBody = _OL_ItemGet($oOutlook, $oItem, Default, "Body") $asBody[1][1] = $asBody[1][1] & @CRLF & "New line" _OL_ItemModify($oOutlook, $oItem, Default, "Body=" & $asBody[1][1]) Edited August 27, 2012 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
zotchy Posted August 27, 2012 Author Share Posted August 27, 2012 Good. Thank you very much for your help.But I have a problem with returning values from "Body", "CC" etc.Once I try to get result of variable $sBody (Item = Body), it returns nothing to MsgBox. So I am not able to update/replace strings.ThanksDmitry Link to comment Share on other sites More sharing options...
water Posted August 27, 2012 Share Posted August 27, 2012 (edited) To work with the To, CC and BCC properties you have to use functions _OL_ItemRecipientAdd, _OL_ItemRecipientDelete and _OL_ItemRecipientGet. _Ol_ItemGet returns an 2D array. So use _ArrayDisplay($aOL_Properties) I've modified my above examples accordingly. Edited August 27, 2012 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
zotchy Posted August 27, 2012 Author Share Posted August 27, 2012 _Ol_ItemGet returns an 2D array. So use _ArrayDisplay($aOL_Properties) Great. But I have a Body with tables and pictures. Once I try to call array asBody[1][1] and make a replacement, it deletes all formatting and pictures. Thanks Link to comment Share on other sites More sharing options...
water Posted August 27, 2012 Share Posted August 27, 2012 Tables and pictures sounds like HTML. What do you get when you run this code? $asBody = _OL_ItemGet($oOutlook, $oItem, Default, "BodyFormat") _ArrayDisplay($asBody) My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
zotchy Posted August 27, 2012 Author Share Posted August 27, 2012 (edited) This is what I have: http://funkyimg.com/u2/2038/400/964514autoit.png Edited August 27, 2012 by zotchy Link to comment Share on other sites More sharing options...
water Posted August 27, 2012 Share Posted August 27, 2012 Value 2 means: HTMLSo you have to retrieve property "HTMLBody" to retain tables and pictures. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
zotchy Posted August 28, 2012 Author Share Posted August 28, 2012 Value 2 means: HTMLSo you have to retrieve property "HTMLBody" to retain tables and pictures.Everything is clear now. Thank you very much for your assistance. Link to comment Share on other sites More sharing options...
water Posted August 28, 2012 Share Posted August 28, 2012 Glad to be of service My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - 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