PDA

View Full Version : Getting a variable from one program back to Outlook



ukdane
05-11-2011, 01:16 AM
I have a script, which works as follows.
When a new email arrives, open a secondary program, run a script within that program, then close the program.

This works, and works really well.

However, once the script has run, I need to be able to return a variable from the secondary programs script back to within Outlook, so I can use the information to something else.

I'm sure it can be done, but I seem to be suffering "brain-freeze" this morning.

Can anyone help tell me how I pass the variable back to outlook?

Thanks

Charlize
05-12-2011, 12:22 AM
How do you start the script ? From within outlook. You can define a rule that needs to run a vba macro where you call the external program. Once this is finished, the vba macro continues.

Charlize

ukdane
05-12-2011, 01:19 AM
Charlize,
The secondary program (Reflection) uses sessions. So the code within Outlook will look like this.
Set objCL = New Reflection.Session
With objCL
.RunMacro "mySessionScript.MyMacro", ""
End with


Can you help me furhter, with this information?

Charlize
05-12-2011, 01:38 AM
I'm not familiair with that reflection stuff. But can't you save the value of your variable in a textfile (within your reflection coding). In outlook you can look for that file, if it exists, read it and store the value in a variable to use and maybe kill the file from your disk ?

Charlize

Charlize
05-12-2011, 02:22 AM
If it's a terminal screen ...
ex.
First Name: John
ID: 456789
Phone: 555-1212

you could use
Dim customerName As String
Dim customerID As String
'maybe the New must be Get or something else to get current terminal session
Set objCL = New Reflection.Session
With objCL
customerName = .GetText(5, 12, 5, 23)
customerID = .GetText(6, 5, 6, 10)
End With
This means, get me the string for customer at line 5 from column 12 to line 5 and column 23 (name = 11 characters long) and get me customerid from line 6, column 5 (included) to line 6 to column 10 (included)(6 long)

Charlize

ukdane
05-12-2011, 02:37 AM
I think maybe I haven't expressed my needs well enough.

The following code runs within Outlook. Essentially what it does is run a macro within the reflection session. The marco (mySessionScript.MyMacro) will generate a series of variables.
It is these variables that I need to report back to Outlook so that Outlook can use them later within it's own macro.



Set objCL = New Reflection.Session
With objCL
.RunMacro "mySessionScript.MyMacro", ""
End With

Charlize
05-12-2011, 03:20 AM
You have to alter the code of your reflection macro. Add a write to file routine for your variables. When outlook goes further with the code, it looks for that file and after reading it, it deletes the file from you disk (but you have the data of those variables in outlook).

Charlize

ukdane
05-12-2011, 08:01 AM
I'm really looking for a solution to be able to pass a variable from one program directly to another, without the need to create a file. But if that is the only solution, then I will have to try to rewrite the code, instead.

Charlize
05-12-2011, 09:40 AM
Another option could be using environmental variables (path, username, ...). The ones we used to declare in bat-files and alike. Vba can read those to. But without you willing to share the coding (or the parts that need some tweaking) you use, it's difficult to produce something else then hypothetical solutions.

Charlize