Pass variables value to Shell

W

wpw3

Hello

Regard below my simple routine to auto email using gbmail. I would
prefer to pass values to the routine instead of hardcoding the
recipients and the message.

This is made difficult by two reasons. First, the Shell function
appears not to accept ANY variables representing the command string.
Such is why I could not use the variable "sString" in the routine. And
second, I had trouble with the double quotes required to change the
subject of the email. The -s parameter requires quotes around the
subject if there are spaces. And since Shell requires quotes around
the command, the double quotes do not work.

Any ideas? I would like to be able to vary the subject and the
recipients by using variables. sSubject would not work because it is a
variable.

Thank you in advance for your help.

wpw3

Sub EmailFriends()

Dim MyPath As String, sString As String, sCurrPath As String
Dim sAddresses As String
Dim sSubject As String, sSMTP As String, sFrom As String
Dim RetVal As Long

sCurrPath = ActiveWorkbook.path
MyPath = "C:\Program Files\gbmail"
sSubject = "Hello My Friends"
sAddresses = "(e-mail address removed) (e-mail address removed)"
sSMTP = "nycexch01.myserver.com"
sFrom = "(e-mail address removed)"

Rem sString = "gbmail -to (e-mail address removed)
(e-mail address removed) -s Test -h nycexch01.myserver.com -from
(e-mail address removed)"

sString = "gbmail -to " & sAddresses & " -s " & sSubject & " -h " &
sSMTP & " -from " & sFrom

RetVal = Shell("c:\Program Files\gbmail\gbmail -to
(e-mail address removed) (e-mail address removed) -h
nycexch01.myserver.com -s Hello_My_Friends -from (e-mail address removed)", 0)

End Sub
 

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