Jump to content

Outlook to TCP port mail


Recommended Posts

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

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 - 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 (NEW 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

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 - 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 (NEW 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

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

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 event

3) Sure, _OL_ItemMove should do what you want

To 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 - 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 (NEW 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

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

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 - 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 (NEW 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

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

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 - 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 (NEW 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

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

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 - 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 (NEW 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

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...