stealthmsgr Posted October 9, 2012 Share Posted October 9, 2012 Quick summary: What I need to do is to allow a user to draft a new message in Outlook (2003 in this case) and send it through a dedicated TCP/IP port to another dedicated port on an off-site server. Ideally two-way traffic. From research, Water's great OutlookEx UDF and it looks like OutlookSaveMail is the way to go. I'm starting a thread, but I don't have any code to start with straight away. I have the inbound/Outbound TCP side done, well for the most part I believe. Any ideas or examples I can break ground with would be appreciated. Or I could be trying to re-invent the wheel, that someone has already done. Link to comment Share on other sites More sharing options...
water Posted October 9, 2012 Share Posted October 9, 2012 I would use _OL_ItemCreate to create the draft item in Outlook. This function returns the object of the created item. Pass this object to _OL_ItemSave to write the draft to disk. Then use FileRead to grab the item and send it using TCP/IP. BTW: There are a few client/server scripts available for TCP/IP. I can post a link if you need it. 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...
stealthmsgr Posted October 9, 2012 Author Share Posted October 9, 2012 Thanks Water. I believe I have the TPC/IP side done. Its just the Outlook to TCP/IP that I'm dealing with now. I'll use your ideas and work on this a bit. Link to comment Share on other sites More sharing options...
stealthmsgr Posted October 9, 2012 Author Share Posted October 9, 2012 Water, Looking at _OL_ItemSave. It looks like it saves this as HTML, can the output be changed to text format? Link to comment Share on other sites More sharing options...
water Posted October 9, 2012 Share Posted October 9, 2012 Sure, set parameter $iOL_Type to $olTXT (see OoutlookExConstants.au3 for the OlSaveAsType enumeration). 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...
stealthmsgr Posted October 10, 2012 Author Share Posted October 10, 2012 Water I have the inbound Tx side done. I'm trying now to digest the OLK side. The html to text using $iOL_Type to $olTXT works great. Some thoughts: 1) can I pick up (automated) any msg that's input into a designated folder in OLK. 2) save it as text to a folder for re-transmission (working on this now) 3) can I then move this msg to another folder once it's saved Also I'm having a problem with the access pop-up, but I think you have a solution for that. I have modified you OL_ItemSave example, but some issues wrapping my head around some of it. I would start posting code but I see no point in simply re-posting your example. I'm simply changing folder destinations. Link to comment Share on other sites More sharing options...
water Posted October 10, 2012 Share Posted October 10, 2012 1) Please have a look at the example script section. The _OL_Example_NewMail_Event.au3 acts on every new mail received. If you just want to monitor a specific folder please have a look at _OL_Example_SentMail_Event.au3.2) Should be easy as the above example scripts return the object of the item that triggered the event3) Sure, _OL_ItemMove should do what you wantTo get rid of the security pop ups you need to pass the $sOL_WarningProgram parameter to click away the security warnings.Hope this points you into the right direction. If you have further questions please don't hesitate to ask. 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...
stealthmsgr Posted October 11, 2012 Author Share Posted October 11, 2012 I finally have some idea what is needed. Prior to this it has bee some guess work. 1) the user needs to be able to draft a message and address it to a contact. In this case the TCP/IP outbound agent 2) the message needs to be converted to a text doc 3) at that point my code can pick it up and send it out via the TCP/IP port. Sorry Water I'm just not seeing this contact capability and connecting the dots. Link to comment Share on other sites More sharing options...
water Posted October 11, 2012 Share Posted October 11, 2012 If the contact is in one of the address books use _OL_ItemRecipientAdd to set and resolve the recipient. 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...
stealthmsgr Posted October 11, 2012 Author Share Posted October 11, 2012 Ok. Here is my first shot at this so, don't laugh. ; ***************************************************************************** ; Create test environment ; ***************************************************************************** Global $oOutlook = _OL_Open() ;~ Global $aOL_Item If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error creating a connection to Outlook. @error = " & @error & ", @extended = " & @extended) Global $Result = _OL_TestEnvironmentCreate($oOutlook) If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF - Manage Test Environment", "Error creating the test environment. @error = " & @error) ; ***************************************************************************** ; Find a mail and save the item without attachements ; ***************************************************************************** Global $aOL_Item = _OL_ItemFind($oOutlook, "*TestSourceFolderMail", $olMail, "", "", "", "EntryID") If $aOL_Item[0][0] = 0 Then Exit MsgBox(16, "Test Example Script", "Could not find a mail item in folder 'TestSourceFolderMail'. @error = " & @error & ", @extended = " & @extended) _OL_ItemSave($oOutlook, $aOL_Item[1][0], Default, "C:TestMail_Out", $olTXT) Run(_OL_Warnings.exe $iOL_ProcessID [$iOL_WinCheckTime=1000[ $iOL_ControlCheckTime=1000[ $sOL_Version=""[ $iOL_Language=1033]]]]) If @error <> 0 Then Exit MsgBox(16, "Test Example Script", "Error saving mail item to C:tempTestDir1. @error = " & @error & ", @extended = " & @extended) ;~ ShellExecute("C:SMSRMMail_OutTestMail.txt") MsgBox(64, "OutlookEX UDF: _OL_ItemSave Example Script", "Item successfully saved!") 1) Having problems with the warnings. Shouldn't the _OL_Warnings.exe be qouted? 2) Environment setup, fuzzy here but can't this be streamlined? (Ok, streamlined, maybe not the best word, but what comes to mind) Link to comment Share on other sites More sharing options...
water Posted October 11, 2012 Share Posted October 11, 2012 Test environment isn't needed. Replace ******** with the folder where the draft mail is stored. The script is untested because I'm no longer in the office. ; Open connection to Outlook and specify exe to click away the security warnings (assume it's in the same directory as the script) Global $oOutlook = _OL_Open(True, "_OL_Warnings.exe") If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error creating a connection to Outlook. @error = " & @error & ", @extended = " & @extended) ; Find a mail and save the item without attachements Global $aOL_Item = _OL_ItemFind($oOutlook, "********", $olMail, "", "", "", "EntryID") If $aOL_Item[0][0] = 0 Then Exit MsgBox(16, "Test Example Script", "Could not find a mail item in folder '\Test\SourceFolder\Mail'. @error = " & @error & ", @extended = " & @extended) _OL_ItemSave($oOutlook, $aOL_Item[1][0], Default, "C:\Temp\Mail_Out\", $olTXT) If @error <> 0 Then Exit MsgBox(16, "Test Example Script", "Error saving mail item to C:\temp\Mail_Out\. @error = " & @error & ", @extended = " & @extended) MsgBox(64, "OutlookEX UDF: _OL_ItemSave Example Script", "Item successfully saved!") 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...
stealthmsgr Posted October 15, 2012 Author Share Posted October 15, 2012 Thanks for the correction. This is what I used to grab an input and then save it to a folder. #include Global $oOutlook = _OL_Open(True, "_OL_Warnings.exe") ; ***************************************************************************** ; Find a mail and save the item without attachements to a folder ; ***************************************************************************** Global $aOL_Item = _OL_ItemFind($oOutlook, "*TestSourceFolderMail", $olMail, "", "", "", "EntryID") If $aOL_Item[0][0] = 0 Then Exit MsgBox(16, "OutlookEX UDF: Test Script", "Could not find a mail item in folder 'TestSourceFolderMail'. @error = " & @error & ", @extended = " & @extended) _OL_ItemSave($oOutlook, $aOL_Item[1][0], Default, "C:TestMail_Out", $olTXT) If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: Test Script", "Error saving mail item to C:testDir1. @error = " & @error & ", @extended = " & @extended) So far so good, mate. So how would I use oOApp_NewMailEx (or the like) to monitor just one Outlook folder for any specific newly received mail? If I can do this then I suppose I also utilize this same folder for a user to create a new mail that would be routed out my TCP/IP port by placing a draft message into this same folder? Link to comment Share on other sites More sharing options...
water Posted October 15, 2012 Share Posted October 15, 2012 With the NewMailEX event you can only monitor the mail Inbox. A new mail created by the user is stored in the drafts folder until it is being sent, then it's moved to the sent folder. 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