Must Get Outlook E-mail Data into External Desktop Applicaiton - Can You Help Complete My Code?

I'm building a Flash application that needs to import email data from Outlook on sync operations, namely 1) The email body of emails with a given string existing in the subject-line, and 2) all attachments on the message.  Since I don't want the user to be required to leave my application while the sync is taking place, my idea is send commands to outlook via a remote object with VBS destination properties, as follows (just an example):
---------------------------------------------------------------------------------------
    <mx:RemoteObject id="RO" destination="MyRemoteObjectDest" fault="Alert.show(event.fault.faultstring), 'Error'">

        <mx:method name="getOutlookData">
            <mx:arguments>
                ...
            </mx:arguments>
        </mx:method>
    </mx:RemoteObject>
---------------------------------------------------------------------------------------
The "getOutlookData" is a VBS file that is meant to write Outlook data to a folder where the application can access it.  If I could send the Outlook data back though the remote object for use inside my actionScript, my application would handle the sync entirely...  Since I don't think it is possible to save references to possible email attachments and then perform 'save-as' from my app, the VBS is instead meant to create folders for each message, store the message body in a text file inside the newly created folder, then save any attachments into the folder too.  The VBS will return a Boolean indicating when operations are complete so the app can begin importing data.

The problem here is this: 1) I don't know if the VBS can be called this way or how it receives parameters if it can, 2) My VB skills are slow and I have to hunt through MSDN2 for functions while my extra-project time is limited.

My questions to you are:

1) Is there a better, simpler approach to what I'm trying to do?  If so, what is that?
2) If not, what functions do you think are best for this operation (please show where)
3) Can you pass parameters into a VBS file triggered this way?  If so, how?

Thanks.  This isn't super urgent but I'd like to get back to this soon; just need a brain-break.  Still, it's a big question, hence the point value.  Code appears below:
JaeWebbAsked:
Who is Participating?
 
RobSampsonCommented:
Hi there, it looks like
fscommand("exec","programname.exe")
is what you're after, but separate your arguments by tabs instead of spaces....

http://www.beyondflash.com/content/ch02.htm

Regards,

Rob.
0
 
JaeWebbAuthor Commented:
Forgot to include the VBS file in-progress:
-------------------------------------------------------------------------------

Sub getOutlookData()

      Dim outlookProxy As Object
      Dim folder As Object
      Dim message As Object
      Dim tempStr As String
      Dim tempFolderName As String
      Dim index As Long
      
      'Can these values be passed into the script insead, ie. 'getOutlookData(keyTHQ, keyTicketNum, targetDir)'?
      Const keyTHQ As String = "(THQ-assignment)"
      Const keyTicketNum As String = "Ticket #"
      Const targetDir As String = "C:\Resources\"
      
      Set outlookApp = CreateObject("Outlook.Application")
      Set folder = outlookProxy.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox)
      
      'Search each message in the designated folder for subject-line data containing searchkey
      For Each message in folder.Items
            If (InStr(1, message.Subject, keyTHQ) Then
                  
                  'Parse subject-line data into processing variables
                  tempStr = message.Subject
                  index = InStr(1, message.Subject, keyTicketNum)
                        'Count characters in keyTicketNum and add to index value; index should equal point after last character of keyTicketNum
                        'no such function as 'countChar' - it's just an idea at this point
                  index = index + countChar(keyTicketNum)
                        'get copy of subject-line with all characters to the left of the index-point stripped off, resulting in no spaces at front of string
                  tempStr = LTrim(tempStr(index))
                        'delete all characters after the first space from tempStr
                  tempStr = Split(tempStr, " ", 1, 1)
                  
                  
                  'Create messageFolder in target directory; messageFolder's name is equal to tempStr
                  
                  'Create text-file called "messagelog.txt" in messageFolder.  If messagelog exists, overwrite, then store
                  'message.Body data as text in messagelog.txt
                                    
                  
                  'If message has attachments, check if attachment exists in  messageFolder.  If attachment does not exist
                  'in message folder, save copy of attachment in messageFolder
      
      
      'Return a Boolean value upon completion(true if script runs successfully, false if not)
0
 
RobSampsonCommented:
Hi there,  I can tell you that values can be passed to a VBS file, and collected using the WScript.Arguments collection.

For example, you can run a command like so:
wscript yourscript.vbs value1 value2

then the VBScript will be:
'============
strParam1 = WScript.Arguments.Item(0)
strParam2 = WScript.Arguments.Item(1)

Execute("GetOutlookData(" & strParam1 & "," & strParam2 & ")"

Sub GetOutlookData(sParam1, sParam2)
      MsgBox "Parameter 1: " & sParam1 & VbCrLf & "Parameter 2: " & sParam2
End Sub
'============

As far as the Outlook bits go, I don't use Exchange, and so can't really help you there....

Regards,

Rob.
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
JaeWebbAuthor Commented:
Rob,

Thanks for your comments.

Interesting.  What environment could I call this script from (wscript yourscript.vbs value1 value2)?  It looks like a command-line type statement.  Do you know if that is the same affect as calling the yourscript.vbs file from an XML/Remote Object doc (same as clicking an exe from what I understand), or will I explictly have to run this in at a command prompt?

BTW, I don't use Exchange either.  This post is only about triggering a VB script from an application external to MS Office (Flash/AIR App).
0
 
RobSampsonCommented:
>> What environment could I call this script from?

Yes, it is a shell command.  From within your Flash application, can you "shell" a command?  To do something like that in VBScript (just to illustrate), you would use:
Set objShell = CreateObject("WScript.Shell")
objShell.Run "cscript yourscript.vbs value1 value2", 1, True

but whatever you use in Flash to execute the VBS, you can try without the cscript bit, and just see if you get the parameters passed, but otherwise, plug in the cscript (or wscript if you don't want the command prompt version), and see what happens.

Just make sure than in your VBS file you are obtaining the WScript.Arguments items.

Regards.

Rob.
0
 
JaeWebbAuthor Commented:
Rob - I read your commentary just after you posted but I forgot to let you know that 1) I appreciate your response - it looks good and 2) yes, Flash has a Shell class but I'm not totally sure on how it should be used yet.  When I get the chance, which should be before the end of the week, I'm going to study it a bit, test your solution and get back to you.
0
 
RobSampsonCommented:
DanRollins, judging by the link I posted, fsCommand seems to do the job in Flash.....

Regards,

Rob.
0
 
JaeWebbAuthor Commented:
Rob,

I was taken off of this project at work so I didn't get back to you when I said I would.  Coincidently I just put myself back on project so I'll be testing either tonight or tomorrow.  Still, without testing, I know your solution is correct.  After seeing your response I did a search for fsCommand, which I thought was just ol'school flash, but I found a reference to it in ActionScript 3.0:

http://livedocs.adobe.com/flex/2/langref/flash/system/package.html

Thanks a bunch, Rob!
0
 
RobSampsonCommented:
Great, no problem.  Thanks for that....

Regards,

Rob.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.