Passing paramaters to executitble

R

Rick A.B.

I'm trying to call an Exe file from access. The Exe is called GWsend,
it's used to send email through the GroupWise client and takes certain
paramater. I can get the following example to work fine.

Private Sub Command2_Click()
Dim smail
Dim email As String
email = "(e-mail address removed)"
smail = Shell("c:\gwmail\GWsend /T=" & email & " /S=""Subject Goes
here"" &_"
/M=""Message goes here"" /A=""C\:test.txt""", 3)
End Sub

This sends the email with the correct subject and message and attached
file.
How ever, when I start using variables gwsend doesn't like it.

If I do this

Private Sub Command2_Click()
Dim smail
Dim email As String
email = "(e-mail address removed)"
Dim txtSubject As String
txtSubject = "This is a test of GWSend"
Dim txtmessage
smail = Shell("c:\gwmail\GWsend /T=" & email & " /S=" & txtSubject & "
&_"
/M=""Message goes here"" /A=""C\:test.txt""", 3)
End Sub

What happens is that the subject is truncated to the first space in
the variable so the email shows up with a subject of This and the rest
of the subject is processed as an unidentified command paramater in
GWSend. I am wondering what I am missing. Is there a way to format
the variable to conform? What is the difference between assinging a
variable and passing the string directly?
Any help appreciated. Here is the info on GWSend.

Syntax: GWSend /T[o]=<text> [Optional Parameters]
Optional Parameters:
/S[ubject]=<text> Specify Subject
/M[essage]=<text> Specify Message (one line)
/F[ileMsg]=<file> Specify Message (loaded from file)
/C[c]=<text> Copy this recicient
/B[c]=<text> Blind Copy to this recicient
/A[ttach]=<file> Attach a file
/U[ser]=<text> Specify GW User Name (optional)
/P[assword]=<text> Specify GW User Password (optional)
/Vx=<text> Specify Variable /V0 .. /V9 for mail
merge
FileMsg may contain placeholders
&&0 .. &&9
 
D

Dale Fye

This is the greatest challenge of using Shell. In your second example, when
you use the variables, you are dropping the quotest that surround them. You
need to make sure you add an additional set of quotes.
 
R

Rick A.B.

This is the greatest challenge of using Shell.  In your second example,when
you use the variables, you are dropping the quotest that surround them.  You
need to make sure you add an additional set of quotes.
Dale,
I've tried using double quotes like
txtSubject = ""This is a test of GWSend""
but access balks and I get a compile error: expected: end of
statement

Rick
 
R

Rick A.B.

Dale,
I've tried using double quotes like
txtSubject = ""This is a test of GWSend""
 but access balks and I get a compile error: expected: end of
statement

Rick

Dale,
This now works, thanks for pointing me in the right direction.

txtSubject = """This is a test of GWSend"""

Rick
 
D

Dale Fye

Rick,

Try something like:

txtSubject = chr$(34) & "This is a test of GWSend" & chr$(34)

----
HTH
Dale



Dale Fye said:
This is the greatest challenge of using Shell. In your second example, when
you use the variables, you are dropping the quotest that surround them. You
need to make sure you add an additional set of quotes.

----
HTH
Dale



Rick A.B. said:
I'm trying to call an Exe file from access. The Exe is called GWsend,
it's used to send email through the GroupWise client and takes certain
paramater. I can get the following example to work fine.

Private Sub Command2_Click()
Dim smail
Dim email As String
email = "(e-mail address removed)"
smail = Shell("c:\gwmail\GWsend /T=" & email & " /S=""Subject Goes
here"" &_"
/M=""Message goes here"" /A=""C\:test.txt""", 3)
End Sub

This sends the email with the correct subject and message and attached
file.
How ever, when I start using variables gwsend doesn't like it.

If I do this

Private Sub Command2_Click()
Dim smail
Dim email As String
email = "(e-mail address removed)"
Dim txtSubject As String
txtSubject = "This is a test of GWSend"
Dim txtmessage
smail = Shell("c:\gwmail\GWsend /T=" & email & " /S=" & txtSubject & "
&_"
/M=""Message goes here"" /A=""C\:test.txt""", 3)
End Sub

What happens is that the subject is truncated to the first space in
the variable so the email shows up with a subject of This and the rest
of the subject is processed as an unidentified command paramater in
GWSend. I am wondering what I am missing. Is there a way to format
the variable to conform? What is the difference between assinging a
variable and passing the string directly?
Any help appreciated. Here is the info on GWSend.

Syntax: GWSend /T[o]=<text> [Optional Parameters]
Optional Parameters:
/S[ubject]=<text> Specify Subject
/M[essage]=<text> Specify Message (one line)
/F[ileMsg]=<file> Specify Message (loaded from file)
/C[c]=<text> Copy this recicient
/B[c]=<text> Blind Copy to this recicient
/A[ttach]=<file> Attach a file
/U[ser]=<text> Specify GW User Name (optional)
/P[assword]=<text> Specify GW User Password (optional)
/Vx=<text> Specify Variable /V0 .. /V9 for mail
merge
FileMsg may contain placeholders
&&0 .. &&9
 
R

Rick A.B.

Rick,

Try something like:

txtSubject = chr$(34) & "This is a test of GWSend" & chr$(34)
Dale,

Yes, that works also, thanks. It's amazing how accustom you get to
coding a certain way and you can't see the forest for the trees when
you need to do something a little different. Habits good and bad are
hard to break.

Rick
 
T

Tony Toews [MVP]

Rick A.B. said:
I'm trying to call an Exe file from access. The Exe is called GWsend,
it's used to send email through the GroupWise client and takes certain
paramater.

For alternatives see Microsoft Access Email FAQ - Novell GroupWise
http://www.granite.ab.ca/access/email/novellgroupwise.htm

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
 
T

Tony Toews [MVP]

Tony Toews said:
For alternatives see Microsoft Access Email FAQ - Novell GroupWise
http://www.granite.ab.ca/access/email/novellgroupwise.htm

A good reason to use other methods mentioned on the above web page is
you will get error messages back which you can pass onto the users.
Much more difficult when you shell out to a exe.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
 

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