VBA script not working

G

Guest

Hi there, I have an email sent to me when a file has finished backing up on
my server. It is sent with the Subject of the email as follows:

Status change for *file.xyz*

I am trying to create a script that processes this Subject line and then
launches an FTP client with the right parameters in order to download the
backup file. Currently I am not passing the parameters as I cannot get it to
work yet. I have a fair bit of experience with C/C++ but am a total beginner
to VBA, I was wondering if somebody could help me as to why this script isnt
working.




Sub StartFTPTransfer(TheEMail As Outlook.MailItem)

Dim Subject As String
Subject = TheEMail.Subject
Dim SubjectArray() As String

For Arrayify = 1 To Len(Subject)
SubjectArray = Mid(Subject, Arrayify, 1)
Next Arrayify

Dim i As Integer
i = 0
Do Until SubjectArray(i) = "*"
i = i + 1
Loop

Dim FileName As String
Do Until SubjectArray(i) = "*"
FileName = FileName & SubjectArray(i)
i = i + 1
Loop

Dim stAppName As String
stAppName = "D:\Program Files\FlashFXP\FlashFXP.exe"
Call Shell(stAppName, vbMaximizedFocus)

End Sub
 
G

Guest

Sorry I forgot to say that it compiles fine in the Visual Basic window that
opens when you select 'Tools\Macro\Visual Basic Editor'. However, when the
rule finds an email and runs it, the script does nothing (or at least it isnt
opening any windows/...)

Thanks again
 
G

Guest

Let's first rule out your code and see if the rule itself isn't firing.
Comment out everything and add a MsgBox "Hello world" line. If that works,
uncomment your code and try loading Notepad.exe with the Shell call.

Let me know what you find.
 
G

Guest

Thanks for your help, I managed to sort it by signing the script.

I have also completely rewritten the script as I realised what a stupid way
of doing the task it was.

Its working fine now, thanks again
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top